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

Unified Diff: ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java

Issue 212933012: Use Display instead of DisplayMetrics to find out the Display size. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java
diff --git a/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java b/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java
index 863fa1b5e16d41c2a6fbbceb807823ed8af87af8..c154ea0b224ae684f7b41cd07bd2beae317199bd 100644
--- a/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java
+++ b/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java
@@ -31,6 +31,7 @@ public class DeviceDisplayInfo {
private final Context mAppContext;
private final WindowManager mWinManager;
private Point mTempPoint = new Point();
+ private DisplayMetrics mTempMetrics = new DisplayMetrics();
private DeviceDisplayInfo(Context context) {
mAppContext = context.getApplicationContext();
@@ -42,7 +43,8 @@ public class DeviceDisplayInfo {
*/
@CalledByNative
public int getDisplayHeight() {
- return getMetrics().heightPixels;
+ getDisplay().getSize(mTempPoint);
+ return mTempPoint.y;
}
/**
@@ -50,7 +52,8 @@ public class DeviceDisplayInfo {
*/
@CalledByNative
public int getDisplayWidth() {
- return getMetrics().widthPixels;
+ getDisplay().getSize(mTempPoint);
+ return mTempPoint.x;
}
/**
@@ -140,7 +143,8 @@ public class DeviceDisplayInfo {
*/
@CalledByNative
public double getDIPScale() {
- return getMetrics().density;
+ getDisplay().getMetrics(mTempMetrics);
+ return mTempMetrics.density;
}
/**
@@ -178,10 +182,6 @@ public class DeviceDisplayInfo {
return mWinManager.getDefaultDisplay();
}
- private DisplayMetrics getMetrics() {
- return mAppContext.getResources().getDisplayMetrics();
- }
-
/**
* Creates DeviceDisplayInfo for a given Context.
*
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698