From 2762ff3dc864018352362f6d103de471f9529ba6 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Wed, 1 Jun 2011 21:27:05 -0700 Subject: Add new supports-screen API to set maximum allowed size. Change-Id: I0a7cd4ba73a4c18558e6daee28963d5fd12c7978 --- .../android/content/res/CompatibilityInfo.java | 31 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'core/java/android/content/res') 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; } -- cgit v1.1