summaryrefslogtreecommitdiffstats
path: root/core/java/android/util
diff options
context:
space:
mode:
authorMitsuru Oshima <oshima@google.com>2009-06-03 11:19:12 -0700
committerMitsuru Oshima <oshima@google.com>2009-06-03 16:28:10 -0700
commit9189cabb0b6c6c28232fe6f412b7ba7a37352a6a (patch)
tree6ddc6a8eb0158cba32cc6139b04c6b6eb9f0ba5f /core/java/android/util
parenteaeb663bcd7a82b654954b42663232cbd7bef7e7 (diff)
downloadframeworks_base-9189cabb0b6c6c28232fe6f412b7ba7a37352a6a.zip
frameworks_base-9189cabb0b6c6c28232fe6f412b7ba7a37352a6a.tar.gz
frameworks_base-9189cabb0b6c6c28232fe6f412b7ba7a37352a6a.tar.bz2
* Moved supports-density tag under manifest
* Refactored Compatibility code * Added CompatibilityInfo class * Removed getApplicationScale from Context * Added Resources#getCompatibilityInfo so that RootView can get the compatibility info w/o going through Context * Expandable support * Added expandable tag under manifest * Old application w/o expandable is given the default screen size ([320, 480] x density). * The non-expandable window is centered.
Diffstat (limited to 'core/java/android/util')
-rw-r--r--core/java/android/util/DisplayMetrics.java51
1 files changed, 41 insertions, 10 deletions
diff --git a/core/java/android/util/DisplayMetrics.java b/core/java/android/util/DisplayMetrics.java
index e4dd020..987be2b 100644
--- a/core/java/android/util/DisplayMetrics.java
+++ b/core/java/android/util/DisplayMetrics.java
@@ -16,6 +16,8 @@
package android.util;
+import android.content.res.CompatibilityInfo;
+import android.content.res.Configuration;
import android.os.*;
@@ -101,17 +103,46 @@ public class DisplayMetrics {
}
/**
- * Set the display metrics' density and update parameters depend on it.
- * @hide
+ * Update the display metrics based on the compatibility info and configuration.
+ * {@hide}
*/
- public void updateDensity(float newDensity) {
- float ratio = newDensity / density;
- density = newDensity;
- scaledDensity = density;
- widthPixels *= ratio;
- heightPixels *= ratio;
- xdpi *= ratio;
- ydpi *= ratio;
+ public void updateMetrics(CompatibilityInfo compatibilityInfo, Configuration configuration) {
+ if (compatibilityInfo.mScalingRequired) {
+ float invertedRatio = compatibilityInfo.mApplicationInvertedScale;
+ density *= invertedRatio;
+ scaledDensity *= invertedRatio;
+ xdpi *= invertedRatio;
+ ydpi *= invertedRatio;
+ widthPixels *= invertedRatio;
+ heightPixels *= invertedRatio;
+ }
+ if (!compatibilityInfo.mExpandable) {
+ // Note: this assume that configuration is updated before calling
+ // updateMetrics method.
+ int defaultWidth;
+ int defaultHeight;
+ switch (configuration.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);
+ }
+ }
+ // adjust the size only when the device's screen is bigger.
+ if (defaultWidth < widthPixels) {
+ widthPixels = defaultWidth;
+ }
+ if (defaultHeight < heightPixels) {
+ heightPixels = defaultHeight;
+ }
+ }
}
public String toString() {