From eb6eef4c45df2d65c3e70660493a147a2be405e3 Mon Sep 17 00:00:00 2001 From: Grace Kloba Date: Tue, 15 Sep 2009 17:56:32 -0700 Subject: [PATCH] Fix the lock icon when switch tabs. In switchToTab, I think it is wrong code where it calls removeTabFromContentView(tab). In openTabAndShow, we should really attach after we the tab to the current. Fix http://b/issue?id=2067930 --- src/com/android/browser/BrowserActivity.java | 56 ++++++++++++++-------------- src/com/android/browser/TabControl.java | 21 +++++++++++ 2 files changed, 48 insertions(+), 29 deletions(-) diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java index 74103f2..dc65b81 100644 --- a/src/com/android/browser/BrowserActivity.java +++ b/src/com/android/browser/BrowserActivity.java @@ -1365,10 +1365,10 @@ public class BrowserActivity extends Activity // we do not need to remove it removeTabFromContentView(currentTab); } - removeTabFromContentView(tab); mTabControl.setCurrentTab(tab); attachTabToContentView(tab); - resetTitle(); + resetTitleIconAndProgress(); + updateLockIconToLatest(); return true; } @@ -1774,6 +1774,11 @@ public class BrowserActivity extends Activity ViewGroup.LayoutParams.WRAP_CONTENT)); } + if (t == mTabControl.getCurrentTab()) { + setLockIconType(t.getLockIconType()); + setPrevLockType(t.getPrevLockIconType()); + } + WebView view = t.getWebView(); view.setEmbeddedTitleBar(mTitleBar); // Attach the sub window if necessary @@ -1811,6 +1816,11 @@ public class BrowserActivity extends Activity if (t.getSubWebView() != null) { mContentView.removeView(t.getSubWebViewContainer()); } + + if (t == mTabControl.getCurrentTab()) { + t.setLockIconType(getLockIconType()); + t.setPrevLockIconType(getPrevLockType()); + } } // Remove the sub window if it exists. Also called by TabControl when the @@ -1850,10 +1860,10 @@ public class BrowserActivity extends Activity if (currentTab != null) { removeTabFromContentView(currentTab); } - attachTabToContentView(tab); // We must set the new tab as the current tab to reflect the old // animation behavior. mTabControl.setCurrentTab(tab); + attachTabToContentView(tab); if (!urlData.isEmpty()) { urlData.loadIn(webview); } @@ -1920,15 +1930,6 @@ public class BrowserActivity extends Activity } /** - * Resets the browser title-view to whatever it must be (for example, if we - * load a page from history). - */ - private void resetTitle() { - resetLockIcon(); - resetTitleIconAndProgress(); - } - - /** * Resets the browser title-view to whatever it must be * (for example, if we had a loading error) * When we have a new page, we call resetTitle, when we @@ -3451,23 +3452,20 @@ public class BrowserActivity extends Activity updateLockIconImage(LOCK_ICON_UNSECURE); } - /** - * Resets the lock icon. This method is called when the icon needs to be - * reset but we do not know whether we are loading a secure or not secure - * page. - */ - private void resetLockIcon() { - // Save the lock-icon state (we revert to it if the load gets cancelled) - saveLockIcon(); + /* package */ void setLockIconType(int type) { + mLockIconType = type; + } - mLockIconType = LOCK_ICON_UNSECURE; + /* package */ int getLockIconType() { + return mLockIconType; + } - if (LOGV_ENABLED) { - Log.v(LOGTAG, "BrowserActivity.resetLockIcon:" + - " reset lock icon to " + mLockIconType); - } + /* package */ void setPrevLockType(int type) { + mPrevLockType = type; + } - updateLockIconImage(LOCK_ICON_UNSECURE); + /* package */ int getPrevLockType() { + return mPrevLockType; } /** @@ -4173,9 +4171,9 @@ public class BrowserActivity extends Activity } - private final static int LOCK_ICON_UNSECURE = 0; - private final static int LOCK_ICON_SECURE = 1; - private final static int LOCK_ICON_MIXED = 2; + final static int LOCK_ICON_UNSECURE = 0; + final static int LOCK_ICON_SECURE = 1; + final static int LOCK_ICON_MIXED = 2; private int mLockIconType = LOCK_ICON_UNSECURE; private int mPrevLockType = LOCK_ICON_UNSECURE; diff --git a/src/com/android/browser/TabControl.java b/src/com/android/browser/TabControl.java index 037a757..4089cac 100644 --- a/src/com/android/browser/TabControl.java +++ b/src/com/android/browser/TabControl.java @@ -210,12 +210,17 @@ class TabControl { private String mOriginalUrl; private ErrorConsoleView mErrorConsole; + // the lock icon type and previous lock icon type for the tab + private int mSavedLockIconType; + private int mSavedPrevLockIconType; // Construct a new tab private Tab(WebView w, boolean closeOnExit, String appId, String url, Context context) { mCloseOnExit = closeOnExit; mAppId = appId; mOriginalUrl = url; + mSavedLockIconType = BrowserActivity.LOCK_ICON_UNSECURE; + mSavedPrevLockIconType = BrowserActivity.LOCK_ICON_UNSECURE; // The tab consists of a container view, which contains the main // WebView, as well as any other UI elements associated with the tab. @@ -413,6 +418,22 @@ class TabControl { mPickerData.mFakeWebView.invalidate(); } } + + void setLockIconType(int type) { + mSavedLockIconType = type; + } + + int getLockIconType() { + return mSavedLockIconType; + } + + void setPrevLockIconType(int type) { + mSavedPrevLockIconType = type; + } + + int getPrevLockIconType() { + return mSavedPrevLockIconType; + } }; // Directory to store thumbnails for each WebView. -- 2.11.0