diff options
author | Mitsuru Oshima <oshima@google.com> | 2009-06-09 21:16:08 -0700 |
---|---|---|
committer | Mitsuru Oshima <oshima@google.com> | 2009-06-10 15:22:17 -0700 |
commit | e5fb328825995aa33b5b7ecf8b5bee2b17f81715 (patch) | |
tree | 4b6ca87aaf21dd587e1d033f5ba3318c4329698f /core/java/android/util | |
parent | ca436e24dec0fa258a8a756c3e7d07bcb096c5b3 (diff) | |
download | frameworks_base-e5fb328825995aa33b5b7ecf8b5bee2b17f81715.zip frameworks_base-e5fb328825995aa33b5b7ecf8b5bee2b17f81715.tar.gz frameworks_base-e5fb328825995aa33b5b7ecf8b5bee2b17f81715.tar.bz2 |
resolution support fix/improvement
* adding compatibility menu
* backup gravity
* set expanable=true if the screen size is hvga * density.
* added "supports any density" mode. I'll add sdk check later.
* disallow to catch orientation change event if the app is not expandable. This
was causing layout problem under non-expandable mode. I discussed this with Mike C
and we agreed to do this approach for now. We'll revisit if this causes problem to
a lot of applications.
Diffstat (limited to 'core/java/android/util')
-rw-r--r-- | core/java/android/util/DisplayMetrics.java | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/core/java/android/util/DisplayMetrics.java b/core/java/android/util/DisplayMetrics.java index 987be2b..245148d 100644 --- a/core/java/android/util/DisplayMetrics.java +++ b/core/java/android/util/DisplayMetrics.java @@ -103,10 +103,10 @@ public class DisplayMetrics { } /** - * Update the display metrics based on the compatibility info and configuration. + * Update the display metrics based on the compatibility info and orientation * {@hide} */ - public void updateMetrics(CompatibilityInfo compatibilityInfo, Configuration configuration) { + public void updateMetrics(CompatibilityInfo compatibilityInfo, int orientation) { if (compatibilityInfo.mScalingRequired) { float invertedRatio = compatibilityInfo.mApplicationInvertedScale; density *= invertedRatio; @@ -116,31 +116,42 @@ public class DisplayMetrics { widthPixels *= invertedRatio; heightPixels *= invertedRatio; } - if (!compatibilityInfo.mExpandable) { + if (!compatibilityInfo.mConfiguredExpandable) { // Note: this assume that configuration is updated before calling // updateMetrics method. int defaultWidth; int defaultHeight; - switch (configuration.orientation) { + switch (orientation) { case Configuration.ORIENTATION_LANDSCAPE: { defaultWidth = (int)(CompatibilityInfo.DEFAULT_PORTRAIT_HEIGHT * density); defaultHeight = (int)(CompatibilityInfo.DEFAULT_PORTRAIT_WIDTH * density); break; } - case Configuration.ORIENTATION_UNDEFINED: case Configuration.ORIENTATION_PORTRAIT: case Configuration.ORIENTATION_SQUARE: default: { defaultWidth = (int)(CompatibilityInfo.DEFAULT_PORTRAIT_WIDTH * density); defaultHeight = (int)(CompatibilityInfo.DEFAULT_PORTRAIT_HEIGHT * density); + break; + } + case Configuration.ORIENTATION_UNDEFINED: { + // don't change + return; } } - // adjust the size only when the device's screen is bigger. - if (defaultWidth < widthPixels) { - widthPixels = defaultWidth; - } - if (defaultHeight < heightPixels) { - heightPixels = defaultHeight; + + if (defaultWidth == widthPixels && defaultHeight == heightPixels) { + // the screen size is same as expected size. make it expandable + compatibilityInfo.mExpandable = true; + } else { + compatibilityInfo.mExpandable = false; + // adjust the size only when the device's screen is bigger. + if (defaultWidth < widthPixels) { + widthPixels = defaultWidth; + } + if (defaultHeight < heightPixels) { + heightPixels = defaultHeight; + } } } } |