Bug 817721/817735/817732 - Add more granular API to query tablet form-factors (r=mfinkle)
authorLucas Rocha <lucasr@mozilla.com>
Fri, 22 Feb 2013 07:22:37 +0000
changeset 122619 5ab1d763ff1c3ba3bb0b1160d864ff7579853edc
parent 122618 3f0f2ba1521c13b825ff0a9525d83395f22d6099
child 122620 ff74c059d79f3b63c479ffc18fd4207161326699
push id24349
push userryanvm@gmail.com
push dateFri, 22 Feb 2013 17:43:12 +0000
treeherdermozilla-central@e36f42046452 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs817721, 817735, 817732
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 817721/817735/817732 - Add more granular API to query tablet form-factors (r=mfinkle)
mobile/android/base/GeckoApp.java
mobile/android/base/GeckoAppShell.java
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -182,16 +182,19 @@ abstract public class GeckoApp
 
     protected int mRestoreMode = RESTORE_NONE;
     protected boolean mInitialized = false;
     private Telemetry.Timer mJavaUiStartupTimer;
     private Telemetry.Timer mGeckoReadyStartupTimer;
 
     private String mPrivateBrowsingSession;
 
+    private static Boolean sIsLargeTablet = null;
+    private static Boolean sIsSmallTablet = null;
+
     abstract public int getLayout();
     abstract public boolean hasTabsSideBar();
     abstract protected String getDefaultProfileName();
 
     void toggleChrome(final boolean aShow) { }
 
     void focusChrome() { }
 
@@ -1441,20 +1444,37 @@ abstract public class GeckoApp
 
                 if (Build.VERSION.SDK_INT >= 11)
                     window.getDecorView().setSystemUiVisibility(fullscreen ? 1 : 0);
             }
         });
     }
 
     public boolean isTablet() {
-        int screenLayout = getResources().getConfiguration().screenLayout;
-        return (Build.VERSION.SDK_INT >= 11 &&
-                (((screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) || 
-                 ((screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE)));
+        return isLargeTablet() || isSmallTablet();
+    }
+
+    public boolean isLargeTablet() {
+        if (sIsLargeTablet == null) {
+            int screenLayout = getResources().getConfiguration().screenLayout;
+            sIsLargeTablet = (Build.VERSION.SDK_INT >= 11 &&
+                              ((screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE));
+        }
+
+        return sIsLargeTablet;
+    }
+
+    public boolean isSmallTablet() {
+        if (sIsSmallTablet == null) {
+            int screenLayout = getResources().getConfiguration().screenLayout;
+            return (Build.VERSION.SDK_INT >= 11 &&
+                    ((screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE));
+        }
+
+        return sIsSmallTablet;
     }
 
     /** Called when the activity is first created. */
     @Override
     public void onCreate(Bundle savedInstanceState)
     {
         GeckoAppShell.registerGlobalExceptionHandler();
 
--- a/mobile/android/base/GeckoAppShell.java
+++ b/mobile/android/base/GeckoAppShell.java
@@ -1959,16 +1959,24 @@ public class GeckoAppShell
 
         SmsManager.getInstance().clearMessageList(aListId);
     }
 
     public static boolean isTablet() {
         return GeckoApp.mAppContext.isTablet();
     }
 
+    public static boolean isLargeTablet() {
+        return GeckoApp.mAppContext.isLargeTablet();
+    }
+
+    public static boolean isSmallTablet() {
+        return GeckoApp.mAppContext.isSmallTablet();
+    }
+
     public static void viewSizeChanged() {
         LayerView v = GeckoApp.mAppContext.getLayerView();
         if (v != null && v.isIMEEnabled()) {
             sendEventToGecko(GeckoEvent.createBroadcastEvent(
                     "ScrollTo:FocusedInput", ""));
         }
     }