diff --git a/embedding/android/GeckoAppShell.java b/embedding/android/GeckoAppShell.java index 72b5716ac7a6..6ba4bf9ece72 100644 --- a/embedding/android/GeckoAppShell.java +++ b/embedding/android/GeckoAppShell.java @@ -549,4 +549,9 @@ class GeckoAppShell notificationManager.cancel(notificationID); } + public static int getDpi() { + DisplayMetrics metrics = new DisplayMetrics(); + GeckoApp.mAppContext.getWindowManager().getDefaultDisplay().getMetrics(metrics); + return metrics.densityDpi; + } } diff --git a/widget/src/android/AndroidBridge.cpp b/widget/src/android/AndroidBridge.cpp index c868e32960d1..3baad7501f5a 100644 --- a/widget/src/android/AndroidBridge.cpp +++ b/widget/src/android/AndroidBridge.cpp @@ -113,6 +113,7 @@ AndroidBridge::Init(JNIEnv *jEnv, jSetClipboardText = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "setClipboardText", "(Ljava/lang/String;)V"); jShowAlertNotification = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "showAlertNotification", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); jAlertsProgressListener_OnProgress = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "alertsProgressListener_OnProgress", "(Ljava/lang/String;JJLjava/lang/String;)V"); + jGetDpi = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getDpi", "()I"); jEGLContextClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("javax/microedition/khronos/egl/EGLContext")); @@ -477,6 +478,12 @@ AndroidBridge::AlertsProgressListener_OnProgress(const nsAString& aAlertName, jstrName, aProgress, aProgressMax, jstrText); } +int +AndroidBridge::GetDPI() +{ + return (int) mJNIEnv->CallStaticIntMethod(mGeckoAppShellClass, jGetDpi); +} + void AndroidBridge::SetSurfaceView(jobject obj) { diff --git a/widget/src/android/AndroidBridge.h b/widget/src/android/AndroidBridge.h index c28e6c1b9cf6..49bf3de24863 100644 --- a/widget/src/android/AndroidBridge.h +++ b/widget/src/android/AndroidBridge.h @@ -158,6 +158,8 @@ public: PRInt64 aProgressMax, const nsAString& aAlertText); + int GetDPI(); + struct AutoLocalJNIFrame { AutoLocalJNIFrame(int nEntries = 128) : mEntries(nEntries) { AndroidBridge::Bridge()->JNI()->PushLocalFrame(mEntries); @@ -219,7 +221,7 @@ protected: jmethodID jSetClipboardText; jmethodID jShowAlertNotification; jmethodID jAlertsProgressListener_OnProgress; - jmethodID jShowFilePicker; + jmethodID jGetDpi; // stuff we need for CallEglCreateWindowSurface jclass jEGLSurfaceImplClass; diff --git a/widget/src/android/nsWindow.cpp b/widget/src/android/nsWindow.cpp index be9831fde2e7..79538d82c0af 100644 --- a/widget/src/android/nsWindow.cpp +++ b/widget/src/android/nsWindow.cpp @@ -270,6 +270,14 @@ nsWindow::GetParent() return mParent; } +float +nsWindow::GetDPI() +{ + if (AndroidBridge::Bridge()) + return AndroidBridge::Bridge()->GetDPI(); + return 160.0f; +} + NS_IMETHODIMP nsWindow::Show(PRBool aState) { diff --git a/widget/src/android/nsWindow.h b/widget/src/android/nsWindow.h index e1ce2e62b8a0..f1e200956bfe 100644 --- a/widget/src/android/nsWindow.h +++ b/widget/src/android/nsWindow.h @@ -93,6 +93,7 @@ public: NS_IMETHOD ConfigureChildren(const nsTArray&); NS_IMETHOD SetParent(nsIWidget* aNewParent); virtual nsIWidget *GetParent(void); + virtual float GetDPI(); NS_IMETHOD Show(PRBool aState); NS_IMETHOD SetModal(PRBool aModal); NS_IMETHOD IsVisible(PRBool & aState);