import android.text.format.DateFormat;
import android.util.AttributeSet;
import android.util.Log;
+import android.util.Patterns;
import android.view.ContextMenu;
import android.view.Gravity;
import android.view.KeyEvent;
import android.accounts.OperationCanceledException;
import android.accounts.AccountManagerCallback;
-import com.android.common.Patterns;
import com.android.common.Search;
import com.android.common.speech.LoggingEvents;
-import com.google.android.gsf.GoogleLoginServiceConstants;
-
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
private Account[] mAccountsGoogle;
private Account[] mAccountsPreferHosted;
+ // XXX: These constants should be exposed through some public api. Hardcode
+ // the values for now until some solution for gsf can be worked out.
+ // http://b/issue?id=2425179
+ private static final String ACCOUNT_TYPE = "com.google";
+ private static final String FEATURE_LEGACY_GOOGLE = "legacy_google";
+ private static final String FEATURE_LEGACY_HOSTED_OR_GOOGLE =
+ "legacy_hosted_or_google";
+
private void startReadOfGoogleAccounts() {
mAccountsGoogle = null;
mAccountsPreferHosted = null;
AccountManager.get(this).getAccountsByTypeAndFeatures(
- GoogleLoginServiceConstants.ACCOUNT_TYPE,
- new String[]{GoogleLoginServiceConstants.FEATURE_LEGACY_HOSTED_OR_GOOGLE},
+ ACCOUNT_TYPE, new String[]{ FEATURE_LEGACY_HOSTED_OR_GOOGLE },
this, null);
}
mAccountsGoogle = accountManagerFuture.getResult();
AccountManager.get(this).getAccountsByTypeAndFeatures(
- GoogleLoginServiceConstants.ACCOUNT_TYPE,
- new String[]{GoogleLoginServiceConstants.FEATURE_LEGACY_GOOGLE},
+ ACCOUNT_TYPE, new String[]{ FEATURE_LEGACY_GOOGLE },
this, null);
} else {
mAccountsPreferHosted = accountManagerFuture.getResult();
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Browser");
+ // Find out if the network is currently up.
+ ConnectivityManager cm = (ConnectivityManager) getSystemService(
+ Context.CONNECTIVITY_SERVICE);
+ NetworkInfo info = cm.getActiveNetworkInfo();
+ if (info != null) {
+ mIsNetworkUp = info.isAvailable();
+ }
+
/* enables registration for changes in network status from
http stack */
mNetworkStateChangedFilter = new IntentFilter();
url = intent.getStringExtra(SearchManager.QUERY);
if (url != null) {
mLastEnteredUrl = url;
- Browser.updateVisitedHistory(mResolver, url, false);
// In general, we shouldn't modify URL from Intent.
// But currently, we get the user-typed URL from search box as well.
url = fixUrl(url);
url = smartUrlFilter(url);
+ Browser.updateVisitedHistory(mResolver, url, false);
String searchSource = "&source=android-" + GOOGLE_SEARCH_SOURCE_SUGGEST + "&";
if (url.contains(searchSource)) {
String source = null;
mTitleBar.setInVoiceMode(false);
mFakeTitleBar.setInVoiceMode(false);
- mTitleBar.setDisplayTitle(mTitle);
- mFakeTitleBar.setDisplayTitle(mTitle);
+ mTitleBar.setDisplayTitle(mUrl);
+ mFakeTitleBar.setDisplayTitle(mUrl);
}
/* package */ static String fixUrl(String inUrl) {
// FIXME: Converting the url to lower case
}
mFindDialog.setWebView(getTopWindow());
mFindDialog.show();
+ getTopWindow().setFindIsUp(true);
mMenuState = EMPTY_MENU;
break;
resetTitleIconAndProgress();
}
- private void goBackOnePageOrQuit() {
+ /* package */ void goBackOnePageOrQuit() {
Tab current = mTabControl.getCurrentTab();
if (current == null) {
/*
* an {@link Intent} to launch the Activity chooser.
* @param c Context used to launch a new Activity.
* @param title Title of the page. Stored in the Intent with
- * {@link Browser#EXTRA_SHARE_TITLE}
+ * {@link Intent#EXTRA_SUBJECT}
* @param url URL of the page. Stored in the Intent with
* {@link Intent#EXTRA_TEXT}
* @param favicon Bitmap of the favicon for the page. Stored in the Intent
Intent send = new Intent(Intent.ACTION_SEND);
send.setType("text/plain");
send.putExtra(Intent.EXTRA_TEXT, url);
- send.putExtra(Browser.EXTRA_SHARE_TITLE, title);
+ send.putExtra(Intent.EXTRA_SUBJECT, title);
send.putExtra(Browser.EXTRA_SHARE_FAVICON, favicon);
send.putExtra(Browser.EXTRA_SHARE_SCREENSHOT, screenshot);
try {
hideFakeTitleBar();
}
}
- } else if (!mInLoad) {
- // onPageFinished may have already been called but a subframe is
- // still loading and updating the progress. Reset mInLoad and update
- // the menu items.
- mInLoad = true;
- updateInLoadMenuItems();
+ } else {
+ if (!mInLoad) {
+ // onPageFinished may have already been called but a subframe is
+ // still loading and updating the progress. Reset mInLoad and
+ // update the menu items.
+ mInLoad = true;
+ updateInLoadMenuItems();
+ }
+ // When the page first begins to load, the Activity may still be
+ // paused, in which case showFakeTitleBar will do nothing. Call
+ // again as the page continues to load so that it will be shown.
+ // (Calling it will the fake title bar is already showing will also
+ // do nothing.
if (!mOptionsMenuOpen || mIconView) {
// This page has begun to load, so show the title bar
showFakeTitleBar();
}
// issued on:
- String issuedOn = reformatCertificateDate(
- certificate.getValidNotBefore());
+ String issuedOn = formatCertificateDate(
+ certificate.getValidNotBeforeDate());
((TextView) certificateView.findViewById(R.id.issued_on))
.setText(issuedOn);
// expires on:
- String expiresOn = reformatCertificateDate(
- certificate.getValidNotAfter());
+ String expiresOn = formatCertificateDate(
+ certificate.getValidNotAfterDate());
((TextView) certificateView.findViewById(R.id.expires_on))
.setText(expiresOn);
}
/**
- * Re-formats the certificate date (Date.toString()) string to
- * a properly localized date string.
+ * Formats the certificate date to a properly localized date string.
* @return Properly localized version of the certificate date string and
- * the original certificate date string if fails to localize.
- * If the original string is null, returns an empty string "".
+ * the "" if it fails to localize.
*/
- private String reformatCertificateDate(String certificateDate) {
- String reformattedDate = null;
-
- if (certificateDate != null) {
- Date date = null;
- try {
- date = java.text.DateFormat.getInstance().parse(certificateDate);
- } catch (ParseException e) {
- date = null;
- }
-
- if (date != null) {
- reformattedDate =
- DateFormat.getDateFormat(this).format(date);
- }
+ private String formatCertificateDate(Date certificateDate) {
+ if (certificateDate == null) {
+ return "";
}
-
- return reformattedDate != null ? reformattedDate :
- (certificateDate != null ? certificateDate : "");
+ String formattedDate = DateFormat.getDateFormat(this).format(certificateDate);
+ if (formattedDate == null) {
+ return "";
+ }
+ return formattedDate;
}
/**