diff --git a/mobile/android/base/BrowserApp.java b/mobile/android/base/BrowserApp.java index abd04d4ff7d..17ff376d283 100644 --- a/mobile/android/base/BrowserApp.java +++ b/mobile/android/base/BrowserApp.java @@ -735,7 +735,7 @@ abstract public class BrowserApp extends GeckoApp public View getActionBarLayout() { int actionBarRes; - if (!hasPermanentMenuKey() || HardwareUtils.isTablet()) + if (!HardwareUtils.hasMenuButton() || HardwareUtils.isTablet()) actionBarRes = R.layout.browser_toolbar_menu; else actionBarRes = R.layout.browser_toolbar; diff --git a/mobile/android/base/BrowserToolbar.java b/mobile/android/base/BrowserToolbar.java index b81a597873a..879ad22df8f 100644 --- a/mobile/android/base/BrowserToolbar.java +++ b/mobile/android/base/BrowserToolbar.java @@ -353,7 +353,7 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, mMenu = (GeckoImageButton) mLayout.findViewById(R.id.menu); mActionItemBar = (LinearLayout) mLayout.findViewById(R.id.menu_items); - mHasSoftMenuButton = !mActivity.hasPermanentMenuKey(); + mHasSoftMenuButton = !HardwareUtils.hasMenuButton(); if (mHasSoftMenuButton) { mMenu.setVisibility(View.VISIBLE); diff --git a/mobile/android/base/GeckoApp.java b/mobile/android/base/GeckoApp.java index 49f2f6b1d33..5156e5cb1ea 100644 --- a/mobile/android/base/GeckoApp.java +++ b/mobile/android/base/GeckoApp.java @@ -17,6 +17,7 @@ import org.mozilla.gecko.updater.UpdateService; import org.mozilla.gecko.updater.UpdateServiceHelper; import org.mozilla.gecko.util.GeckoEventListener; import org.mozilla.gecko.util.GeckoEventResponder; +import org.mozilla.gecko.util.HardwareUtils; import org.mozilla.gecko.util.ThreadUtils; import org.mozilla.gecko.util.UiAsyncTask; @@ -473,7 +474,7 @@ abstract public class GeckoApp @Override public void showMenu(View menu) { // Hide the menu only if we are showing the MenuPopup. - if (!hasPermanentMenuKey()) + if (!HardwareUtils.hasMenuButton()) closeMenu(); mMenuPanel.removeAllViews(); @@ -718,18 +719,6 @@ abstract public class GeckoApp public boolean areTabsShown() { return false; } - public boolean hasPermanentMenuKey() { - boolean hasMenu = true; - - if (Build.VERSION.SDK_INT >= 11) - hasMenu = false; - - if (Build.VERSION.SDK_INT >= 14) - hasMenu = ViewConfiguration.get(GeckoApp.mAppContext).hasPermanentMenuKey(); - - return hasMenu; - } - @Override public void handleMessage(String event, JSONObject message) { try { diff --git a/mobile/android/base/util/HardwareUtils.java b/mobile/android/base/util/HardwareUtils.java index 16bebe6b6e8..4c47843d029 100644 --- a/mobile/android/base/util/HardwareUtils.java +++ b/mobile/android/base/util/HardwareUtils.java @@ -10,6 +10,7 @@ import android.content.pm.PackageManager; import android.content.res.Configuration; import android.os.Build; import android.util.Log; +import android.view.ViewConfiguration; public final class HardwareUtils { private static final String LOGTAG = "GeckoHardwareUtils"; @@ -19,6 +20,7 @@ public final class HardwareUtils { private static Boolean sIsLargeTablet; private static Boolean sIsSmallTablet; private static Boolean sIsTelevision; + private static Boolean sHasMenuButton; private HardwareUtils() { } @@ -58,4 +60,17 @@ public final class HardwareUtils { } return sIsTelevision; } + + public static boolean hasMenuButton() { + if (sHasMenuButton == null) { + sHasMenuButton = Boolean.TRUE; + if (Build.VERSION.SDK_INT >= 11) { + sHasMenuButton = Boolean.FALSE; + } + if (Build.VERSION.SDK_INT >= 14) { + sHasMenuButton = ViewConfiguration.get(sContext).hasPermanentMenuKey(); + } + } + return sHasMenuButton; + } }