diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-07-21 19:01:28 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-07-21 19:01:28 -0700 |
commit | 9fc20b0e381b5fe00b7049ef357c839cd05a33bf (patch) | |
tree | 043fdbb02527c00a2003094291351159a5015ef8 /core/java/android/util/DisplayMetrics.java | |
parent | 7c94ceaeac65f4604fa49df6dce9a8d584f52da2 (diff) | |
parent | c4db95c077f826585d20be2f3db4043c53d30cf5 (diff) | |
download | frameworks_base-9fc20b0e381b5fe00b7049ef357c839cd05a33bf.zip frameworks_base-9fc20b0e381b5fe00b7049ef357c839cd05a33bf.tar.gz frameworks_base-9fc20b0e381b5fe00b7049ef357c839cd05a33bf.tar.bz2 |
Merge change 8126 into donut
* changes:
First pass at reworking screen density/size APIs.
Diffstat (limited to 'core/java/android/util/DisplayMetrics.java')
-rw-r--r-- | core/java/android/util/DisplayMetrics.java | 98 |
1 files changed, 57 insertions, 41 deletions
diff --git a/core/java/android/util/DisplayMetrics.java b/core/java/android/util/DisplayMetrics.java index 38d99b3..061f98a 100644 --- a/core/java/android/util/DisplayMetrics.java +++ b/core/java/android/util/DisplayMetrics.java @@ -123,51 +123,67 @@ public class DisplayMetrics { */ public void updateMetrics(CompatibilityInfo compatibilityInfo, int orientation, int screenLayout) { - if (!compatibilityInfo.isConfiguredExpandable()) { - // Note: this assume that configuration is updated before calling - // updateMetrics method. - if (screenLayout == Configuration.SCREENLAYOUT_LARGE) { - // This is a large screen device and the app is not - // compatible with large screens, to diddle it. - + boolean expandable = compatibilityInfo.isConfiguredExpandable(); + boolean largeScreens = compatibilityInfo.isConfiguredLargeScreens(); + + // 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); - // 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 (!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 (!expandable || !largeScreens) { + // 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; } - - if (defaultWidth < widthPixels) { - // content/window's x offset in original pixels - widthPixels = defaultWidth; + 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; } - if (defaultHeight < heightPixels) { - heightPixels = defaultHeight; + case Configuration.ORIENTATION_UNDEFINED: { + // don't change + return; } - - } else { - // the screen size is same as expected size. make it expandable - compatibilityInfo.setExpandable(true); + } + + if (defaultWidth < widthPixels) { + // content/window's x offset in original pixels + widthPixels = defaultWidth; + } + if (defaultHeight < heightPixels) { + heightPixels = defaultHeight; } } if (compatibilityInfo.isScalingRequired()) { |