diff --git a/mobile/android/base/BrowserApp.java b/mobile/android/base/BrowserApp.java index 47814861d4f..c6be146ff1c 100644 --- a/mobile/android/base/BrowserApp.java +++ b/mobile/android/base/BrowserApp.java @@ -27,7 +27,6 @@ import org.mozilla.gecko.preferences.GeckoPreferences; import org.mozilla.gecko.prompts.Prompt; import org.mozilla.gecko.toolbar.AutocompleteHandler; import org.mozilla.gecko.toolbar.BrowserToolbar; -import org.mozilla.gecko.toolbar.SiteIdentityPopup; import org.mozilla.gecko.util.Clipboard; import org.mozilla.gecko.util.GamepadUtils; import org.mozilla.gecko.util.HardwareUtils; @@ -188,15 +187,6 @@ abstract public class BrowserApp extends GeckoApp // race by determining if the web content should be hidden at the animation's end. private boolean mHideWebContentOnAnimationEnd = false; - private SiteIdentityPopup mSiteIdentityPopup; - - public SiteIdentityPopup getSiteIdentityPopup() { - if (mSiteIdentityPopup == null) - mSiteIdentityPopup = new SiteIdentityPopup(this); - - return mSiteIdentityPopup; - } - @Override public void onTabChanged(Tab tab, Tabs.TabEvents msg, Object data) { if (tab == null) { @@ -219,9 +209,6 @@ abstract public class BrowserApp extends GeckoApp if (Tabs.getInstance().isSelectedTab(tab)) { updateHomePagerForTab(tab); - if (mSiteIdentityPopup != null) - mSiteIdentityPopup.dismiss(); - final TabsPanel.Panel panel = tab.isPrivate() ? TabsPanel.Panel.PRIVATE_TABS : TabsPanel.Panel.NORMAL_TABS; @@ -618,8 +605,7 @@ abstract public class BrowserApp extends GeckoApp return; } - if (mSiteIdentityPopup != null && mSiteIdentityPopup.isShowing()) { - mSiteIdentityPopup.dismiss(); + if (mBrowserToolbar.onBackPressed()) { return; } @@ -1048,9 +1034,7 @@ abstract public class BrowserApp extends GeckoApp invalidateOptionsMenu(); updateSideBarState(); mTabsPanel.refresh(); - if (mSiteIdentityPopup != null) { - mSiteIdentityPopup.dismiss(); - } + mBrowserToolbar.refresh(); } @Override diff --git a/mobile/android/base/toolbar/BrowserToolbar.java b/mobile/android/base/toolbar/BrowserToolbar.java index 4d60ad0d1e9..4aa890fbcff 100644 --- a/mobile/android/base/toolbar/BrowserToolbar.java +++ b/mobile/android/base/toolbar/BrowserToolbar.java @@ -141,6 +141,8 @@ public class BrowserToolbar extends GeckoRelativeLayout private OnStartEditingListener mStartEditingListener; private OnStopEditingListener mStopEditingListener; + private SiteIdentityPopup mSiteIdentityPopup; + final private BrowserApp mActivity; private boolean mHasSoftMenuButton; @@ -295,7 +297,9 @@ public class BrowserToolbar extends GeckoRelativeLayout mSiteSecurity = (ImageButton) findViewById(R.id.site_security); mSiteSecurityVisible = (mSiteSecurity.getVisibility() == View.VISIBLE); - mActivity.getSiteIdentityPopup().setAnchor(mSiteSecurity); + + mSiteIdentityPopup = new SiteIdentityPopup(mActivity); + mSiteIdentityPopup.setAnchor(mSiteSecurity); mProgressSpinner = AnimationUtils.loadAnimation(mActivity, R.anim.progress_spinner); @@ -429,9 +433,9 @@ public class BrowserToolbar extends GeckoRelativeLayout Log.e(LOGTAG, "Selected tab has no identity data"); return; } - SiteIdentityPopup siteIdentityPopup = mActivity.getSiteIdentityPopup(); - siteIdentityPopup.updateIdentity(identityData); - siteIdentityPopup.show(); + + mSiteIdentityPopup.updateIdentity(identityData); + mSiteIdentityPopup.show(); } }; @@ -481,6 +485,14 @@ public class BrowserToolbar extends GeckoRelativeLayout } } + public void refresh() { + dismissSiteIdentityPopup(); + } + + public boolean onBackPressed() { + return dismissSiteIdentityPopup(); + } + public boolean onKey(int keyCode, KeyEvent event) { if (event.getAction() != KeyEvent.ACTION_DOWN) { return false; @@ -557,6 +569,7 @@ public class BrowserToolbar extends GeckoRelativeLayout case RESTORED: // TabCount fixup after OOM case SELECTED: + dismissSiteIdentityPopup(); updateTabCount(tabs.getDisplayCount()); mSwitchingTabs = true; // Fall through. @@ -593,7 +606,7 @@ public class BrowserToolbar extends GeckoRelativeLayout case LOCATION_CHANGE: // A successful location change will cause Tab to notify // us of a title change, so we don't update the title here. - refresh(); + refreshState(); break; case CLOSED: @@ -668,6 +681,15 @@ public class BrowserToolbar extends GeckoRelativeLayout } } + private boolean dismissSiteIdentityPopup() { + if (mSiteIdentityPopup != null && mSiteIdentityPopup.isShowing()) { + mSiteIdentityPopup.dismiss(); + return true; + } + + return false; + } + private int getUrlBarEntryTranslation() { return getWidth() - mUrlBarEntry.getRight(); } @@ -1533,7 +1555,7 @@ public class BrowserToolbar extends GeckoRelativeLayout setVisibility(View.GONE); } - private void refresh() { + private void refreshState() { Tab tab = Tabs.getInstance().getSelectedTab(); if (tab != null) { setFavicon(tab.getFavicon());