diff options
| author | Dianne Hackborn <hackbod@google.com> | 2011-05-26 00:55:58 -0700 |
|---|---|---|
| committer | Dianne Hackborn <hackbod@google.com> | 2011-05-26 10:46:19 -0700 |
| commit | 81e56d535c853d73ff537357da5b935f51cb779d (patch) | |
| tree | b0d69765bbefecbdeeadebc24b7e57f902af84b9 /core/java/android/view/Display.java | |
| parent | 42f8094c066209a65b09d53611ef5c93daba4c51 (diff) | |
Rework how we decide whether to use system or status bar.
The PhoneWindowManager is now responsible for determing this,
since it needs to do this before we can generate the configuration
since we need to take into account the system bar size we will use.
Also the Display should now report the screen height without
including the system bar.
Change-Id: I82dfcc5e327e4d13d82c373c6c870f557a99b757
Diffstat (limited to 'core/java/android/view/Display.java')
| -rw-r--r-- | core/java/android/view/Display.java | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java index b5d36d9ae92f..80325463545f 100644 --- a/core/java/android/view/Display.java +++ b/core/java/android/view/Display.java @@ -80,25 +80,37 @@ public class Display { * adjusted for you based on the current rotation of the display. */ public void getSize(Point outSize) { + getSizeInternal(outSize, true); + } + + /** + * Returns the raw size of the display, in pixels. Note that this + * should <em>not</em> generally be used for computing layouts, since + * a device will typically have screen decoration (such as a status bar) + * along the edges of the display that reduce the amount of application + * space available from the raw size returned here. This value is + * adjusted for you based on the current rotation of the display. + */ + private void getSizeInternal(Point outSize, boolean doCompat) { try { IWindowManager wm = getWindowManager(); if (wm != null) { wm.getDisplaySize(outSize); + if (doCompat && mCompatibilityInfo != null) { + synchronized (mTmpMetrics) { + mTmpMetrics.unscaledWidthPixels = outSize.x; + mTmpMetrics.unscaledHeightPixels = outSize.y; + mTmpMetrics.density = mDensity; + mCompatibilityInfo.applyToDisplayMetrics(mTmpMetrics); + outSize.x = mTmpMetrics.widthPixels; + outSize.y = mTmpMetrics.heightPixels; + } + } } else { // This is just for boot-strapping, initializing the // system process before the window manager is up. outSize.y = getRealHeight(); } - if (mCompatibilityInfo != null) { - synchronized (mTmpMetrics) { - mTmpMetrics.realWidthPixels = outSize.x; - mTmpMetrics.realHeightPixels = outSize.y; - mTmpMetrics.density = mDensity; - mCompatibilityInfo.applyToDisplayMetrics(mTmpMetrics); - outSize.x = mTmpMetrics.widthPixels; - outSize.y = mTmpMetrics.heightPixels; - } - } } catch (RemoteException e) { Slog.w("Display", "Unable to get display size", e); } @@ -109,7 +121,7 @@ public class Display { */ public void getRectSize(Rect outSize) { synchronized (mTmpPoint) { - getSize(mTmpPoint); + getSizeInternal(mTmpPoint, true); outSize.set(0, 0, mTmpPoint.x, mTmpPoint.y); } } @@ -137,7 +149,7 @@ public class Display { synchronized (mTmpPoint) { long now = SystemClock.uptimeMillis(); if (now > (mLastGetTime+20)) { - getSize(mTmpPoint); + getSizeInternal(mTmpPoint, true); mLastGetTime = now; } return mTmpPoint.x; @@ -152,7 +164,7 @@ public class Display { synchronized (mTmpPoint) { long now = SystemClock.uptimeMillis(); if (now > (mLastGetTime+20)) { - getSize(mTmpPoint); + getSizeInternal(mTmpPoint, true); mLastGetTime = now; } return mTmpPoint.y; @@ -218,7 +230,7 @@ public class Display { */ public void getMetrics(DisplayMetrics outMetrics) { synchronized (mTmpPoint) { - getSize(mTmpPoint); + getSizeInternal(mTmpPoint, false); outMetrics.widthPixels = mTmpPoint.x; outMetrics.heightPixels = mTmpPoint.y; } @@ -248,8 +260,8 @@ public class Display { outMetrics.xdpi = mDpiX; outMetrics.ydpi = mDpiY; - outMetrics.realWidthPixels = outMetrics.widthPixels; - outMetrics.realHeightPixels = outMetrics.heightPixels; + outMetrics.unscaledWidthPixels = outMetrics.widthPixels; + outMetrics.unscaledHeightPixels = outMetrics.heightPixels; } static IWindowManager getWindowManager() { |
