Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(936)

Unified Diff: ui/android/java/src/org/chromium/ui/base/WindowAndroid.java

Issue 2300463002: Add observers for DIP scale change. (Closed)
Patch Set: An attempt to fix tests compilation Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/android/java/src/org/chromium/ui/base/WindowAndroid.java
diff --git a/ui/android/java/src/org/chromium/ui/base/WindowAndroid.java b/ui/android/java/src/org/chromium/ui/base/WindowAndroid.java
index dabb468983aa8e19a23b3e5ce859786048a0485c..0b2d48488b8d377ab564c5fc5de453675de9c0dc 100644
--- a/ui/android/java/src/org/chromium/ui/base/WindowAndroid.java
+++ b/ui/android/java/src/org/chromium/ui/base/WindowAndroid.java
@@ -71,6 +71,7 @@ public class WindowAndroid {
// Native pointer to the c++ WindowAndroid object.
private long mNativeWindowAndroid = 0;
private final VSyncMonitor mVSyncMonitor;
+ private final DIPScaleMonitor mDIPScaleMonitor;
// A string used as a key to store intent errors in a bundle
static final String WINDOW_CALLBACK_ERRORS = "window_callback_errors";
@@ -173,6 +174,7 @@ public class WindowAndroid {
mOutstandingIntents = new SparseArray<IntentCallback>();
mIntentErrors = new HashMap<Integer, String>();
mVSyncMonitor = new VSyncMonitor(context, mVSyncListener);
+ mDIPScaleMonitor = new DIPScaleMonitor(this);
mAccessibilityManager = (AccessibilityManager) mApplicationContext.getSystemService(
Context.ACCESSIBILITY_SERVICE);
}
@@ -514,6 +516,8 @@ public class WindowAndroid {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if (mTouchExplorationMonitor != null) mTouchExplorationMonitor.destroy();
}
+
+ mDIPScaleMonitor.onDestroy();
}
/**
@@ -642,6 +646,23 @@ public class WindowAndroid {
});
}
+ // Device scale factor related methods.
+
+ /**
+ * Returns current device scale factor, aka DIP scale or display density.
+ */
+ public float getDIPScale() {
+ return mDIPScaleMonitor.getDIPScale();
+ }
+
+ public void addDIPScaleListener(DIPScaleListener listener) {
+ mDIPScaleMonitor.addObserver(listener);
+ }
+
+ public void removeDIPScaleListener(DIPScaleListener listener) {
+ mDIPScaleMonitor.removeObserver(listener);
+ }
+
/**
* Getter for the current context (not necessarily the application context).
* Make no assumptions regarding what type of Context is returned here, it could be for example

Powered by Google App Engine
This is Rietveld 408576698