diff options
author | Dianne Hackborn <hackbod@google.com> | 2011-06-01 21:27:05 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2011-06-01 22:20:38 -0700 |
commit | 2762ff3dc864018352362f6d103de471f9529ba6 (patch) | |
tree | 336a610d1901f4e3ccb526057bed4d0de8ae674a /core/java/android/content/res | |
parent | e66763516a9c27c192adaba417616371a1c3c9bf (diff) | |
download | frameworks_base-2762ff3dc864018352362f6d103de471f9529ba6.zip frameworks_base-2762ff3dc864018352362f6d103de471f9529ba6.tar.gz frameworks_base-2762ff3dc864018352362f6d103de471f9529ba6.tar.bz2 |
Add new supports-screen API to set maximum allowed size.
Change-Id: I0a7cd4ba73a4c18558e6daee28963d5fd12c7978
Diffstat (limited to 'core/java/android/content/res')
-rw-r--r-- | core/java/android/content/res/CompatibilityInfo.java | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/core/java/android/content/res/CompatibilityInfo.java b/core/java/android/content/res/CompatibilityInfo.java index 0d2e567..b686e54 100644 --- a/core/java/android/content/res/CompatibilityInfo.java +++ b/core/java/android/content/res/CompatibilityInfo.java @@ -96,21 +96,42 @@ public class CompatibilityInfo implements Parcelable { boolean forceCompat) { int compatFlags = 0; - if (appInfo.requiresSmallestWidthDp != 0 || appInfo.compatibleWidthLimitDp != 0) { + if (appInfo.requiresSmallestWidthDp != 0 || appInfo.compatibleWidthLimitDp != 0 + || appInfo.largestWidthLimitDp != 0) { // New style screen requirements spec. int required = appInfo.requiresSmallestWidthDp != 0 ? appInfo.requiresSmallestWidthDp : appInfo.compatibleWidthLimitDp; + if (required == 0) { + required = appInfo.largestWidthLimitDp; + } int compat = appInfo.compatibleWidthLimitDp != 0 - ? appInfo.compatibleWidthLimitDp - : appInfo.requiresSmallestWidthDp; + ? appInfo.compatibleWidthLimitDp : required; if (compat < required) { compat = required; } - - if (compat >= sw) { + int largest = appInfo.largestWidthLimitDp; + + if (required > DEFAULT_NORMAL_SHORT_DIMENSION) { + // For now -- if they require a size larger than the only + // size we can do in compatibility mode, then don't ever + // allow the app to go in to compat mode. Trying to run + // it at a smaller size it can handle will make it far more + // broken than running at a larger size than it wants or + // thinks it can handle. + compatFlags |= NEVER_NEEDS_COMPAT; + } else if (largest != 0 && sw > largest) { + // If the screen size is larger than the largest size the + // app thinks it can work with, then always force it in to + // compatibility mode. + compatFlags |= NEEDS_SCREEN_COMPAT | ALWAYS_NEEDS_COMPAT; + } else if (compat >= sw) { + // The screen size is something the app says it was designed + // for, so never do compatibility mode. compatFlags |= NEVER_NEEDS_COMPAT; } else if (forceCompat) { + // The app may work better with or without compatibility mode. + // Let the user decide. compatFlags |= NEEDS_SCREEN_COMPAT; } |