diff options
author | Dianne Hackborn <hackbod@google.com> | 2011-04-27 18:52:56 -0400 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2011-05-09 17:03:24 -0700 |
commit | e2515eebf42c763c0a2d9f873a153711778cfc17 (patch) | |
tree | ee159940f05c439d0524771bfbfe6b551c82c2d4 /core/java/android/util | |
parent | 158e3582c03ab9e0221718da20fc8854bb9216d0 (diff) | |
download | frameworks_base-e2515eebf42c763c0a2d9f873a153711778cfc17.zip frameworks_base-e2515eebf42c763c0a2d9f873a153711778cfc17.tar.gz frameworks_base-e2515eebf42c763c0a2d9f873a153711778cfc17.tar.bz2 |
Better compat mode part one: start scaling windows.
First step of improving app screen size compatibility mode. When
running in compat mode, an application's windows are scaled up on
the screen rather than being small with 1:1 pixels.
Currently we scale the application to fill the entire screen, so
don't use an even pixel scaling. Though this may have some
negative impact on the appearance (it looks okay to me), it has a
big benefit of allowing us to now treat these apps as normal
full-screens apps and do the normal transition animations as you
move in and out and around in them.
This introduces fun stuff in the input system to take care of
modifying pointer coordinates to account for the app window
surface scaling. The input dispatcher is told about the scale
that is being applied to each window and, when there is one,
adjusts pointer events appropriately as they are being sent
to the transport.
Also modified is CompatibilityInfo, which has been greatly
simplified to not be so insane and incomprehendible. It is
now simple -- when constructed it determines if the given app
is compatible with the current screen size and density, and
that is that.
There are new APIs on ActivityManagerService to put applications
that we would traditionally consider compatible with larger screens
in compatibility mode. This is the start of a facility to have
a UI affordance for a user to switch apps in and out of
compatibility.
To test switching of modes, there is a new variation of the "am"
command to do this: am screen-compat [on|off] [package]
This mode switching has the fundamentals of restarting activities
when it is changed, though the state still needs to be persisted
and the overall mode switch cleaned up.
For the few small apps I have tested, things mostly seem to be
working well. I know of one problem with the text selection
handles being drawn at the wrong position because at some point
the window offset is being scaled incorrectly. There are
probably other similar issues around the interaction between
two windows because the different window coordinate spaces are
done in a hacky way instead of being formally integrated into
the window manager layout process.
Change-Id: Ie038e3746b448135117bd860859d74e360938557
Diffstat (limited to 'core/java/android/util')
-rw-r--r-- | core/java/android/util/DisplayMetrics.java | 108 |
1 files changed, 10 insertions, 98 deletions
diff --git a/core/java/android/util/DisplayMetrics.java b/core/java/android/util/DisplayMetrics.java index 63baf14..8018ff9 100644 --- a/core/java/android/util/DisplayMetrics.java +++ b/core/java/android/util/DisplayMetrics.java @@ -16,9 +16,7 @@ package android.util; -import android.content.res.CompatibilityInfo; -import android.content.res.Configuration; -import android.os.*; +import android.os.SystemProperties; /** @@ -107,6 +105,11 @@ public class DisplayMetrics { */ public float ydpi; + /** @hide */ + public int realWidthPixels; + /** @hide */ + public int realHeightPixels; + public DisplayMetrics() { } @@ -118,6 +121,8 @@ public class DisplayMetrics { scaledDensity = o.scaledDensity; xdpi = o.xdpi; ydpi = o.ydpi; + realWidthPixels = o.realWidthPixels; + realHeightPixels = o.realHeightPixels; } public void setToDefaults() { @@ -128,101 +133,8 @@ public class DisplayMetrics { scaledDensity = density; xdpi = DENSITY_DEVICE; ydpi = DENSITY_DEVICE; - } - - /** - * Update the display metrics based on the compatibility info and orientation - * NOTE: DO NOT EXPOSE THIS API! It is introducing a circular dependency - * with the higher-level android.res package. - * {@hide} - */ - public void updateMetrics(CompatibilityInfo compatibilityInfo, int orientation, - int screenLayout) { - boolean expandable = compatibilityInfo.isConfiguredExpandable(); - boolean largeScreens = compatibilityInfo.isConfiguredLargeScreens(); - boolean xlargeScreens = compatibilityInfo.isConfiguredXLargeScreens(); - - // Note: this assume that configuration is updated before calling - // updateMetrics method. - if (!expandable) { - if ((screenLayout&Configuration.SCREENLAYOUT_COMPAT_NEEDED) == 0) { - expandable = true; - // the current screen size is compatible with non-resizing apps. - compatibilityInfo.setExpandable(true); - } else { - compatibilityInfo.setExpandable(false); - } - } - if (!largeScreens) { - if ((screenLayout&Configuration.SCREENLAYOUT_SIZE_MASK) - != Configuration.SCREENLAYOUT_SIZE_LARGE) { - largeScreens = true; - // the current screen size is not large. - compatibilityInfo.setLargeScreens(true); - } else { - compatibilityInfo.setLargeScreens(false); - } - } - if (!xlargeScreens) { - if ((screenLayout&Configuration.SCREENLAYOUT_SIZE_MASK) - != Configuration.SCREENLAYOUT_SIZE_XLARGE) { - xlargeScreens = true; - // the current screen size is not large. - compatibilityInfo.setXLargeScreens(true); - } else { - compatibilityInfo.setXLargeScreens(false); - } - } - - if (!expandable || (!largeScreens && !xlargeScreens)) { - // This is a larger screen device and the app is not - // compatible with large screens, so diddle it. - - // Figure out the compatibility width and height of the screen. - int defaultWidth; - int defaultHeight; - switch (orientation) { - case Configuration.ORIENTATION_LANDSCAPE: { - defaultWidth = (int)(CompatibilityInfo.DEFAULT_PORTRAIT_HEIGHT * density + - 0.5f); - defaultHeight = (int)(CompatibilityInfo.DEFAULT_PORTRAIT_WIDTH * density + - 0.5f); - break; - } - case Configuration.ORIENTATION_PORTRAIT: - case Configuration.ORIENTATION_SQUARE: - default: { - defaultWidth = (int)(CompatibilityInfo.DEFAULT_PORTRAIT_WIDTH * density + - 0.5f); - defaultHeight = (int)(CompatibilityInfo.DEFAULT_PORTRAIT_HEIGHT * density + - 0.5f); - break; - } - case Configuration.ORIENTATION_UNDEFINED: { - // don't change - return; - } - } - - if (defaultWidth < widthPixels) { - // content/window's x offset in original pixels - widthPixels = defaultWidth; - } - if (defaultHeight < heightPixels) { - heightPixels = defaultHeight; - } - } - - if (compatibilityInfo.isScalingRequired()) { - float invertedRatio = compatibilityInfo.applicationInvertedScale; - density *= invertedRatio; - densityDpi = (int)((density*DisplayMetrics.DENSITY_DEFAULT)+.5f); - scaledDensity *= invertedRatio; - xdpi *= invertedRatio; - ydpi *= invertedRatio; - widthPixels = (int) (widthPixels * invertedRatio + 0.5f); - heightPixels = (int) (heightPixels * invertedRatio + 0.5f); - } + realWidthPixels = 0; + realHeightPixels = 0; } @Override |