diff --git a/mobile/android/base/BrowserToolbar.java b/mobile/android/base/BrowserToolbar.java index 002379f1ba5..d09a3269556 100644 --- a/mobile/android/base/BrowserToolbar.java +++ b/mobile/android/base/BrowserToolbar.java @@ -417,29 +417,8 @@ public class BrowserToolbar implements Tabs.OnTabsChangedListener, } if (Build.VERSION.SDK_INT >= 11) { - View panel = mActivity.getMenuPanel(); - - // If panel is null, the app is starting up for the first time; - // add this to the popup only if we have a soft menu button. - // else, browser-toolbar is initialized on rotation, - // and we need to re-attach action-bar items. - - if (panel == null) { - mActivity.onCreatePanelMenu(Window.FEATURE_OPTIONS_PANEL, null); - panel = mActivity.getMenuPanel(); - - if (mHasSoftMenuButton) { - mMenuPopup = new MenuPopup(mActivity); - mMenuPopup.setPanelView(panel); - - mMenuPopup.setOnDismissListener(new PopupWindow.OnDismissListener() { - @Override - public void onDismiss() { - mActivity.onOptionsMenuClosed(null); - } - }); - } - } + // Create the panel and inflate the custom menu. + mActivity.onCreatePanelMenu(Window.FEATURE_OPTIONS_PANEL, null); } mFocusOrder = Arrays.asList(mBack, mForward, mLayout, mReader, mSiteSecurity, mStop, mTabs); @@ -1167,8 +1146,22 @@ public class BrowserToolbar implements Tabs.OnTabsChangedListener, if (!mHasSoftMenuButton) return false; + // Initialize the popup. + if (mMenuPopup == null) { + View panel = mActivity.getMenuPanel(); + mMenuPopup = new MenuPopup(mActivity); + mMenuPopup.setPanelView(panel); + + mMenuPopup.setOnDismissListener(new PopupWindow.OnDismissListener() { + @Override + public void onDismiss() { + mActivity.onOptionsMenuClosed(null); + } + }); + } + GeckoAppShell.getGeckoInterface().invalidateOptionsMenu(); - if (mMenuPopup != null && !mMenuPopup.isShowing()) + if (!mMenuPopup.isShowing()) mMenuPopup.showAsDropDown(mMenu); return true; @@ -1178,7 +1171,7 @@ public class BrowserToolbar implements Tabs.OnTabsChangedListener, if (!mHasSoftMenuButton) return false; - if (mMenuPopup != null && mMenuPopup.isShowing()) + if (mMenuPopup.isShowing()) mMenuPopup.dismiss(); return true;