Bug 708772 - (1/3) Add IsTablet method to AndroidBridge [r=dougt]

This commit is contained in:
Matt Brubeck 2011-12-14 13:53:38 -08:00
parent 6d41c00c3d
commit 5868041d51
3 changed files with 23 additions and 0 deletions

View File

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

View File

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

View File

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