diff options
author | Dianne Hackborn <hackbod@google.com> | 2009-07-22 21:48:55 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2009-07-24 10:47:15 -0700 |
commit | 11ea33471e1a14a8594f0b2cd012d86340dd3bd8 (patch) | |
tree | bb73c079d8bb21c19fa913b8fd9c587a9089ea84 /core/java/android/util | |
parent | 3b99e64e5899030b5d6f8201cb56cd149c80b24d (diff) | |
download | frameworks_base-11ea33471e1a14a8594f0b2cd012d86340dd3bd8.zip frameworks_base-11ea33471e1a14a8594f0b2cd012d86340dd3bd8.tar.gz frameworks_base-11ea33471e1a14a8594f0b2cd012d86340dd3bd8.tar.bz2 |
Allow for screen density drawables in compatibility mode.
This change allows us to use drawables that match the current screen
density even when being loaded in compatibility mode. In this case,
the bitmap is loaded in the screen density, and the bitmap and
nine-patch drawables take care of accounting for the density difference.
This should be safe for existing applications, for the most part, since
they shouldn't really be pulling the bitmap out of the drawable. For
the small rare chance of them breaking, it worth getting the correct
graphics. Also this will only happen when there is actually a resource
of the matching density, and no existing apps should have resources for
anything besides the default density (though of course all of the
framework resources will be available in the native density).
As part of this, the bitmap density API has been changed to a single
integer provider the DPI unit density.
Diffstat (limited to 'core/java/android/util')
-rw-r--r-- | core/java/android/util/DisplayMetrics.java | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/core/java/android/util/DisplayMetrics.java b/core/java/android/util/DisplayMetrics.java index 061f98a..dd5a440 100644 --- a/core/java/android/util/DisplayMetrics.java +++ b/core/java/android/util/DisplayMetrics.java @@ -80,6 +80,11 @@ public class DisplayMetrics { */ public float density; /** + * The screen density expressed as dots-per-inch. May be either + * {@link #DENSITY_LOW}, {@link #DENSITY_MEDIUM}, or {@link #DENSITY_HIGH}. + */ + public int densityDpi; + /** * A scaling factor for fonts displayed on the display. This is the same * as {@link #density}, except that it may be adjusted in smaller * increments at runtime based on a user preference for the font size. @@ -101,6 +106,7 @@ public class DisplayMetrics { widthPixels = o.widthPixels; heightPixels = o.heightPixels; density = o.density; + densityDpi = o.densityDpi; scaledDensity = o.scaledDensity; xdpi = o.xdpi; ydpi = o.ydpi; @@ -110,6 +116,7 @@ public class DisplayMetrics { widthPixels = 0; heightPixels = 0; density = DENSITY_DEVICE / (float) DENSITY_DEFAULT; + densityDpi = DENSITY_DEVICE; scaledDensity = density; xdpi = DENSITY_DEVICE; ydpi = DENSITY_DEVICE; @@ -186,9 +193,11 @@ public class DisplayMetrics { heightPixels = defaultHeight; } } + if (compatibilityInfo.isScalingRequired()) { float invertedRatio = compatibilityInfo.applicationInvertedScale; density *= invertedRatio; + densityDpi = (int)((density*DisplayMetrics.DENSITY_DEFAULT)+.5f); scaledDensity *= invertedRatio; xdpi *= invertedRatio; ydpi *= invertedRatio; |