Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c4db95c0 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

First pass at reworking screen density/size APIs.

This changes the names of the directories in aapt, to what you see
in the list of DpiTest resources.  Also adds a new "long" configuration
for wide screens, which the platform sets appropriate, and introduces
a new kind of resizeability for not large but significantly larger
than normal screens which may have compatibility issues.
parent fe6f45c8
Loading
Loading
Loading
Loading
+81 −15
Original line number Diff line number Diff line
@@ -3386,17 +3386,6 @@
 visibility="public"
>
</field>
<field name="donut_resource_pad19"
 type="int"
 transient="false"
 volatile="false"
 value="16843405"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="donut_resource_pad2"
 type="int"
 transient="false"
@@ -6961,6 +6950,17 @@
 visibility="public"
>
</field>
<field name="resizeable"
 type="int"
 transient="false"
 volatile="false"
 value="16843405"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="resource"
 type="int"
 transient="false"
@@ -35507,6 +35507,17 @@
 visibility="public"
>
</field>
<field name="FLAG_RESIZEABLE_FOR_SCREENS"
 type="int"
 transient="false"
 volatile="false"
 value="4096"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="FLAG_SUPPORTS_LARGE_SCREENS"
 type="int"
 transient="false"
@@ -39810,7 +39821,51 @@
 visibility="public"
>
</field>
<field name="SCREENLAYOUT_LARGE"
<field name="SCREENLAYOUT_LONG_MASK"
 type="int"
 transient="false"
 volatile="false"
 value="48"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="SCREENLAYOUT_LONG_NO"
 type="int"
 transient="false"
 volatile="false"
 value="16"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="SCREENLAYOUT_LONG_UNDEFINED"
 type="int"
 transient="false"
 volatile="false"
 value="0"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="SCREENLAYOUT_LONG_YES"
 type="int"
 transient="false"
 volatile="false"
 value="32"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="SCREENLAYOUT_SIZE_LARGE"
 type="int"
 transient="false"
 volatile="false"
@@ -39821,7 +39876,18 @@
 visibility="public"
>
</field>
<field name="SCREENLAYOUT_NORMAL"
<field name="SCREENLAYOUT_SIZE_MASK"
 type="int"
 transient="false"
 volatile="false"
 value="15"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="SCREENLAYOUT_SIZE_NORMAL"
 type="int"
 transient="false"
 volatile="false"
@@ -39832,7 +39898,7 @@
 visibility="public"
>
</field>
<field name="SCREENLAYOUT_SMALL"
<field name="SCREENLAYOUT_SIZE_SMALL"
 type="int"
 transient="false"
 volatile="false"
@@ -39843,7 +39909,7 @@
 visibility="public"
>
</field>
<field name="SCREENLAYOUT_UNDEFINED"
<field name="SCREENLAYOUT_SIZE_UNDEFINED"
 type="int"
 transient="false"
 volatile="false"
+11 −3
Original line number Diff line number Diff line
@@ -160,13 +160,21 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     */
    public static final int FLAG_SUPPORTS_LARGE_SCREENS = 1<<11;
    
    /**
     * Value for {@link #flags}: true when the application knows how to adjust
     * its UI for different screen sizes.  Corresponds to
     * {@link android.R.styleable#AndroidManifestSupportsScreens_resizeable
     * android:resizeable}.
     */
    public static final int FLAG_RESIZEABLE_FOR_SCREENS = 1<<12;
    
    /**
     * Value for {@link #flags}: this is false if the application has set
     * its android:allowBackup to false, true otherwise.
     * 
     * {@hide}
     */
    public static final int FLAG_ALLOW_BACKUP = 1<<12;
    public static final int FLAG_ALLOW_BACKUP = 1<<13;
    
    /**
     * Indicates that the application supports any densities;
@@ -183,7 +191,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     * {@link #FLAG_ALLOW_CLEAR_USER_DATA}, {@link #FLAG_UPDATED_SYSTEM_APP},
     * {@link #FLAG_TEST_ONLY}, {@link #FLAG_SUPPORTS_SMALL_SCREENS},
     * {@link #FLAG_SUPPORTS_NORMAL_SCREENS},
     * {@link #FLAG_SUPPORTS_LARGE_SCREENS}.
     * {@link #FLAG_SUPPORTS_LARGE_SCREENS}, {@link #FLAG_RESIZEABLE_FOR_SCREENS}.
     */
    public int flags = 0;
    
