summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-11-27 21:46:22 +0100
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-12-04 23:04:28 +0100
commitdaa20c9a7f602828927a5f8833bdaf54185f160e (patch)
tree43cc1e137c972c33da24b6abe2e0fa2cdcca2020
parentdbd72b9eb833a0e116a31125186b002da4b725b4 (diff)
android: introduce getDisplayMetrics - reduce code duplication
Change-Id: Ic020d9604814213e13c339b07b6e74de77a9f400
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java9
-rw-r--r--android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java9
2 files changed, 12 insertions, 6 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
index 7161f1465242..888e5884a096 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
@@ -45,4 +45,13 @@ public class LOKitShell {
}
});
}
+
+ public static DisplayMetrics getDisplayMetrics() {
+ if (LibreOfficeMainActivity.mAppContext == null) {
+ return null;
+ }
+ DisplayMetrics metrics = new DisplayMetrics();
+ LibreOfficeMainActivity.mAppContext.getWindowManager().getDefaultDisplay().getMetrics(metrics);
+ return metrics;
+ }
}
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
index 9b7dd39684c7..b5bb73d1985d 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
@@ -145,8 +145,7 @@ public class GeckoLayerClient implements LayerView.Listener {
/* Informs Gecko that the screen size has changed. */
private void sendResizeEventIfNecessary(boolean force) {
- DisplayMetrics metrics = new DisplayMetrics();
- LibreOfficeMainActivity.mAppContext.getWindowManager().getDefaultDisplay().getMetrics(metrics);
+ DisplayMetrics metrics = LOKitShell.getDisplayMetrics();
IntSize newScreenSize = new IntSize(metrics.widthPixels, metrics.heightPixels);
@@ -159,11 +158,9 @@ public class GeckoLayerClient implements LayerView.Listener {
return;
}
- mScreenSize = newScreenSize;
+ Log.d(LOGTAG, "Screen-size changed to " + mScreenSize + " - > " + newScreenSize);
- if (screenSizeChanged) {
- Log.d(LOGTAG, "Screen-size changed to " + mScreenSize);
- }
+ mScreenSize = newScreenSize;
LOEvent event = LOEventFactory.sizeChanged(metrics.widthPixels, metrics.heightPixels);
LOKitShell.sendEvent(event);