diff options
| author | Mitsuru Oshima <oshima@google.com> | 2009-07-02 20:06:08 -0700 |
|---|---|---|
| committer | Mitsuru Oshima <oshima@google.com> | 2009-07-06 21:13:39 -0700 |
| commit | 569076c9f6bdadb4d3285a26e069634a839b5b87 (patch) | |
| tree | 55f3486ab528a454de07dbdb815b58f9e83a3839 /core/java/android/content | |
| parent | dbee95cacff9d2faf30638e64abe26fbeb128787 (diff) | |
| download | frameworks_base-569076c9f6bdadb4d3285a26e069634a839b5b87.zip frameworks_base-569076c9f6bdadb4d3285a26e069634a839b5b87.tar.gz frameworks_base-569076c9f6bdadb4d3285a26e069634a839b5b87.tar.bz2 | |
widgets scaling fix. Use container's compatibility info and display metrics when container and widgets disagree.
Diffstat (limited to 'core/java/android/content')
| -rw-r--r-- | core/java/android/content/res/CompatibilityInfo.java | 28 | ||||
| -rw-r--r-- | core/java/android/content/res/Resources.java | 22 |
2 files changed, 44 insertions, 6 deletions
diff --git a/core/java/android/content/res/CompatibilityInfo.java b/core/java/android/content/res/CompatibilityInfo.java index 4e6fe07..dfe304d 100644 --- a/core/java/android/content/res/CompatibilityInfo.java +++ b/core/java/android/content/res/CompatibilityInfo.java @@ -159,15 +159,33 @@ public class CompatibilityInfo { } } + private CompatibilityInfo(int appFlags, int compFlags, float scale, float invertedScale) { + this.appFlags = appFlags; + mCompatibilityFlags = compFlags; + applicationScale = scale; + applicationInvertedScale = invertedScale; + } + private CompatibilityInfo() { - appFlags = ApplicationInfo.FLAG_SUPPORTS_SMALL_SCREENS + this(ApplicationInfo.FLAG_SUPPORTS_SMALL_SCREENS | ApplicationInfo.FLAG_SUPPORTS_NORMAL_SCREENS - | ApplicationInfo.FLAG_SUPPORTS_LARGE_SCREENS; - applicationScale = applicationInvertedScale = 1.0f; - mCompatibilityFlags = EXPANDABLE | CONFIGURED_EXPANDABLE; + | ApplicationInfo.FLAG_SUPPORTS_LARGE_SCREENS, + EXPANDABLE | CONFIGURED_EXPANDABLE, + 1.0f, + 1.0f); } /** + * Returns the copy of this instance. + */ + public CompatibilityInfo copy() { + CompatibilityInfo info = new CompatibilityInfo(appFlags, mCompatibilityFlags, + applicationScale, applicationInvertedScale); + info.setVisibleRect(mXOffset, mWidth, mHeight); + return info; + } + + /** * Sets the application's visible rect in compatibility mode. * @param xOffset the application's x offset that is added to center the content. * @param widthPixels the application's width in real pixels on the screen. @@ -470,4 +488,4 @@ public class CompatibilityInfo { return mVisibleInsets; } } -}
\ No newline at end of file +} diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java index d7512bb..49ad656 100644 --- a/core/java/android/content/res/Resources.java +++ b/core/java/android/content/res/Resources.java @@ -129,7 +129,7 @@ public class Resources { */ public Resources(AssetManager assets, DisplayMetrics metrics, Configuration config) { - this(assets, metrics, config, null); + this(assets, metrics, config, (ApplicationInfo) null); } /** @@ -166,6 +166,26 @@ public class Resources { } /** + * Creates a new resources that uses the given compatibility info. Used to create + * a context for widgets using the container's compatibility info. + * {@see ApplicationContext#createPackageCotnext}. + * @hide + */ + public Resources(AssetManager assets, DisplayMetrics metrics, + Configuration config, CompatibilityInfo info) { + mAssets = assets; + mMetrics.setToDefaults(); + mCompatibilityInfo = info; + updateConfiguration(config, metrics); + assets.ensureStringBlocks(); + if (mCompatibilityInfo.isScalingRequired()) { + mPreloadedDrawables = emptySparseArray(); + } else { + mPreloadedDrawables = sPreloadedDrawables; + } + } + + /** * Return a global shared Resources object that provides access to only * system resources (no application resources), and is not configured for * the current screen (can not use dimension units, does not change based |
