зеркало из https://github.com/mozilla/pjs.git
Bug 602322 - Implement GetDPI on Android. r=mwu, a=blocking-fennec
This commit is contained in:
Родитель
87a42bc406
Коммит
e42c7c84ee
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -93,6 +93,7 @@ public:
|
|||
NS_IMETHOD ConfigureChildren(const nsTArray<nsIWidget::Configuration>&);
|
||||
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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче