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() {
int actionBarRes;
if (!hasPermanentMenuKey() || HardwareUtils.isTablet())
if (!HardwareUtils.hasMenuButton() || HardwareUtils.isTablet())
actionBarRes = R.layout.browser_toolbar_menu;
else
actionBarRes = R.layout.browser_toolbar;

View File

@ -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);

View File

@ -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 {

View File

@ -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;
}
}