From 24aec25c9aafe2e2a2dfaa78436b1c9e0f31afe4 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Wed, 14 Dec 2011 13:53:38 -0800 Subject: [PATCH] Bug 708772 - (1/3) Add IsTablet method to AndroidBridge [r=dougt] --- embedding/android/GeckoAppShell.java | 13 +++++++++++++ widget/src/android/AndroidBridge.cpp | 7 +++++++ widget/src/android/AndroidBridge.h | 3 +++ 3 files changed, 23 insertions(+) diff --git a/embedding/android/GeckoAppShell.java b/embedding/android/GeckoAppShell.java index f93417f380ef..c4ad46642272 100644 --- a/embedding/android/GeckoAppShell.java +++ b/embedding/android/GeckoAppShell.java @@ -1695,4 +1695,17 @@ public class GeckoAppShell public static void sendMessage(String aNumber, String aMessage) { GeckoSmsManager.send(aNumber, aMessage); } + + public static boolean isTablet() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { + Configuration config = GeckoApp.mAppContext.getResources().getConfiguration(); + // xlarge is defined by android as screens larger than 960dp x 720dp + // and should include most devices ~7in and up. + // http://developer.android.com/guide/practices/screens_support.html + if ((config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE) { + return true; + } + } + return false; + } } diff --git a/widget/src/android/AndroidBridge.cpp b/widget/src/android/AndroidBridge.cpp index 5ba5b1b2a280..7cfba5438a1f 100644 --- a/widget/src/android/AndroidBridge.cpp +++ b/widget/src/android/AndroidBridge.cpp @@ -156,6 +156,7 @@ AndroidBridge::Init(JNIEnv *jEnv, jPostToJavaThread = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "postToJavaThread", "(Z)V"); jInitCamera = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "initCamera", "(Ljava/lang/String;III)[I"); jCloseCamera = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "closeCamera", "()V"); + jIsTablet = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "isTablet", "()Z"); jEnableBatteryNotifications = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "enableBatteryNotifications", "()V"); jDisableBatteryNotifications = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "disableBatteryNotifications", "()V"); jGetCurrentBatteryInformation = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getCurrentBatteryInformation", "()[D"); @@ -1463,6 +1464,12 @@ AndroidBridge::UnlockWindow(void* window) return true; } +bool +AndroidBridge::IsTablet() +{ + return mJNIEnv->CallStaticBooleanMethod(mGeckoAppShellClass, jIsTablet); +} + /* Implementation file */ NS_IMPL_ISUPPORTS1(nsAndroidBridge, nsIAndroidBridge) diff --git a/widget/src/android/AndroidBridge.h b/widget/src/android/AndroidBridge.h index 278358a3f26f..b0c274c0166f 100644 --- a/widget/src/android/AndroidBridge.h +++ b/widget/src/android/AndroidBridge.h @@ -336,6 +336,8 @@ public: PRUint16 GetNumberOfMessagesForText(const nsAString& aText); void SendMessage(const nsAString& aNumber, const nsAString& aText); + bool IsTablet(); + protected: static AndroidBridge *sBridge; @@ -411,6 +413,7 @@ protected: jmethodID jPostToJavaThread; jmethodID jInitCamera; jmethodID jCloseCamera; + jmethodID jIsTablet; jmethodID jEnableBatteryNotifications; jmethodID jDisableBatteryNotifications; jmethodID jGetCurrentBatteryInformation;