diff --git a/api/current.xml b/api/current.xml index ae7e7569330a7..9f79118728452 100644 --- a/api/current.xml +++ b/api/current.xml @@ -3463,17 +3463,6 @@ visibility="public" > - - + + + + - + + + + + + + + - + + - -= android.os.Build.VERSION_CODES.CUR_DEVELOPMENT)) { pkg.applicationInfo.flags |= ApplicationInfo.FLAG_SUPPORTS_LARGE_SCREENS; } + if (resizeable < 0 || (resizeable > 0 + && pkg.applicationInfo.targetSdkVersion + >= android.os.Build.VERSION_CODES.CUR_DEVELOPMENT)) { + pkg.applicationInfo.flags |= ApplicationInfo.FLAG_RESIZEABLE_FOR_SCREENS; + } int densities[] = null; int size = pkg.supportsDensityList.size(); if (size > 0) { diff --git a/core/java/android/content/res/CompatibilityInfo.java b/core/java/android/content/res/CompatibilityInfo.java index 2805bd5ec0bf3..517551ec8e149 100644 --- a/core/java/android/content/res/CompatibilityInfo.java +++ b/core/java/android/content/res/CompatibilityInfo.java @@ -69,8 +69,8 @@ public class CompatibilityInfo { /** * A flag mask to indicates that the application can expand over the original size. * The flag is set to true if - * 1) Application declares its expandable in manifest file using or - * 2) The screen size is same as (320 x 480) * density. + * 1) Application declares its expandable in manifest file using or + * 2) Configuration.SCREENLAYOUT_COMPAT_NEEDED is not set * {@see compatibilityFlag} */ private static final int EXPANDABLE = 2; @@ -78,11 +78,28 @@ public class CompatibilityInfo { /** * A flag mask to tell if the application is configured to be expandable. This differs * from EXPANDABLE in that the application that is not expandable will be - * marked as expandable if it runs in (320x 480) * density screen size. + * marked as expandable if Configuration.SCREENLAYOUT_COMPAT_NEEDED is not set. */ private static final int CONFIGURED_EXPANDABLE = 4; - private static final int SCALING_EXPANDABLE_MASK = SCALING_REQUIRED | EXPANDABLE; + /** + * A flag mask to indicates that the application supports large screens. + * The flag is set to true if + * 1) Application declares it supports large screens in manifest file using or + * 2) The screen size is not large + * {@see compatibilityFlag} + */ + private static final int LARGE_SCREENS = 8; + + /** + * A flag mask to tell if the application supports large screens. This differs + * from LARGE_SCREENS in that the application that does not support large + * screens will be marked as supporting them if the current screen is not + * large. + */ + private static final int CONFIGURED_LARGE_SCREENS = 16; + + private static final int SCALING_EXPANDABLE_MASK = SCALING_REQUIRED | EXPANDABLE | LARGE_SCREENS; /** * The effective screen density we have selected for this application. @@ -108,7 +125,10 @@ public class CompatibilityInfo { appFlags = appInfo.flags; if ((appInfo.flags & ApplicationInfo.FLAG_SUPPORTS_LARGE_SCREENS) != 0) { - mCompatibilityFlags = EXPANDABLE | CONFIGURED_EXPANDABLE; + mCompatibilityFlags |= LARGE_SCREENS | CONFIGURED_LARGE_SCREENS; + } + if ((appInfo.flags & ApplicationInfo.FLAG_RESIZEABLE_FOR_SCREENS) != 0) { + mCompatibilityFlags |= EXPANDABLE | CONFIGURED_EXPANDABLE; } float packageDensityScale = -1.0f; @@ -162,7 +182,8 @@ public class CompatibilityInfo { private CompatibilityInfo() { this(ApplicationInfo.FLAG_SUPPORTS_SMALL_SCREENS | ApplicationInfo.FLAG_SUPPORTS_NORMAL_SCREENS - | ApplicationInfo.FLAG_SUPPORTS_LARGE_SCREENS, + | ApplicationInfo.FLAG_SUPPORTS_LARGE_SCREENS + | ApplicationInfo.FLAG_RESIZEABLE_FOR_SCREENS, EXPANDABLE | CONFIGURED_EXPANDABLE, DisplayMetrics.DENSITY_DEVICE, 1.0f, @@ -189,6 +210,17 @@ public class CompatibilityInfo { } } + /** + * Sets large screen bit in the compatibility flag. + */ + public void setLargeScreens(boolean expandable) { + if (expandable) { + mCompatibilityFlags |= CompatibilityInfo.LARGE_SCREENS; + } else { + mCompatibilityFlags &= ~CompatibilityInfo.LARGE_SCREENS; + } + } + /** * @return true if the application is configured to be expandable. */ @@ -196,6 +228,13 @@ public class CompatibilityInfo { return (mCompatibilityFlags & CompatibilityInfo.CONFIGURED_EXPANDABLE) != 0; } + /** + * @return true if the application is configured to be expandable. + */ + public boolean isConfiguredLargeScreens() { + return (mCompatibilityFlags & CompatibilityInfo.CONFIGURED_LARGE_SCREENS) != 0; + } + /** * @return true if the scaling is required */ @@ -204,7 +243,8 @@ public class CompatibilityInfo { } public boolean supportsScreen() { - return (mCompatibilityFlags & CompatibilityInfo.EXPANDABLE) != 0; + return (mCompatibilityFlags & (EXPANDABLE|LARGE_SCREENS)) + == (EXPANDABLE|LARGE_SCREENS); } @Override @@ -219,8 +259,8 @@ public class CompatibilityInfo { * @param params the window's parameter */ public Translator getTranslator(WindowManager.LayoutParams params) { - if ( (mCompatibilityFlags & CompatibilityInfo.SCALING_EXPANDABLE_MASK) - == CompatibilityInfo.EXPANDABLE) { + if ( (mCompatibilityFlags & SCALING_EXPANDABLE_MASK) + == (EXPANDABLE|LARGE_SCREENS)) { if (DBG) Log.d(TAG, "no translation required"); return null; } diff --git a/core/java/android/content/res/Configuration.java b/core/java/android/content/res/Configuration.java index 4928e93484446..cbf8410b8d9f5 100644 --- a/core/java/android/content/res/Configuration.java +++ b/core/java/android/content/res/Configuration.java @@ -41,6 +41,39 @@ public final class Configuration implements Parcelable, ComparableThe {@link #SCREENLAYOUT_SIZE_MASK} bits define the overall size + * of the screen. They may be one of + * {@link #SCREENLAYOUT_SIZE_SMALL}, {@link #SCREENLAYOUT_SIZE_NORMAL}, + * or {@link #SCREENLAYOUT_SIZE_LARGE}. + * + *

The {@link #SCREENLAYOUT_LONG_MASK} defines whether the screen + * is wider/taller than normal. They may be one of + * {@link #SCREENLAYOUT_LONG_NO} or {@link #SCREENLAYOUT_LONG_YES}. + */ + public int screenLayout; + public static final int TOUCHSCREEN_UNDEFINED = 0; public static final int TOUCHSCREEN_NOTOUCH = 1; public static final int TOUCHSCREEN_STYLUS = 2; @@ -117,18 +150,6 @@ public final class Configuration implements Parcelable, Comparable + + - DpiTest: Large Screen + DpiTest: Large Long diff --git a/tests/DpiTest/res/values-normalScreen/strings.xml b/tests/DpiTest/res/values-large-notlong/strings.xml similarity index 91% rename from tests/DpiTest/res/values-normalScreen/strings.xml rename to tests/DpiTest/res/values-large-notlong/strings.xml index 256d696df80ed..9681f4428908a 100644 --- a/tests/DpiTest/res/values-normalScreen/strings.xml +++ b/tests/DpiTest/res/values-large-notlong/strings.xml @@ -15,5 +15,5 @@ --> - DpiTest: Normal Screen + DpiTest: Large NotLong diff --git a/tests/DpiTest/res/values-smallScreen/strings.xml b/tests/DpiTest/res/values-large/strings.xml similarity index 92% rename from tests/DpiTest/res/values-smallScreen/strings.xml rename to tests/DpiTest/res/values-large/strings.xml index cdb4ac9f60bd8..faa95f2b8fd24 100644 --- a/tests/DpiTest/res/values-smallScreen/strings.xml +++ b/tests/DpiTest/res/values-large/strings.xml @@ -15,5 +15,5 @@ --> - DpiTest: Small Screen + DpiTest: Large diff --git a/tests/DpiTest/res/values-long/strings.xml b/tests/DpiTest/res/values-long/strings.xml new file mode 100644 index 0000000000000..d6e5d93394f6c --- /dev/null +++ b/tests/DpiTest/res/values-long/strings.xml @@ -0,0 +1,19 @@ + + + + + DpiTest: Long + diff --git a/tests/DpiTest/res/values-normal-long/strings.xml b/tests/DpiTest/res/values-normal-long/strings.xml new file mode 100644 index 0000000000000..640608396d758 --- /dev/null +++ b/tests/DpiTest/res/values-normal-long/strings.xml @@ -0,0 +1,19 @@ + + + + + DpiTest: Normal Long + diff --git a/tests/DpiTest/res/values-normal-notlong/strings.xml b/tests/DpiTest/res/values-normal-notlong/strings.xml new file mode 100644 index 0000000000000..3265e4c5ae024 --- /dev/null +++ b/tests/DpiTest/res/values-normal-notlong/strings.xml @@ -0,0 +1,19 @@ + + + + + DpiTest: Normal NotLong + diff --git a/tests/DpiTest/res/values-normal/strings.xml b/tests/DpiTest/res/values-normal/strings.xml new file mode 100644 index 0000000000000..1e27da4aa57cf --- /dev/null +++ b/tests/DpiTest/res/values-normal/strings.xml @@ -0,0 +1,19 @@ + + + + + DpiTest: Normal + diff --git a/tests/DpiTest/res/values-notlong/strings.xml b/tests/DpiTest/res/values-notlong/strings.xml new file mode 100644 index 0000000000000..4b9d5da319b91 --- /dev/null +++ b/tests/DpiTest/res/values-notlong/strings.xml @@ -0,0 +1,19 @@ + + + + + DpiTest: NotLong + diff --git a/tests/DpiTest/res/values-small-long/strings.xml b/tests/DpiTest/res/values-small-long/strings.xml new file mode 100644 index 0000000000000..2575b0d917b7b --- /dev/null +++ b/tests/DpiTest/res/values-small-long/strings.xml @@ -0,0 +1,19 @@ + + + + + DpiTest: Small Long + diff --git a/tests/DpiTest/res/values-small-notlong/strings.xml b/tests/DpiTest/res/values-small-notlong/strings.xml new file mode 100644 index 0000000000000..2df2b29a29543 --- /dev/null +++ b/tests/DpiTest/res/values-small-notlong/strings.xml @@ -0,0 +1,19 @@ + + + + + DpiTest: Small NotLong + diff --git a/tests/DpiTest/res/values-small/strings.xml b/tests/DpiTest/res/values-small/strings.xml new file mode 100644 index 0000000000000..9fd5e4014894c --- /dev/null +++ b/tests/DpiTest/res/values-small/strings.xml @@ -0,0 +1,19 @@ + + + + + DpiTest: Small + diff --git a/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java b/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java index 8c69305d57609..49fff57ba0fe1 100644 --- a/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java +++ b/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java @@ -57,7 +57,8 @@ public class DpiTestActivity extends Activity { if (noCompat) { ai.flags |= ApplicationInfo.FLAG_SUPPORTS_LARGE_SCREENS | ApplicationInfo.FLAG_SUPPORTS_NORMAL_SCREENS - | ApplicationInfo.FLAG_SUPPORTS_SMALL_SCREENS; + | ApplicationInfo.FLAG_SUPPORTS_SMALL_SCREENS + | ApplicationInfo.FLAG_RESIZEABLE_FOR_SCREENS; ai.supportsDensities = new int[] { ApplicationInfo.ANY_DENSITY }; app.getResources().setCompatibilityInfo(new CompatibilityInfo(ai)); } diff --git a/tools/aapt/AaptAssets.cpp b/tools/aapt/AaptAssets.cpp index 14cad2f0b8b9c..dbcef6d67480a 100644 --- a/tools/aapt/AaptAssets.cpp +++ b/tools/aapt/AaptAssets.cpp @@ -138,6 +138,20 @@ AaptGroupEntry::parseNamePart(const String8& part, int* axis, uint32_t* value) return 0; } + // screen layout size + if (getScreenLayoutSizeName(part.string(), &config)) { + *axis = AXIS_SCREENLAYOUTSIZE; + *value = (config.screenLayout&ResTable_config::MASK_SCREENSIZE); + return 0; + } + + // screen layout long + if (getScreenLayoutLongName(part.string(), &config)) { + *axis = AXIS_SCREENLAYOUTLONG; + *value = (config.screenLayout&ResTable_config::MASK_SCREENLONG); + return 0; + } + // orientation if (getOrientationName(part.string(), &config)) { *axis = AXIS_ORIENTATION; @@ -187,13 +201,6 @@ AaptGroupEntry::parseNamePart(const String8& part, int* axis, uint32_t* value) return 0; } - // screen layout - if (getScreenLayoutName(part.string(), &config)) { - *axis = AXIS_SCREENLAYOUT; - *value = config.screenLayout; - return 0; - } - // version if (getVersionName(part.string(), &config)) { *axis = AXIS_VERSION; @@ -209,7 +216,8 @@ AaptGroupEntry::initFromDirName(const char* dir, String8* resType) { Vector parts; - String8 mcc, mnc, loc, orient, den, touch, key, keysHidden, nav, size, layout, vers; + String8 mcc, mnc, loc, layoutsize, layoutlong, orient, den; + String8 touch, key, keysHidden, nav, size, vers; const char *p = dir; const char *q; @@ -296,6 +304,30 @@ AaptGroupEntry::initFromDirName(const char* dir, String8* resType) //printf("not region: %s\n", part.string()); } + if (getScreenLayoutSizeName(part.string())) { + layoutsize = part; + + index++; + if (index == N) { + goto success; + } + part = parts[index]; + } else { + //printf("not screen layout size: %s\n", part.string()); + } + + if (getScreenLayoutLongName(part.string())) { + layoutlong = part; + + index++; + if (index == N) { + goto success; + } + part = parts[index]; + } else { + //printf("not screen layout long: %s\n", part.string()); + } + // orientation if (getOrientationName(part.string())) { orient = part; @@ -385,18 +417,6 @@ AaptGroupEntry::initFromDirName(const char* dir, String8* resType) //printf("not screen size: %s\n", part.string()); } - if (getScreenLayoutName(part.string())) { - layout = part; - - index++; - if (index == N) { - goto success; - } - part = parts[index]; - } else { - //printf("not screen layout: %s\n", part.string()); - } - if (getVersionName(part.string())) { vers = part; @@ -416,6 +436,8 @@ success: this->mcc = mcc; this->mnc = mnc; this->locale = loc; + this->screenLayoutSize = layoutsize; + this->screenLayoutLong = layoutlong; this->orientation = orient; this->density = den; this->touchscreen = touch; @@ -423,7 +445,6 @@ success: this->keyboard = key; this->navigation = nav; this->screenSize = size; - this->screenLayout = layout; this->version = vers; // what is this anyway? @@ -441,6 +462,10 @@ AaptGroupEntry::toString() const s += ","; s += this->locale; s += ","; + s += screenLayoutSize; + s += ","; + s += screenLayoutLong; + s += ","; s += this->orientation; s += ","; s += density; @@ -455,8 +480,6 @@ AaptGroupEntry::toString() const s += ","; s += screenSize; s += ","; - s += screenLayout; - s += ","; s += version; return s; } @@ -477,6 +500,14 @@ AaptGroupEntry::toDirName(const String8& resType) const s += "-"; s += locale; } + if (this->screenLayoutSize != "") { + s += "-"; + s += screenLayoutSize; + } + if (this->screenLayoutLong != "") { + s += "-"; + s += screenLayoutLong; + } if (this->orientation != "") { s += "-"; s += orientation; @@ -505,10 +536,6 @@ AaptGroupEntry::toDirName(const String8& resType) const s += "-"; s += screenSize; } - if (this->screenLayout != "") { - s += "-"; - s += screenLayout; - } if (this->version != "") { s += "-"; s += version; @@ -630,6 +657,57 @@ bool AaptGroupEntry::getLocaleName(const char* fileName, return false; } +bool AaptGroupEntry::getScreenLayoutSizeName(const char* name, + ResTable_config* out) +{ + if (strcmp(name, kWildcardName) == 0) { + if (out) out->screenLayout = + (out->screenLayout&~ResTable_config::MASK_SCREENSIZE) + | ResTable_config::SCREENSIZE_ANY; + return true; + } else if (strcmp(name, "small") == 0) { + if (out) out->screenLayout = + (out->screenLayout&~ResTable_config::MASK_SCREENSIZE) + | ResTable_config::SCREENSIZE_SMALL; + return true; + } else if (strcmp(name, "normal") == 0) { + if (out) out->screenLayout = + (out->screenLayout&~ResTable_config::MASK_SCREENSIZE) + | ResTable_config::SCREENSIZE_NORMAL; + return true; + } else if (strcmp(name, "large") == 0) { + if (out) out->screenLayout = + (out->screenLayout&~ResTable_config::MASK_SCREENSIZE) + | ResTable_config::SCREENSIZE_LARGE; + return true; + } + + return false; +} + +bool AaptGroupEntry::getScreenLayoutLongName(const char* name, + ResTable_config* out) +{ + if (strcmp(name, kWildcardName) == 0) { + if (out) out->screenLayout = + (out->screenLayout&~ResTable_config::MASK_SCREENLONG) + | ResTable_config::SCREENLONG_ANY; + return true; + } else if (strcmp(name, "long") == 0) { + if (out) out->screenLayout = + (out->screenLayout&~ResTable_config::MASK_SCREENLONG) + | ResTable_config::SCREENLONG_YES; + return true; + } else if (strcmp(name, "notlong") == 0) { + if (out) out->screenLayout = + (out->screenLayout&~ResTable_config::MASK_SCREENLONG) + | ResTable_config::SCREENLONG_NO; + return true; + } + + return false; +} + bool AaptGroupEntry::getOrientationName(const char* name, ResTable_config* out) { @@ -663,6 +741,21 @@ bool AaptGroupEntry::getDensityName(const char* name, return true; } + if (strcmp(name, "ldpi") == 0) { + if (out) out->density = ResTable_config::DENSITY_LOW; + return true; + } + + if (strcmp(name, "mdpi") == 0) { + if (out) out->density = ResTable_config::DENSITY_MEDIUM; + return true; + } + + if (strcmp(name, "hdpi") == 0) { + if (out) out->density = ResTable_config::DENSITY_HIGH; + return true; + } + char* c = (char*)name; while (*c >= '0' && *c <= '9') { c++; @@ -818,26 +911,6 @@ bool AaptGroupEntry::getScreenSizeName(const char* name, return true; } -bool AaptGroupEntry::getScreenLayoutName(const char* name, - ResTable_config* out) -{ - if (strcmp(name, kWildcardName) == 0) { - if (out) out->screenLayout = out->SCREENLAYOUT_ANY; - return true; - } else if (strcmp(name, "smallscreen") == 0) { - if (out) out->screenLayout = out->SCREENLAYOUT_SMALL; - return true; - } else if (strcmp(name, "normalscreen") == 0) { - if (out) out->screenLayout = out->SCREENLAYOUT_NORMAL; - return true; - } else if (strcmp(name, "largescreen") == 0) { - if (out) out->screenLayout = out->SCREENLAYOUT_LARGE; - return true; - } - - return false; -} - bool AaptGroupEntry::getVersionName(const char* name, ResTable_config* out) { @@ -873,6 +946,8 @@ int AaptGroupEntry::compare(const AaptGroupEntry& o) const if (v == 0) v = mnc.compare(o.mnc); if (v == 0) v = locale.compare(o.locale); if (v == 0) v = vendor.compare(o.vendor); + if (v == 0) v = screenLayoutSize.compare(o.screenLayoutSize); + if (v == 0) v = screenLayoutLong.compare(o.screenLayoutLong); if (v == 0) v = orientation.compare(o.orientation); if (v == 0) v = density.compare(o.density); if (v == 0) v = touchscreen.compare(o.touchscreen); @@ -880,7 +955,6 @@ int AaptGroupEntry::compare(const AaptGroupEntry& o) const if (v == 0) v = keyboard.compare(o.keyboard); if (v == 0) v = navigation.compare(o.navigation); if (v == 0) v = screenSize.compare(o.screenSize); - if (v == 0) v = screenLayout.compare(o.screenLayout); if (v == 0) v = version.compare(o.version); return v; } @@ -892,6 +966,8 @@ ResTable_config AaptGroupEntry::toParams() const getMccName(mcc.string(), ¶ms); getMncName(mnc.string(), ¶ms); getLocaleName(locale.string(), ¶ms); + getScreenLayoutSizeName(screenLayoutSize.string(), ¶ms); + getScreenLayoutLongName(screenLayoutLong.string(), ¶ms); getOrientationName(orientation.string(), ¶ms); getDensityName(density.string(), ¶ms); getTouchscreenName(touchscreen.string(), ¶ms); @@ -899,7 +975,6 @@ ResTable_config AaptGroupEntry::toParams() const getKeyboardName(keyboard.string(), ¶ms); getNavigationName(navigation.string(), ¶ms); getScreenSizeName(screenSize.string(), ¶ms); - getScreenLayoutName(screenLayout.string(), ¶ms); getVersionName(version.string(), ¶ms); return params; } diff --git a/tools/aapt/AaptAssets.h b/tools/aapt/AaptAssets.h index e8c739558a6bd..57243496f12d8 100644 --- a/tools/aapt/AaptAssets.h +++ b/tools/aapt/AaptAssets.h @@ -30,6 +30,8 @@ enum { AXIS_MNC, AXIS_LANGUAGE, AXIS_REGION, + AXIS_SCREENLAYOUTSIZE, + AXIS_SCREENLAYOUTLONG, AXIS_ORIENTATION, AXIS_DENSITY, AXIS_TOUCHSCREEN, @@ -37,7 +39,6 @@ enum { AXIS_KEYBOARD, AXIS_NAVIGATION, AXIS_SCREENSIZE, - AXIS_SCREENLAYOUT, AXIS_VERSION }; @@ -56,6 +57,8 @@ public: String8 mnc; String8 locale; String8 vendor; + String8 screenLayoutSize; + String8 screenLayoutLong; String8 orientation; String8 density; String8 touchscreen; @@ -63,7 +66,6 @@ public: String8 keyboard; String8 navigation; String8 screenSize; - String8 screenLayout; String8 version; bool initFromDirName(const char* dir, String8* resType); @@ -73,6 +75,8 @@ public: static bool getMccName(const char* name, ResTable_config* out = NULL); static bool getMncName(const char* name, ResTable_config* out = NULL); static bool getLocaleName(const char* name, ResTable_config* out = NULL); + static bool getScreenLayoutSizeName(const char* name, ResTable_config* out = NULL); + static bool getScreenLayoutLongName(const char* name, ResTable_config* out = NULL); static bool getOrientationName(const char* name, ResTable_config* out = NULL); static bool getDensityName(const char* name, ResTable_config* out = NULL); static bool getTouchscreenName(const char* name, ResTable_config* out = NULL); @@ -80,7 +84,6 @@ public: static bool getKeyboardName(const char* name, ResTable_config* out = NULL); static bool getNavigationName(const char* name, ResTable_config* out = NULL); static bool getScreenSizeName(const char* name, ResTable_config* out = NULL); - static bool getScreenLayoutName(const char* name, ResTable_config* out = NULL); static bool getVersionName(const char* name, ResTable_config* out = NULL); int compare(const AaptGroupEntry& o) const;