diff options
Diffstat (limited to 'src/com')
22 files changed, 339 insertions, 281 deletions
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java index 5deb33538..40bc16eb8 100644 --- a/src/com/android/browser/BaseUi.java +++ b/src/com/android/browser/BaseUi.java @@ -32,6 +32,7 @@ import android.view.LayoutInflater; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; +import android.view.View.OnKeyListener; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.view.WindowManager; @@ -113,7 +114,6 @@ public abstract class BaseUi implements UI, WebViewFactory { mCustomViewContainer = (FrameLayout) mBrowserFrameLayout .findViewById(R.id.fullscreen_custom_content); frameLayout.addView(mBrowserFrameLayout, COVER_SCREEN_PARAMS); - } /** @@ -253,7 +253,7 @@ public abstract class BaseUi implements UI, WebViewFactory { } private void attachTabToContentView(Tab tab) { - if (tab.getWebView() == null) { + if ((tab == null) || (tab.getWebView() == null)) { return; } View container = tab.getViewContainer(); @@ -286,6 +286,8 @@ public abstract class BaseUi implements UI, WebViewFactory { Log.w(LOGTAG, "mContainer is already attached to content in" + " attachTabToContentView!"); } + mainView.setNextFocusUpId(R.id.url_focused); + mainView.setNextFocusDownId(R.id.url_focused); mUiController.attachSubWindow(tab); } @@ -643,9 +645,9 @@ public abstract class BaseUi implements UI, WebViewFactory { } private void setStatusBarVisibility(boolean visible) { - int flag = visible ? 0 : WindowManager.LayoutParams.FLAG_FULLSCREEN; - mActivity.getWindow().setFlags(flag, - WindowManager.LayoutParams.FLAG_FULLSCREEN); + WindowManager.LayoutParams params = mActivity.getWindow().getAttributes(); + params.systemUiVisibility = visible ? View.STATUS_BAR_VISIBLE : View.STATUS_BAR_HIDDEN; + mActivity.getWindow().setAttributes(params); } // ------------------------------------------------------------------------- diff --git a/src/com/android/browser/BookmarkUtils.java b/src/com/android/browser/BookmarkUtils.java index 379b22d63..cfb8e469e 100644 --- a/src/com/android/browser/BookmarkUtils.java +++ b/src/com/android/browser/BookmarkUtils.java @@ -16,6 +16,7 @@ package com.android.browser; +import android.app.ActivityManager; import android.app.AlertDialog; import android.content.ContentUris; import android.content.Context; @@ -33,6 +34,7 @@ import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.Rect; import android.graphics.RectF; +import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.PaintDrawable; import android.net.Uri; @@ -40,6 +42,7 @@ import android.os.Message; import android.preference.PreferenceManager; import android.provider.Browser; import android.provider.BrowserContract; +import android.util.DisplayMetrics; public class BookmarkUtils { private final static String LOGTAG = "BookmarkUtils"; @@ -60,10 +63,11 @@ public class BookmarkUtils { */ static Bitmap createIcon(Context context, Bitmap touchIcon, Bitmap favicon, BookmarkIconType type) { - int iconDimension = context.getResources().getDimensionPixelSize( - android.R.dimen.app_icon_size); - - return createIcon(context, touchIcon, favicon, type, iconDimension); + final ActivityManager am = (ActivityManager) context + .getSystemService(Context.ACTIVITY_SERVICE); + final int iconDimension = am.getLauncherLargeIconSize(); + final int iconDensity = am.getLauncherLargeIconDensity(); + return createIcon(context, touchIcon, favicon, type, iconDimension, iconDensity); } static Drawable createListFaviconBackground(Context context) { @@ -79,7 +83,7 @@ public class BookmarkUtils { } private static Bitmap createIcon(Context context, Bitmap touchIcon, - Bitmap favicon, BookmarkIconType type, int iconDimension) { + Bitmap favicon, BookmarkIconType type, int iconDimension, int iconDensity) { Bitmap bm = Bitmap.createBitmap(iconDimension, iconDimension, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bm); Rect iconBounds = new Rect(0, 0, bm.getWidth(), bm.getHeight()); @@ -90,7 +94,7 @@ public class BookmarkUtils { } else { // No touch icon so create our own. // Set the background based on the type of shortcut (either webapp or home shortcut). - Bitmap icon = getIconBackground(context, type); + Bitmap icon = getIconBackground(context, type, iconDensity); if (icon != null) { // Now draw the correct icon background into our new bitmap. @@ -127,17 +131,25 @@ public class BookmarkUtils { return i; } - private static Bitmap getIconBackground(Context context, BookmarkIconType type) { + private static Bitmap getIconBackground(Context context, BookmarkIconType type, int density) { if (type == BookmarkIconType.ICON_HOME_SHORTCUT) { // Want to create a shortcut icon on the homescreen, so the icon // background is the red bookmark. - return BitmapFactory.decodeResource(context.getResources(), - R.mipmap.ic_launcher_shortcut_browser_bookmark); + Drawable drawable = context.getResources().getDrawableForDensity( + R.mipmap.ic_launcher_shortcut_browser_bookmark, density); + if (drawable instanceof BitmapDrawable) { + BitmapDrawable bd = (BitmapDrawable) drawable; + return bd.getBitmap(); + } } else if (type == BookmarkIconType.ICON_INSTALLABLE_WEB_APP) { // Use the web browser icon as the background for the icon for an installable // web app. - return BitmapFactory.decodeResource(context.getResources(), - R.mipmap.ic_launcher_browser); + Drawable drawable = context.getResources().getDrawableForDensity( + R.mipmap.ic_launcher_browser, density); + if (drawable instanceof BitmapDrawable) { + BitmapDrawable bd = (BitmapDrawable) drawable; + return bd.getBitmap(); + } } return null; } diff --git a/src/com/android/browser/BookmarksLoader.java b/src/com/android/browser/BookmarksLoader.java index e2f894195..77223926b 100644 --- a/src/com/android/browser/BookmarksLoader.java +++ b/src/com/android/browser/BookmarksLoader.java @@ -21,7 +21,6 @@ import android.content.CursorLoader; import android.net.Uri; import android.provider.BrowserContract.Bookmarks; import android.provider.BrowserContract.ChromeSyncColumns; -import android.text.TextUtils; public class BookmarksLoader extends CursorLoader { public static final String ARG_ACCOUNT_TYPE = "acct_type"; diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java index a67b4e620..527f025df 100644 --- a/src/com/android/browser/BrowserActivity.java +++ b/src/com/android/browser/BrowserActivity.java @@ -94,8 +94,6 @@ public class BrowserActivity extends Activity { if (((AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE)) .isEnabled()) { setDefaultKeyMode(DEFAULT_KEYS_DISABLE); - } else { - setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL); } mController = new Controller(this); diff --git a/src/com/android/browser/BrowserBookmarksPage.java b/src/com/android/browser/BrowserBookmarksPage.java index fa7a5e289..7475237c0 100644 --- a/src/com/android/browser/BrowserBookmarksPage.java +++ b/src/com/android/browser/BrowserBookmarksPage.java @@ -25,11 +25,11 @@ import android.content.ClipData; import android.content.ClipboardManager; import android.content.ContentUris; import android.content.Context; -import android.content.CursorLoader; import android.content.Intent; import android.content.Loader; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; +import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.content.res.Configuration; import android.content.res.Resources; import android.database.Cursor; @@ -40,9 +40,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.preference.PreferenceManager; import android.provider.BrowserContract; -import android.provider.BrowserContract.Accounts; import android.provider.BrowserContract.ChromeSyncColumns; -import android.text.TextUtils; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; import android.view.LayoutInflater; @@ -52,10 +50,8 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.webkit.WebIconDatabase.IconListener; -import android.widget.Adapter; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; -import android.widget.AdapterView.OnItemSelectedListener; import android.widget.GridView; import android.widget.ListView; import android.widget.PopupMenu.OnMenuItemClickListener; @@ -74,12 +70,11 @@ interface BookmarksPageCallbacks { */ public class BrowserBookmarksPage extends Fragment implements View.OnCreateContextMenuListener, LoaderManager.LoaderCallbacks<Cursor>, OnItemClickListener, IconListener, - OnItemSelectedListener, BreadCrumbView.Controller, OnMenuItemClickListener { + BreadCrumbView.Controller, OnMenuItemClickListener, OnSharedPreferenceChangeListener { static final String LOGTAG = "browser"; static final int LOADER_BOOKMARKS = 1; - static final int LOADER_ACCOUNTS_THEN_BOOKMARKS = 2; static final String EXTRA_DISABLE_WINDOW = "disable_new_window"; @@ -88,7 +83,6 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte public static final String PREF_ACCOUNT_TYPE = "acct_type"; public static final String PREF_ACCOUNT_NAME = "acct_name"; - static final String DEFAULT_ACCOUNT = "local"; static final int VIEW_THUMBNAILS = 1; static final int VIEW_LIST = 2; static final String PREF_SELECTED_VIEW = "bookmarks_view"; @@ -124,13 +118,12 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte public Loader<Cursor> onCreateLoader(int id, Bundle args) { switch (id) { case LOADER_BOOKMARKS: { - String accountType = null; - String accountName = null; - if (args != null) { - accountType = args.getString(BookmarksLoader.ARG_ACCOUNT_TYPE); - accountName = args.getString(BookmarksLoader.ARG_ACCOUNT_NAME); - } - BookmarksLoader bl = new BookmarksLoader(getActivity(), accountType, accountName); + SharedPreferences prefs = PreferenceManager + .getDefaultSharedPreferences(getActivity()); + String accountType = prefs.getString(PREF_ACCOUNT_TYPE, null); + String accountName = prefs.getString(PREF_ACCOUNT_NAME, null); + BookmarksLoader bl = new BookmarksLoader(getActivity(), + accountType, accountName); if (mCrumbs != null) { Uri uri = (Uri) mCrumbs.getTopData(); if (uri != null) { @@ -139,11 +132,6 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte } return bl; } - case LOADER_ACCOUNTS_THEN_BOOKMARKS: { - return new CursorLoader(getActivity(), Accounts.CONTENT_URI, - new String[] { Accounts.ACCOUNT_TYPE, Accounts.ACCOUNT_NAME }, null, null, - null); - } } throw new UnsupportedOperationException("Unknown loader id " + id); } @@ -166,77 +154,12 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte mAdapter.changeCursor(cursor); break; } - - case LOADER_ACCOUNTS_THEN_BOOKMARKS: { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences( - getActivity()); - String storedAccountType = prefs.getString(PREF_ACCOUNT_TYPE, null); - String storedAccountName = prefs.getString(PREF_ACCOUNT_NAME, null); - String accountType = - TextUtils.isEmpty(storedAccountType) ? DEFAULT_ACCOUNT : storedAccountType; - String accountName = - TextUtils.isEmpty(storedAccountName) ? DEFAULT_ACCOUNT : storedAccountName; - - Bundle args = null; - if (cursor == null || !cursor.moveToFirst()) { - // No accounts, set the prefs to the default - accountType = DEFAULT_ACCOUNT; - accountName = DEFAULT_ACCOUNT; - } else { - int accountPosition = -1; - - if (!DEFAULT_ACCOUNT.equals(accountType) && - !DEFAULT_ACCOUNT.equals(accountName)) { - // Check to see if the account in prefs still exists - cursor.moveToFirst(); - do { - if (accountType.equals(cursor.getString(0)) - && accountName.equals(cursor.getString(1))) { - accountPosition = cursor.getPosition(); - break; - } - } while (cursor.moveToNext()); - } - - if (accountPosition == -1) { - if (!(DEFAULT_ACCOUNT.equals(accountType) - && DEFAULT_ACCOUNT.equals(accountName))) { - // No account is set in prefs and there is at least one, - // so pick the first one as the default - cursor.moveToFirst(); - accountType = cursor.getString(0); - accountName = cursor.getString(1); - } - } - - args = new Bundle(); - args.putString(BookmarksLoader.ARG_ACCOUNT_TYPE, accountType); - args.putString(BookmarksLoader.ARG_ACCOUNT_NAME, accountName); - } - - // The stored account name wasn't found, update the stored account with a valid one - if (!accountType.equals(storedAccountType) - || !accountName.equals(storedAccountName)) { - prefs.edit() - .putString(PREF_ACCOUNT_TYPE, accountType) - .putString(PREF_ACCOUNT_NAME, accountName) - .apply(); - } - getLoaderManager().initLoader(LOADER_BOOKMARKS, args, this); - - break; - } } } + @Override public void onLoaderReset(Loader<Cursor> loader) { onLoadFinished(loader, null); - switch (loader.getId()) { - case LOADER_BOOKMARKS: { - onLoadFinished(loader, null); - break; - } - } } long getFolderId() { @@ -443,28 +366,15 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte if (mCallbacks != null) { mCallbacks.onFolderChanged(1, BrowserContract.Bookmarks.CONTENT_URI_DEFAULT_FOLDER); } - // Start the loaders LoaderManager lm = getLoaderManager(); - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + SharedPreferences prefs = PreferenceManager + .getDefaultSharedPreferences(getActivity()); + prefs.registerOnSharedPreferenceChangeListener(this); mCurrentView = prefs.getInt(PREF_SELECTED_VIEW, BrowserBookmarksPage.VIEW_THUMBNAILS); mAdapter = new BrowserBookmarksAdapter(getActivity(), mCurrentView); - String accountType = prefs.getString(PREF_ACCOUNT_TYPE, DEFAULT_ACCOUNT); - String accountName = prefs.getString(PREF_ACCOUNT_NAME, DEFAULT_ACCOUNT); - if (!TextUtils.isEmpty(accountType) && !TextUtils.isEmpty(accountName)) { - // There is an account set, load up that one - Bundle args = null; - if (!DEFAULT_ACCOUNT.equals(accountType) && !DEFAULT_ACCOUNT.equals(accountName)) { - args = new Bundle(); - args.putString(BookmarksLoader.ARG_ACCOUNT_TYPE, accountType); - args.putString(BookmarksLoader.ARG_ACCOUNT_NAME, accountName); - } - lm.restartLoader(LOADER_BOOKMARKS, args, this); - } else { - // No account set, load the account list first - lm.restartLoader(LOADER_ACCOUNTS_THEN_BOOKMARKS, null, this); - } + lm.restartLoader(LOADER_BOOKMARKS, null, this); // Add our own listener in case there are favicons that have yet to be loaded. CombinedBookmarkHistoryView.getIconListenerSet().addListener(this); @@ -475,12 +385,17 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte @Override public void onDestroyView() { super.onDestroyView(); + SharedPreferences prefs = PreferenceManager + .getDefaultSharedPreferences(getActivity()); + prefs.unregisterOnSharedPreferenceChangeListener(this); if (mHeaderContainer != null) { mHeaderContainer.removeView(mHeader); } mCrumbs.setController(null); mCrumbs = null; getLoaderManager().destroyLoader(LOADER_BOOKMARKS); + mAdapter = null; + CombinedBookmarkHistoryView.getIconListenerSet().removeListener(this); } @Override @@ -518,36 +433,6 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte } } - @Override - public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { - Adapter adapter = parent.getAdapter(); - String accountType = "com.google"; - String accountName = adapter.getItem(position).toString(); - - Bundle args = null; - if (ACCOUNT_NAME_UNSYNCED.equals(accountName)) { - accountType = DEFAULT_ACCOUNT; - accountName = DEFAULT_ACCOUNT; - } else { - args = new Bundle(); - args.putString(BookmarksLoader.ARG_ACCOUNT_TYPE, accountType); - args.putString(BookmarksLoader.ARG_ACCOUNT_NAME, accountName); - } - - // Remember the selection for later - PreferenceManager.getDefaultSharedPreferences(getActivity()).edit() - .putString(PREF_ACCOUNT_TYPE, accountType) - .putString(PREF_ACCOUNT_NAME, accountName) - .apply(); - - getLoaderManager().restartLoader(LOADER_BOOKMARKS, args, this); - } - - @Override - public void onNothingSelected(AdapterView<?> parent) { - // Do nothing - } - /* package */ static Intent createShortcutIntent(Context context, Cursor cursor) { String url = cursor.getString(BookmarksLoader.COLUMN_INDEX_URL); String title = cursor.getString(BookmarksLoader.COLUMN_INDEX_TITLE); @@ -842,4 +727,21 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte mCrumbs.setMaxVisible(mCrumbMaxVisible); } } + + @Override + public void onSharedPreferenceChanged( + SharedPreferences sharedPreferences, String key) { + if (PREF_ACCOUNT_NAME.equals(key) || PREF_ACCOUNT_TYPE.equals(key)) { + mCrumbs.setController(null); + mCrumbs.clear(); + LoaderManager lm = getLoaderManager(); + lm.restartLoader(LOADER_BOOKMARKS, null, this); + mCrumbs.setController(this); + String name = getString(R.string.bookmarks); + mCrumbs.pushView(name, false, BrowserContract.Bookmarks.CONTENT_URI_DEFAULT_FOLDER); + if (mCallbacks != null) { + mCallbacks.onFolderChanged(1, BrowserContract.Bookmarks.CONTENT_URI_DEFAULT_FOLDER); + } + } + } } diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java index 48f1d6f63..faf004234 100644 --- a/src/com/android/browser/BrowserSettings.java +++ b/src/com/android/browser/BrowserSettings.java @@ -498,8 +498,8 @@ public class BrowserSettings extends Observable implements OnSharedPreferenceCha quickControls = p.getBoolean(PREF_QUICK_CONTROLS, quickControls); useMostVisitedHomepage = p.getBoolean(PREF_MOST_VISITED_HOMEPAGE, useMostVisitedHomepage); - // Only set these on startup if it is a dev build - if (DEV_BUILD) { + // Only set these if this is a dev build or debug is enabled + if (DEV_BUILD || showDebugSettings()) { userAgent = Integer.parseInt(p.getString(PREF_USER_AGENT, "0")); hardwareAccelerated = p.getBoolean(PREF_HARDWARE_ACCEL, hardwareAccelerated); } @@ -601,9 +601,11 @@ public class BrowserSettings extends Observable implements OnSharedPreferenceCha return showDebugSettings; } - public void toggleDebugSettings() { + public void toggleDebugSettings(Context context) { showDebugSettings = !showDebugSettings; navDump = showDebugSettings; + syncSharedPreferences(context, + PreferenceManager.getDefaultSharedPreferences(context)); update(); } diff --git a/src/com/android/browser/CombinedBookmarkHistoryView.java b/src/com/android/browser/CombinedBookmarkHistoryView.java index 734adddcf..173abba3d 100644 --- a/src/com/android/browser/CombinedBookmarkHistoryView.java +++ b/src/com/android/browser/CombinedBookmarkHistoryView.java @@ -244,14 +244,21 @@ public class CombinedBookmarkHistoryView extends LinearLayout protected void onDetachedFromWindow() { super.onDetachedFromWindow(); if (mCurrentFragment != INVALID_ID) { - FragmentManager fm = mActivity.getFragmentManager(); - FragmentTransaction transaction = fm.beginTransaction(); - if (mCurrentFragment == FRAGMENT_ID_BOOKMARKS) { - transaction.remove(mBookmarks); - } else if (mCurrentFragment == FRAGMENT_ID_HISTORY) { - transaction.remove(mHistory); + try { + FragmentManager fm = mActivity.getFragmentManager(); + FragmentTransaction transaction = fm.beginTransaction(); + if (mCurrentFragment == FRAGMENT_ID_BOOKMARKS) { + transaction.remove(mBookmarks); + } else if (mCurrentFragment == FRAGMENT_ID_HISTORY) { + transaction.remove(mHistory); + } + transaction.commit(); + } catch (IllegalStateException ex) { + // This exception is thrown if the fragment isn't added + // This will happen if the activity is finishing, and the + // fragment was already removed before this view was detached + // Aka, success! } - transaction.commit(); mCurrentFragment = INVALID_ID; } mUiController.unregisterOptionsMenuHandler(this); diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java index 6c6fe0bb3..472201b91 100644 --- a/src/com/android/browser/Controller.java +++ b/src/com/android/browser/Controller.java @@ -63,7 +63,6 @@ import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; import android.view.Gravity; import android.view.KeyEvent; -import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; @@ -78,7 +77,6 @@ import android.webkit.WebChromeClient; import android.webkit.WebIconDatabase; import android.webkit.WebSettings; import android.webkit.WebView; -import android.widget.TextView; import java.io.ByteArrayOutputStream; import java.io.File; @@ -2020,7 +2018,6 @@ public class Controller } protected void reuseTab(Tab appTab, String appId, UrlData urlData) { - Log.i(LOGTAG, "Reusing tab for " + appId); // Dismiss the subwindow if applicable. dismissSubWindow(appTab); // Since we might kill the WebView, remove it from the @@ -2127,9 +2124,11 @@ public class Controller public Tab openIncognitoTab() { if (mTabControl.canCreateNewTab()) { Tab currentTab = mTabControl.getCurrentTab(); - Tab tab = mTabControl.createNewTab(false, null, null, true); + Tab tab = mTabControl.createNewTab(false, null, + null, true); addTab(tab); setActiveTab(tab); + loadUrlDataIn(tab, new UrlData("browser:incognito")); return tab; } else { mUi.showMaxTabsWarning(); @@ -2195,12 +2194,9 @@ public class Controller removeComboView(); int currentIndex = mTabControl.getCurrentIndex(); int removeIndex = mTabControl.getTabIndex(tab); - removeTab(tab); - if (currentIndex >= removeIndex && currentIndex != 0) { - currentIndex--; - } Tab newtab = mTabControl.getTab(currentIndex); setActiveTab(newtab); + removeTab(tab); } /**************** TODO: Url loading clean up *******************************/ @@ -2413,67 +2409,28 @@ public class Controller return true; } break; - case KeyEvent.KEYCODE_B: - if (ctrl) { - bookmarksOrHistoryPicker(false); - return true; - } - break; +// case KeyEvent.KEYCODE_B: // menu case KeyEvent.KEYCODE_C: if (ctrl) { webView.copySelection(); return true; } break; - case KeyEvent.KEYCODE_D: - if (ctrl) { - bookmarkCurrentPage(AddBookmarkPage.DEFAULT_FOLDER_ID); - return true; - } - break; +// case KeyEvent.KEYCODE_D: // menu // case KeyEvent.KEYCODE_E: // in Chrome: puts '?' in URL bar - case KeyEvent.KEYCODE_F: - if (ctrl) { - webView.showFindDialog(null, true); - return true; - } - break; +// case KeyEvent.KEYCODE_F: // menu // case KeyEvent.KEYCODE_G: // in Chrome: finds next match - case KeyEvent.KEYCODE_H: - if (ctrl) { - bookmarksOrHistoryPicker(true); - return true; - } - break; +// case KeyEvent.KEYCODE_H: // menu // case KeyEvent.KEYCODE_I: // unused - case KeyEvent.KEYCODE_J: - if (ctrl) { - viewDownloads(); - return true; - } - break; +// case KeyEvent.KEYCODE_J: // menu // case KeyEvent.KEYCODE_K: // in Chrome: puts '?' in URL bar - case KeyEvent.KEYCODE_L: - if (ctrl) { - editUrl(); - return true; - } - break; +// case KeyEvent.KEYCODE_L: // menu // case KeyEvent.KEYCODE_M: // unused // case KeyEvent.KEYCODE_N: // in Chrome: new window // case KeyEvent.KEYCODE_O: // in Chrome: open file // case KeyEvent.KEYCODE_P: // in Chrome: print page // case KeyEvent.KEYCODE_Q: // unused - case KeyEvent.KEYCODE_R: - if (ctrl) { - if (mInLoad) { - stopLoading(); - } else { - webView.reload(); - } - return true; - } - break; +// case KeyEvent.KEYCODE_R: // case KeyEvent.KEYCODE_S: // in Chrome: saves page case KeyEvent.KEYCODE_T: if (ctrl) { @@ -2487,17 +2444,13 @@ public class Controller break; // case KeyEvent.KEYCODE_U: // in Chrome: opens source of page // case KeyEvent.KEYCODE_V: // text view intercepts to paste - case KeyEvent.KEYCODE_W: - if (ctrl) { - closeCurrentTab(); - return true; - } - break; +// case KeyEvent.KEYCODE_W: // menu // case KeyEvent.KEYCODE_X: // text view intercepts to cut // case KeyEvent.KEYCODE_Y: // unused // case KeyEvent.KEYCODE_Z: // unused } - return false; + // if we get here, it is a regular key and webview is not null + return mUi.dispatchKey(keyCode, event); } boolean onKeyUp(int keyCode, KeyEvent event) { diff --git a/src/com/android/browser/IntentHandler.java b/src/com/android/browser/IntentHandler.java index 9c5097533..e17fdc555 100644 --- a/src/com/android/browser/IntentHandler.java +++ b/src/com/android/browser/IntentHandler.java @@ -179,7 +179,7 @@ public class IntentHandler { } else if ("about:debug.nav".equals(urlData.mUrl)) { current.getWebView().debugDump(); } else { - mSettings.toggleDebugSettings(); + mSettings.toggleDebugSettings(mActivity); } return; } diff --git a/src/com/android/browser/PhoneUi.java b/src/com/android/browser/PhoneUi.java index 99fc4a0dd..4119c298c 100644 --- a/src/com/android/browser/PhoneUi.java +++ b/src/com/android/browser/PhoneUi.java @@ -22,6 +22,7 @@ import android.graphics.PixelFormat; import android.util.Log; import android.view.ActionMode; import android.view.Gravity; +import android.view.KeyEvent; import android.view.Menu; import android.view.View; import android.view.ViewGroup; @@ -269,4 +270,9 @@ public class PhoneUi extends BaseUi { hideFakeTitleBar(); } + @Override + public boolean dispatchKey(int code, KeyEvent event) { + return false; + } + } diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java index 83db214e1..c4897f227 100644 --- a/src/com/android/browser/Tab.java +++ b/src/com/android/browser/Tab.java @@ -148,14 +148,12 @@ class Tab { if (incognito) { mUrl = "browser:incognito"; mTitle = c.getString(R.string.new_incognito_tab); - mFavicon = BitmapFactory.decodeResource( - c.getResources(), R.drawable.fav_incognito); } else { mUrl = ""; mTitle = c.getString(R.string.new_tab); - mFavicon = BitmapFactory.decodeResource( - c.getResources(), R.drawable.app_web_browser_sm); } + mFavicon = BitmapFactory.decodeResource( + c.getResources(), R.drawable.app_web_browser_sm); mLockIcon = LockIcon.LOCK_ICON_UNSECURE; } @@ -170,13 +168,8 @@ class Tab { if (favicon != null) { mFavicon = favicon; } else { - if (incognito) { - mFavicon = BitmapFactory.decodeResource( - c.getResources(), R.drawable.fav_incognito); - } else { - mFavicon = BitmapFactory.decodeResource( - c.getResources(), R.drawable.app_web_browser_sm); - } + mFavicon = BitmapFactory.decodeResource( + c.getResources(), R.drawable.app_web_browser_sm); } } } diff --git a/src/com/android/browser/TabBar.java b/src/com/android/browser/TabBar.java index 1ab02eddd..df2e68a67 100644 --- a/src/com/android/browser/TabBar.java +++ b/src/com/android/browser/TabBar.java @@ -18,13 +18,16 @@ package com.android.browser; import com.android.browser.ScrollWebView.ScrollListener; +import android.animation.Animator; +import android.animation.Animator.AnimatorListener; +import android.animation.AnimatorSet; +import android.animation.ObjectAnimator; import android.app.Activity; import android.content.Context; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapShader; import android.graphics.Canvas; -import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.Path; @@ -151,6 +154,7 @@ public class TabBar extends LinearLayout mTabMap.clear(); for (Tab tab : tabs) { TabView tv = buildTabView(tab); + mTabs.addTab(tv); } mTabs.setSelectedTab(mTabControl.getCurrentIndex()); } @@ -286,7 +290,6 @@ public class TabBar extends LinearLayout TabView tabview = new TabView(mActivity, tab); mTabMap.put(tab, tabview); tabview.setOnClickListener(this); - mTabs.addTab(tabview); return tabview; } @@ -327,7 +330,7 @@ public class TabBar extends LinearLayout mTab = tab; setGravity(Gravity.CENTER_VERTICAL); setOrientation(LinearLayout.HORIZONTAL); - setPadding(mTabPadding, 0, 0, 0); + setPadding(mTabOverlap, 0, mTabSliceWidth, 0); LayoutInflater inflater = LayoutInflater.from(getContext()); mTabContent = inflater.inflate(R.layout.tab_title, this, true); mTitle = (TextView) mTabContent.findViewById(R.id.title); @@ -346,6 +349,14 @@ public class TabBar extends LinearLayout void showIndicator(boolean show) { if (mSelected) { mIndicator.setVisibility(show ? View.VISIBLE : View.GONE); + LayoutParams lp = (LinearLayout.LayoutParams) getLayoutParams(); + if (show) { + lp.width = mTabWidthSelected + mIndicator.getWidth(); + } else { + lp.width = mTabWidthSelected; + } + lp.height = LayoutParams.MATCH_PARENT; + setLayoutParams(lp); } else { mIndicator.setVisibility(View.GONE); } @@ -485,21 +496,88 @@ public class TabBar extends LinearLayout } + static Drawable createFaviconBackground(Context context) { + PaintDrawable faviconBackground = new PaintDrawable(); + Resources res = context.getResources(); + faviconBackground.getPaint().setColor(context.getResources() + .getColor(R.color.tabFaviconBackground)); + faviconBackground.setCornerRadius( + res.getDimension(R.dimen.tab_favicon_corner_radius)); + return faviconBackground; + } + private Drawable renderFavicon(Bitmap icon) { - Drawable[] array = new Drawable[3]; - array[0] = new PaintDrawable(Color.BLACK); - array[1] = new PaintDrawable(Color.WHITE); + Drawable[] array = new Drawable[2]; + array[0] = createFaviconBackground(getContext()); if (icon == null) { - array[2] = mGenericFavicon; + array[1] = mGenericFavicon; } else { - array[2] = new BitmapDrawable(icon); + array[1] = new BitmapDrawable(icon); } LayerDrawable d = new LayerDrawable(array); - d.setLayerInset(1, 1, 1, 1, 1); - d.setLayerInset(2, 2, 2, 2, 2); + d.setLayerInset(1, 2, 2, 2, 2); return d; } + private void animateTabOut(final Tab tab, final TabView tv) { + ObjectAnimator scalex = ObjectAnimator.ofFloat(tv, "scaleX", 1.0f, 0.0f); + ObjectAnimator scaley = ObjectAnimator.ofFloat(tv, "scaleY", 1.0f, 0.0f); + ObjectAnimator alpha = ObjectAnimator.ofFloat(tv, "alpha", 1.0f, 0.0f); + AnimatorSet animator = new AnimatorSet(); + animator.playTogether(scalex, scaley, alpha); + animator.setDuration(150); + animator.addListener(new AnimatorListener() { + + @Override + public void onAnimationCancel(Animator animation) { + } + + @Override + public void onAnimationEnd(Animator animation) { + mTabs.removeTab(tv); + mTabMap.remove(tab); + mUi.onRemoveTabCompleted(tab); + } + + @Override + public void onAnimationRepeat(Animator animation) { + } + + @Override + public void onAnimationStart(Animator animation) { + } + + }); + animator.start(); + } + + private void animateTabIn(final Tab tab, final TabView tv) { + ObjectAnimator scalex = ObjectAnimator.ofFloat(tv, "scaleX", 0.0f, 1.0f); + scalex.setDuration(150); + scalex.addListener(new AnimatorListener() { + + @Override + public void onAnimationCancel(Animator animation) { + } + + @Override + public void onAnimationEnd(Animator animation) { + mUi.onAddTabCompleted(tab); + } + + @Override + public void onAnimationRepeat(Animator animation) { + } + + @Override + public void onAnimationStart(Animator animation) { + mTabs.addTab(tv); + } + + }); + scalex.start(); + } + // TabChangeListener implementation public void onSetActiveTab(Tab tab) { @@ -526,6 +604,7 @@ public class TabBar extends LinearLayout public void onNewTab(Tab tab) { TabView tv = buildTabView(tab); + animateTabIn(tab, tv); } public void onProgress(Tab tab, int progress) { @@ -538,9 +617,10 @@ public class TabBar extends LinearLayout public void onRemoveTab(Tab tab) { TabView tv = mTabMap.get(tab); if (tv != null) { - mTabs.removeTab(tv); + animateTabOut(tab, tv); + } else { + mTabMap.remove(tab); } - mTabMap.remove(tab); } public void onUrlAndTitle(Tab tab, String url, String title) { diff --git a/src/com/android/browser/TabScrollView.java b/src/com/android/browser/TabScrollView.java index 09dddee44..d0648b706 100644 --- a/src/com/android/browser/TabScrollView.java +++ b/src/com/android/browser/TabScrollView.java @@ -28,7 +28,6 @@ import android.widget.LinearLayout; */ public class TabScrollView extends HorizontalScrollView { - private Context mContext; private LinearLayout mContentView; private int mSelected; private int mAnimationDuration; @@ -62,13 +61,12 @@ public class TabScrollView extends HorizontalScrollView { } private void init(Context ctx) { - mContext = ctx; mAnimationDuration = ctx.getResources().getInteger( R.integer.tab_animation_duration); mTabOverlap = (int) ctx.getResources().getDimension(R.dimen.tab_overlap); setHorizontalScrollBarEnabled(false); setOverScrollMode(OVER_SCROLL_NEVER); - mContentView = new TabLayout(mContext); + mContentView = new TabLayout(ctx); mContentView.setOrientation(LinearLayout.HORIZONTAL); mContentView.setLayoutParams( new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); @@ -189,6 +187,21 @@ public class TabScrollView extends HorizontalScrollView { return getScrollX(); } + @Override + protected void onScrollChanged(int l, int t, int oldl, int oldt) { + super.onScrollChanged(l, t, oldl, oldt); + + // TabViews base their drawing based on their absolute position within the + // window. When hardware accelerated, we need to recreate their display list + // when they scroll + if (isHardwareAccelerated()) { + int count = mContentView.getChildCount(); + for (int i = 0; i < count; i++) { + mContentView.getChildAt(i).invalidate(); + } + } + } + class TabLayout extends LinearLayout { public TabLayout(Context context) { diff --git a/src/com/android/browser/TitleBarXLarge.java b/src/com/android/browser/TitleBarXLarge.java index 4822cc077..0dcece60b 100644 --- a/src/com/android/browser/TitleBarXLarge.java +++ b/src/com/android/browser/TitleBarXLarge.java @@ -60,6 +60,7 @@ public class TitleBarXLarge extends TitleBarBase private ImageButton mBackButton; private ImageButton mForwardButton; private ImageView mStar; + private ImageView mWebIcon; private View mSearchButton; private View mUrlContainer; private View mGoButton; @@ -105,6 +106,7 @@ public class TitleBarXLarge extends TitleBarBase // back/forward. Probably should be done inside onPageStarted. mBackButton = (ImageButton) findViewById(R.id.back); mForwardButton = (ImageButton) findViewById(R.id.forward); + mWebIcon = (ImageView) findViewById(R.id.web_icon); mStar = (ImageView) findViewById(R.id.star); mStopButton = (ImageView) findViewById(R.id.stop); mSearchButton = findViewById(R.id.search); @@ -131,7 +133,7 @@ public class TitleBarXLarge extends TitleBarBase mUrlInput.setOnFocusChangeListener(this); mUrlInput.setSelectAllOnFocus(true); mUrlInput.addTextChangedListener(this); - setUrlMode(false); + setEditMode(false); } void updateNavigationState(Tab tab) { @@ -158,7 +160,7 @@ public class TitleBarXLarge extends TitleBarBase void setUseQuickControls(boolean useQuickControls) { mUseQuickControls = useQuickControls; - mUrlInput.setReverseResults(mUseQuickControls); + mUrlInput.setUseQuickControls(mUseQuickControls); if (mUseQuickControls) { mBackButton.setVisibility(View.GONE); mForwardButton.setVisibility(View.GONE); @@ -185,7 +187,11 @@ public class TitleBarXLarge extends TitleBarBase if (!mEditable && hasFocus) { mUi.editUrl(false); } else { - setUrlMode(hasFocus); + if (hasFocus) { + setEditMode(hasFocus); + } else { + mUrlInput.stopEditing(); + } } mUrlContainer.setBackgroundDrawable(hasFocus ? mFocusDrawable : mUnfocusDrawable); @@ -264,7 +270,7 @@ public class TitleBarXLarge extends TitleBarBase private void clearOrClose() { if (TextUtils.isEmpty(mUrlInput.getText())) { // close - setUrlMode(false); + mUrlInput.stopEditing(); } else { // clear mUrlInput.setText(""); @@ -300,22 +306,21 @@ public class TitleBarXLarge extends TitleBarBase i.putExtra(SearchManager.APP_DATA, appData); } mUiController.handleNewIntent(i); - setUrlMode(false); setDisplayTitle(text); } @Override public void onDismiss() { - WebView top = mUiController.getCurrentTopWebView(); - if (top != null) { - mUiController.getCurrentTopWebView().requestFocus(); - } + final Tab currentTab = mUi.getActiveTab(); mUi.hideFakeTitleBar(); - setUrlMode(false); - // if top != null current must be set - if ((top != null) && !mInVoiceMode) { - setDisplayTitle(mUiController.getCurrentWebView().getUrl()); - } + post(new Runnable() { + public void run() { + TitleBarXLarge.this.clearFocus(); + if ((currentTab != null) && !mInVoiceMode) { + setDisplayTitle(currentTab.getUrl()); + } + } + }); } /** @@ -330,8 +335,8 @@ public class TitleBarXLarge extends TitleBarBase } } - void setUrlMode(boolean focused) { - if (focused) { + void setEditMode(boolean edit) { + if (edit) { mUrlInput.setDropDownWidth(mUrlContainer.getWidth()); mUrlInput.setDropDownHorizontalOffset(-mUrlInput.getLeft()); mSearchButton.setVisibility(View.GONE); @@ -340,9 +345,9 @@ public class TitleBarXLarge extends TitleBarBase if (mInVoiceMode) { mVoiceSearchIndicator.setVisibility(View.VISIBLE); } + mWebIcon.setImageResource(R.drawable.ic_search_holo_dark); updateSearchMode(); } else { - mUrlInput.clearFocus(); mGoButton.setVisibility(View.GONE); mVoiceSearch.setVisibility(View.GONE); mStar.setVisibility(View.VISIBLE); @@ -353,6 +358,7 @@ public class TitleBarXLarge extends TitleBarBase } else { mSearchButton.setVisibility(View.VISIBLE); } + mWebIcon.setImageResource(R.drawable.ic_web_holo_dark); } } @@ -450,4 +456,5 @@ public class TitleBarXLarge extends TitleBarBase void setIncognitoMode(boolean incognito) { mUrlInput.setIncognitoMode(incognito); } + } diff --git a/src/com/android/browser/UI.java b/src/com/android/browser/UI.java index 47385223d..8de2b19ab 100644 --- a/src/com/android/browser/UI.java +++ b/src/com/android/browser/UI.java @@ -20,6 +20,7 @@ import android.content.res.Configuration; import android.graphics.Bitmap; import android.os.Bundle; import android.view.ActionMode; +import android.view.KeyEvent; import android.view.Menu; import android.view.View; import android.webkit.WebChromeClient.CustomViewCallback; @@ -117,4 +118,6 @@ public interface UI { void showMaxTabsWarning(); + boolean dispatchKey(int code, KeyEvent event); + } diff --git a/src/com/android/browser/UrlInputView.java b/src/com/android/browser/UrlInputView.java index 021484301..23e412dd1 100644 --- a/src/com/android/browser/UrlInputView.java +++ b/src/com/android/browser/UrlInputView.java @@ -18,11 +18,15 @@ package com.android.browser; import com.android.browser.SuggestionsAdapter.CompletionListener; import com.android.browser.SuggestionsAdapter.SuggestItem; +import com.android.browser.search.SearchEngine; +import com.android.browser.search.SearchEngineInfo; +import com.android.browser.search.SearchEngines; import android.content.Context; import android.content.res.Configuration; import android.text.TextUtils; import android.util.AttributeSet; +import android.util.Patterns; import android.view.KeyEvent; import android.view.View; import android.view.View.OnFocusChangeListener; @@ -55,6 +59,8 @@ public class UrlInputView extends AutoCompleteTextView private View mContainer; private boolean mLandscape; private boolean mInVoiceMode; + private boolean mIncognitoMode; + private int mVOffset; public UrlInputView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); @@ -81,6 +87,7 @@ public class UrlInputView extends AutoCompleteTextView onConfigurationChanged(ctx.getResources().getConfiguration()); setThreshold(1); setOnItemClickListener(this); + mVOffset = 0; } void setController(UiController controller) { @@ -89,6 +96,13 @@ public class UrlInputView extends AutoCompleteTextView setCustomSelectionActionModeCallback(urlSelectionMode); } + void setUseQuickControls(boolean useQuickControls) { + mVOffset = (useQuickControls + ? (int) getResources().getDimension(R.dimen.dropdown_offset) + : 0); + mAdapter.setReverseResults(useQuickControls); + } + void setContainer(View container) { mContainer = container; } @@ -130,7 +144,7 @@ public class UrlInputView extends AutoCompleteTextView if (getLeft() != -getDropDownHorizontalOffset()) { setDropDownHorizontalOffset(-getLeft()); } - setDropDownVerticalOffset(8); + setDropDownVerticalOffset(mVOffset); } @Override @@ -152,14 +166,16 @@ public class UrlInputView extends AutoCompleteTextView performFiltering(getText().toString(), 0); showDropDown(); } - } else { - finishInput(null, null, null); } if (mWrappedFocusListener != null) { mWrappedFocusListener.onFocusChange(v, hasFocus); } } + void stopEditing() { + finishInput(null, null, null); + } + public void setUrlInputListener(UrlInputListener listener) { mListener = listener; } @@ -174,10 +190,33 @@ public class UrlInputView extends AutoCompleteTextView if (TextUtils.isEmpty(url)) { mListener.onDismiss(); } else { + if (mIncognitoMode && isSearch(url)) { + // To prevent logging, intercept this request + // TODO: This is a quick hack, refactor this + SearchEngine searchEngine = BrowserSettings.getInstance() + .getSearchEngine(); + if (searchEngine == null) return; + SearchEngineInfo engineInfo = SearchEngines + .getSearchEngineInfo(mContext, searchEngine.getName()); + if (engineInfo == null) return; + url = engineInfo.getSearchUriForQuery(url); + // mLister.onAction can take it from here without logging + } mListener.onAction(url, extra, source); } } + boolean isSearch(String inUrl) { + String url = UrlUtils.fixUrl(inUrl).trim(); + if (TextUtils.isEmpty(url)) return false; + + if (Patterns.WEB_URL.matcher(url).matches() + || UrlUtils.ACCEPTED_URI_SCHEMA.matcher(url).matches()) { + return false; + } + return true; + } + // Completion Listener @Override @@ -219,12 +258,9 @@ public class UrlInputView extends AutoCompleteTextView } - public void setReverseResults(boolean reverse) { - mAdapter.setReverseResults(reverse); - } - public void setIncognitoMode(boolean incognito) { - mAdapter.setIncognitoMode(incognito); + mIncognitoMode = incognito; + mAdapter.setIncognitoMode(mIncognitoMode); } } diff --git a/src/com/android/browser/UrlUtils.java b/src/com/android/browser/UrlUtils.java index 0a7e90c40..d6278ca40 100644 --- a/src/com/android/browser/UrlUtils.java +++ b/src/com/android/browser/UrlUtils.java @@ -152,7 +152,8 @@ public class UrlUtils { if (inUrl == null) { return ""; } - if (inUrl.startsWith(HomeProvider.MOST_VISITED)) { + if (inUrl.startsWith("content:") + || inUrl.startsWith("browser:")) { return ""; } return inUrl; diff --git a/src/com/android/browser/XLargeUi.java b/src/com/android/browser/XLargeUi.java index a9cc9fe38..0fa38cfb0 100644 --- a/src/com/android/browser/XLargeUi.java +++ b/src/com/android/browser/XLargeUi.java @@ -24,6 +24,7 @@ import android.os.Bundle; import android.util.Log; import android.view.ActionMode; import android.view.Gravity; +import android.view.KeyEvent; import android.view.View; import android.webkit.WebChromeClient.CustomViewCallback; import android.webkit.WebView; @@ -81,6 +82,7 @@ public class XLargeUi extends BaseUi implements ScrollListener { @Override public void hideComboView() { + checkTabCount(); super.hideComboView(); // ComboView changes the action bar, set it back up to what we want setupActionBar(); @@ -209,6 +211,9 @@ public class XLargeUi extends BaseUi implements ScrollListener { @Override public void addTab(Tab tab) { mTabBar.onNewTab(tab); + } + + protected void onAddTabCompleted(Tab tab) { checkTabCount(); } @@ -251,6 +256,9 @@ public class XLargeUi extends BaseUi implements ScrollListener { public void removeTab(Tab tab) { super.removeTab(tab); mTabBar.onRemoveTab(tab); + } + + protected void onRemoveTabCompleted(Tab tab) { checkTabCount(); } @@ -296,7 +304,7 @@ public class XLargeUi extends BaseUi implements ScrollListener { @Override protected void hideFakeTitleBar() { if (isFakeTitleBarShowing()) { - mFakeTitleBar.setUrlMode(false); + mFakeTitleBar.setEditMode(false); mContentView.removeView(mFakeTitleBar); mTabBar.onHideTitleBar(); } @@ -396,4 +404,25 @@ public class XLargeUi extends BaseUi implements ScrollListener { mActivity.getActionBar().show(); } } + + @Override + public boolean dispatchKey(int code, KeyEvent event) { + WebView web = getActiveTab().getWebView(); + switch (code) { + case KeyEvent.KEYCODE_TAB: + case KeyEvent.KEYCODE_DPAD_UP: + case KeyEvent.KEYCODE_DPAD_LEFT: + if ((web != null) && web.hasFocus()) { + editUrl(true); + return true; + } + } + boolean ctrl = event.hasModifiers(KeyEvent.META_CTRL_ON); + if (!ctrl && event.isPrintingKey() && !mFakeTitleBar.isEditingUrl()) { + editUrl(true); + return mContentView.dispatchKeyEvent(event); + } + return false; + } + } diff --git a/src/com/android/browser/preferences/GeneralPreferencesFragment.java b/src/com/android/browser/preferences/GeneralPreferencesFragment.java index 273516616..b6228dc4e 100644 --- a/src/com/android/browser/preferences/GeneralPreferencesFragment.java +++ b/src/com/android/browser/preferences/GeneralPreferencesFragment.java @@ -224,7 +224,7 @@ public class GeneralPreferencesFragment extends PreferenceFragment mDialog = new AlertDialog.Builder(getActivity()) .setIcon(android.R.drawable.ic_dialog_alert) - .setTitle("Choose account") // STOPSHIP localize + .setTitle(R.string.account_chooser_dialog_title) .setSingleChoiceItems(accountNames, curAccountOffset, this) .create(); return mDialog; diff --git a/src/com/android/browser/preferences/PrivacySecurityPreferencesFragment.java b/src/com/android/browser/preferences/PrivacySecurityPreferencesFragment.java index c0cf3cf57..91705e5cb 100644 --- a/src/com/android/browser/preferences/PrivacySecurityPreferencesFragment.java +++ b/src/com/android/browser/preferences/PrivacySecurityPreferencesFragment.java @@ -44,6 +44,11 @@ public class PrivacySecurityPreferencesFragment extends PreferenceFragment Preference e = findPreference(BrowserSettings.PREF_CLEAR_HISTORY); e.setOnPreferenceChangeListener(this); + } + + @Override + public void onResume() { + super.onResume(); setupAutoLoginPreference(); } @@ -66,6 +71,8 @@ public class PrivacySecurityPreferencesFragment extends PreferenceFragment values[i] = ""; autologinPref.setEntries(names); autologinPref.setEntryValues(values); + autologinPref.setValue(BrowserSettings.getInstance() + .getAutoLoginAccount(getActivity())); } private void updateAutoLoginSummary(Preference pref) { diff --git a/src/com/android/browser/search/SearchEngines.java b/src/com/android/browser/search/SearchEngines.java index 62690e77c..a6ba3de05 100644 --- a/src/com/android/browser/search/SearchEngines.java +++ b/src/com/android/browser/search/SearchEngines.java @@ -61,7 +61,7 @@ public class SearchEngines { return new OpenSearchSearchEngine(context, searchEngineInfo); } - private static SearchEngineInfo getSearchEngineInfo(Context context, String name) { + public static SearchEngineInfo getSearchEngineInfo(Context context, String name) { try { return new SearchEngineInfo(context, name); } catch (IllegalArgumentException exception) { diff --git a/src/com/android/browser/widget/BookmarkThumbnailWidgetService.java b/src/com/android/browser/widget/BookmarkThumbnailWidgetService.java index 51ba2ca18..1c7856f3a 100644 --- a/src/com/android/browser/widget/BookmarkThumbnailWidgetService.java +++ b/src/com/android/browser/widget/BookmarkThumbnailWidgetService.java @@ -75,14 +75,16 @@ public class BookmarkThumbnailWidgetService extends RemoteViewsService { private static final int BOOKMARK_INDEX_TOUCH_ICON = 5; private static final int BOOKMARK_INDEX_THUMBNAIL = 7; - private Map<Integer, BookmarkFactory> mFactories; + // The service will likely be destroyed at any time, so we need to keep references to the + // factories across services connections. + private static final Map<Integer, BookmarkFactory> mFactories = + new HashMap<Integer, BookmarkFactory>(); private Handler mUiHandler; private BookmarksObserver mBookmarksObserver; @Override public void onCreate() { super.onCreate(); - mFactories = new HashMap<Integer, BookmarkFactory>(); mUiHandler = new Handler(); mBookmarksObserver = new BookmarksObserver(mUiHandler); getContentResolver().registerContentObserver( @@ -109,6 +111,12 @@ public class BookmarkThumbnailWidgetService extends RemoteViewsService { BookmarkFactory fac = mFactories.get(widgetId); if (fac != null && folderId >= 0) { fac.changeFolder(folderId); + } else { + // This a workaround to the issue when the Browser process crashes, after which + // mFactories is not populated (due to onBind() not being called). Calling + // notifyDataSetChanged() will trigger a connection to be made. + AppWidgetManager.getInstance(getApplicationContext()) + .notifyAppWidgetViewDataChanged(widgetId, R.id.bookmarks_list); } } return START_STICKY; |