@@ -400,7 +408,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     */
    public void disableCompatibilityMode() {
        flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
                FLAG_SUPPORTS_SMALL_SCREENS);
                FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS);
        supportsDensities = ANY_DENSITIES_ARRAY;
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -674,6 +674,7 @@ public class PackageParser {
        int supportsSmallScreens = 1;
        int supportsNormalScreens = 1;
        int supportsLargeScreens = 1;
        int resizeable = 1;
        
        int outerDepth = parser.getDepth();
        while ((type=parser.next()) != parser.END_DOCUMENT
@@ -883,6 +884,9 @@ public class PackageParser {
                supportsLargeScreens = sa.getInteger(
                        com.android.internal.R.styleable.AndroidManifestSupportsScreens_largeScreens,
                        supportsLargeScreens);
                resizeable = sa.getInteger(
                        com.android.internal.R.styleable.AndroidManifestSupportsScreens_resizeable,
                        supportsLargeScreens);

                sa.recycle();
                
@@ -969,6 +973,11 @@ public class PackageParser {
                        >= 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) {
+49 −9
Original line number Diff line number Diff line
@@ -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 <expandable /> or
     * 2) The screen size is same as (320 x 480) * density. 
     * 1) Application declares its expandable in manifest file using <supports-screens> 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 <supports-screens> 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;
        }
+36 −15
Original line number Diff line number Diff line
@@ -41,6 +41,39 @@ public final class Configuration implements Parcelable, Comparable<Configuration
     */
    public boolean userSetLocale;

    public static final int SCREENLAYOUT_SIZE_MASK = 0x0f;
    public static final int SCREENLAYOUT_SIZE_UNDEFINED = 0x00;
    public static final int SCREENLAYOUT_SIZE_SMALL = 0x01;
    public static final int SCREENLAYOUT_SIZE_NORMAL = 0x02;
    public static final int SCREENLAYOUT_SIZE_LARGE = 0x03;
    
    public static final int SCREENLAYOUT_LONG_MASK = 0x30;
    public static final int SCREENLAYOUT_LONG_UNDEFINED = 0x00;
    public static final int SCREENLAYOUT_LONG_NO = 0x10;
    public static final int SCREENLAYOUT_LONG_YES = 0x20;
    
    /**
     * Special flag we generate to indicate that the screen layout requires
     * us to use a compatibility mode for apps that are not modern layout
     * aware.
     * @hide
     */
    public static final int SCREENLAYOUT_COMPAT_NEEDED = 0x10000000;
    
    /**
     * Bit mask of overall layout of the screen.  Currently there are two
     * fields:
     * <p>The {@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}.
     * 
     * <p>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;
@@ -116,18 +149,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
     */
    public int orientation;
    
    public static final int SCREENLAYOUT_UNDEFINED = 0;
    public static final int SCREENLAYOUT_SMALL = 1;
    public static final int SCREENLAYOUT_NORMAL = 2;
    public static final int SCREENLAYOUT_LARGE = 3;
    
    /**
     * Overall layout of the screen.  May be one of
     * {@link #SCREENLAYOUT_SMALL}, {@link #SCREENLAYOUT_NORMAL},
     * or {@link #SCREENLAYOUT_LARGE}.
     */
    public int screenLayout;
    
    /**
     * Construct an invalid Configuration.  You must call {@link #setToDefaults}
     * for this object to be valid.  {@more}
@@ -198,7 +219,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
        hardKeyboardHidden = HARDKEYBOARDHIDDEN_UNDEFINED;
        navigation = NAVIGATION_UNDEFINED;
        orientation = ORIENTATION_UNDEFINED;
        screenLayout = SCREENLAYOUT_UNDEFINED;
        screenLayout = SCREENLAYOUT_SIZE_UNDEFINED;
    }

    /** {@hide} */
@@ -269,7 +290,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
            changed |= ActivityInfo.CONFIG_ORIENTATION;
            orientation = delta.orientation;
        }
        if (delta.screenLayout != SCREENLAYOUT_UNDEFINED
        if (delta.screenLayout != SCREENLAYOUT_SIZE_UNDEFINED
                && screenLayout != delta.screenLayout) {
            changed |= ActivityInfo.CONFIG_SCREEN_LAYOUT;
            screenLayout = delta.screenLayout;
@@ -342,7 +363,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
                && orientation != delta.orientation) {
            changed |= ActivityInfo.CONFIG_ORIENTATION;
        }
        if (delta.screenLayout != SCREENLAYOUT_UNDEFINED
        if (delta.screenLayout != SCREENLAYOUT_SIZE_UNDEFINED
                && screenLayout != delta.screenLayout) {
            changed |= ActivityInfo.CONFIG_SCREEN_LAYOUT;
        }
Loading