Bug 856756 - Move GeckoApp.hasPermanentMenuKey to HardwareUtils.hasMenuButton. r=mfinkle

This commit is contained in:
Kartikaya Gupta 2013-04-02 10:04:21 -04:00
parent 39eae0eca8
commit 50f56e6cb7
4 changed files with 19 additions and 15 deletions

View File

@ -735,7 +735,7 @@ abstract public class BrowserApp extends GeckoApp
public View getActionBarLayout() { public View getActionBarLayout() {
int actionBarRes; int actionBarRes;
if (!hasPermanentMenuKey() || HardwareUtils.isTablet()) if (!HardwareUtils.hasMenuButton() || HardwareUtils.isTablet())
actionBarRes = R.layout.browser_toolbar_menu; actionBarRes = R.layout.browser_toolbar_menu;
else else
actionBarRes = R.layout.browser_toolbar; actionBarRes = R.layout.browser_toolbar;

View File

@ -353,7 +353,7 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory,
mMenu = (GeckoImageButton) mLayout.findViewById(R.id.menu); mMenu = (GeckoImageButton) mLayout.findViewById(R.id.menu);
mActionItemBar = (LinearLayout) mLayout.findViewById(R.id.menu_items); mActionItemBar = (LinearLayout) mLayout.findViewById(R.id.menu_items);
mHasSoftMenuButton = !mActivity.hasPermanentMenuKey(); mHasSoftMenuButton = !HardwareUtils.hasMenuButton();
if (mHasSoftMenuButton) { if (mHasSoftMenuButton) {
mMenu.setVisibility(View.VISIBLE); mMenu.setVisibility(View.VISIBLE);

View File

@ -17,6 +17,7 @@ import org.mozilla.gecko.updater.UpdateService;
import org.mozilla.gecko.updater.UpdateServiceHelper; import org.mozilla.gecko.updater.UpdateServiceHelper;
import org.mozilla.gecko.util.GeckoEventListener; import org.mozilla.gecko.util.GeckoEventListener;
import org.mozilla.gecko.util.GeckoEventResponder; import org.mozilla.gecko.util.GeckoEventResponder;
import org.mozilla.gecko.util.HardwareUtils;
import org.mozilla.gecko.util.ThreadUtils; import org.mozilla.gecko.util.ThreadUtils;
import org.mozilla.gecko.util.UiAsyncTask; import org.mozilla.gecko.util.UiAsyncTask;
@ -473,7 +474,7 @@ abstract public class GeckoApp
@Override @Override
public void showMenu(View menu) { public void showMenu(View menu) {
// Hide the menu only if we are showing the MenuPopup. // Hide the menu only if we are showing the MenuPopup.
if (!hasPermanentMenuKey()) if (!HardwareUtils.hasMenuButton())
closeMenu(); closeMenu();
mMenuPanel.removeAllViews(); mMenuPanel.removeAllViews();
@ -718,18 +719,6 @@ abstract public class GeckoApp
public boolean areTabsShown() { return false; } 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 @Override
public void handleMessage(String event, JSONObject message) { public void handleMessage(String event, JSONObject message) {
try { try {

View File

@ -10,6 +10,7 @@ import android.content.pm.PackageManager;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Build; import android.os.Build;
import android.util.Log; import android.util.Log;
import android.view.ViewConfiguration;
public final class HardwareUtils { public final class HardwareUtils {
private static final String LOGTAG = "GeckoHardwareUtils"; private static final String LOGTAG = "GeckoHardwareUtils";
@ -19,6 +20,7 @@ public final class HardwareUtils {
private static Boolean sIsLargeTablet; private static Boolean sIsLargeTablet;
private static Boolean sIsSmallTablet; private static Boolean sIsSmallTablet;
private static Boolean sIsTelevision; private static Boolean sIsTelevision;
private static Boolean sHasMenuButton;
private HardwareUtils() { private HardwareUtils() {
} }
@ -58,4 +60,17 @@ public final class HardwareUtils {
} }
return sIsTelevision; 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;
}
} }