Loading api/current.txt +10 −0 Original line number Diff line number Diff line Loading @@ -6250,6 +6250,7 @@ package android.content.pm { field public static final int CONFIG_FONT_SCALE = 1073741824; // 0x40000000 field public static final int CONFIG_KEYBOARD = 16; // 0x10 field public static final int CONFIG_KEYBOARD_HIDDEN = 32; // 0x20 field public static final int CONFIG_LAYOUT_DIRECTION = 8192; // 0x2000 field public static final int CONFIG_LOCALE = 4; // 0x4 field public static final int CONFIG_MCC = 1; // 0x1 field public static final int CONFIG_MNC = 2; // 0x2 Loading Loading @@ -6852,9 +6853,12 @@ package android.content.res { method public int describeContents(); method public int diff(android.content.res.Configuration); method public boolean equals(android.content.res.Configuration); method public int getLayoutDirection(); method public boolean isLayoutSizeAtLeast(int); method public static boolean needNewResources(int, int); method public void readFromParcel(android.os.Parcel); method public void setLayoutDirection(java.util.Locale); method public void setLocale(java.util.Locale); method public void setTo(android.content.res.Configuration); method public void setToDefaults(); method public int updateFrom(android.content.res.Configuration); Loading Loading @@ -6883,6 +6887,11 @@ package android.content.res { field public static final int ORIENTATION_PORTRAIT = 1; // 0x1 field public static final deprecated int ORIENTATION_SQUARE = 3; // 0x3 field public static final int ORIENTATION_UNDEFINED = 0; // 0x0 field public static final int SCREENLAYOUT_LAYOUTDIR_LTR = 64; // 0x40 field public static final int SCREENLAYOUT_LAYOUTDIR_MASK = 192; // 0xc0 field public static final int SCREENLAYOUT_LAYOUTDIR_RTL = 128; // 0x80 field public static final int SCREENLAYOUT_LAYOUTDIR_SHIFT = 6; // 0x6 field public static final int SCREENLAYOUT_LAYOUTDIR_UNDEFINED = 0; // 0x0 field public static final int SCREENLAYOUT_LONG_MASK = 48; // 0x30 field public static final int SCREENLAYOUT_LONG_NO = 16; // 0x10 field public static final int SCREENLAYOUT_LONG_UNDEFINED = 0; // 0x0 Loading @@ -6893,6 +6902,7 @@ package android.content.res { field public static final int SCREENLAYOUT_SIZE_SMALL = 1; // 0x1 field public static final int SCREENLAYOUT_SIZE_UNDEFINED = 0; // 0x0 field public static final int SCREENLAYOUT_SIZE_XLARGE = 4; // 0x4 field public static final int SCREENLAYOUT_UNDEFINED = 0; // 0x0 field public static final int SCREEN_HEIGHT_DP_UNDEFINED = 0; // 0x0 field public static final int SCREEN_WIDTH_DP_UNDEFINED = 0; // 0x0 field public static final int SMALLEST_SCREEN_WIDTH_DP_UNDEFINED = 0; // 0x0 core/java/android/content/pm/ActivityInfo.java +10 −2 Original line number Diff line number Diff line Loading @@ -370,6 +370,12 @@ public class ActivityInfo extends ComponentInfo * {@link android.R.attr#configChanges} attribute. */ public static final int CONFIG_DENSITY = 0x1000; /** * Bit in {@link #configChanges} that indicates that the activity * can itself handle the change to layout direction. Set from the * {@link android.R.attr#configChanges} attribute. */ public static final int CONFIG_LAYOUT_DIRECTION = 0x2000; /** * Bit in {@link #configChanges} that indicates that the activity * can itself handle changes to the font scaling factor. Set from the Loading Loading @@ -398,6 +404,7 @@ public class ActivityInfo extends ComponentInfo 0x0200, // SCREEN SIZE 0x2000, // SMALLEST SCREEN SIZE 0x0100, // DENSITY 0x4000, // LAYOUT DIRECTION }; /** @hide * Convert Java change bits to native. Loading Loading @@ -434,8 +441,9 @@ public class ActivityInfo extends ComponentInfo * {@link #CONFIG_MCC}, {@link #CONFIG_MNC}, * {@link #CONFIG_LOCALE}, {@link #CONFIG_TOUCHSCREEN}, * {@link #CONFIG_KEYBOARD}, {@link #CONFIG_NAVIGATION}, * {@link #CONFIG_ORIENTATION}, and {@link #CONFIG_SCREEN_LAYOUT}. Set from the * {@link android.R.attr#configChanges} attribute. * {@link #CONFIG_ORIENTATION}, {@link #CONFIG_SCREEN_LAYOUT} and * {@link #CONFIG_LAYOUT_DIRECTION}. Set from the {@link android.R.attr#configChanges} * attribute. */ public int configChanges; Loading core/java/android/content/res/Configuration.java +100 −23 Original line number Diff line number Diff line Loading @@ -126,6 +126,24 @@ public final class Configuration implements Parcelable, Comparable<Configuration * resource qualifier. */ public static final int SCREENLAYOUT_LONG_YES = 0x20; /** Constant for {@link #screenLayout}: bits that encode the layout direction. */ public static final int SCREENLAYOUT_LAYOUTDIR_MASK = 0xC0; /** Constant for {@link #screenLayout}: bits shift to get the layout direction. */ public static final int SCREENLAYOUT_LAYOUTDIR_SHIFT = 6; /** Constant for {@link #screenLayout}: a {@link #SCREENLAYOUT_LAYOUTDIR_MASK} * value indicating that no layout dir has been set. */ public static final int SCREENLAYOUT_LAYOUTDIR_UNDEFINED = 0x00; /** Constant for {@link #screenLayout}: a {@link #SCREENLAYOUT_LAYOUTDIR_MASK} * value indicating that a layout dir has been set to LTR. */ public static final int SCREENLAYOUT_LAYOUTDIR_LTR = 0x01 << SCREENLAYOUT_LAYOUTDIR_SHIFT; /** Constant for {@link #screenLayout}: a {@link #SCREENLAYOUT_LAYOUTDIR_MASK} * value indicating that a layout dir has been set to RTL. */ public static final int SCREENLAYOUT_LAYOUTDIR_RTL = 0x02 << SCREENLAYOUT_LAYOUTDIR_SHIFT; /** Constant for {@link #screenLayout}: a value indicating that screenLayout is undefined */ public static final int SCREENLAYOUT_UNDEFINED = SCREENLAYOUT_SIZE_UNDEFINED | SCREENLAYOUT_LONG_UNDEFINED | SCREENLAYOUT_LAYOUTDIR_UNDEFINED; /** * Special flag we generate to indicate that the screen layout requires * us to use a compatibility mode for apps that are not modern layout Loading @@ -146,6 +164,10 @@ public final class Configuration implements Parcelable, Comparable<Configuration * is wider/taller than normal. They may be one of * {@link #SCREENLAYOUT_LONG_NO} or {@link #SCREENLAYOUT_LONG_YES}. * * <p>The {@link #SCREENLAYOUT_LAYOUTDIR_MASK} defines whether the screen layout * is either LTR or RTL. They may be one of * {@link #SCREENLAYOUT_LAYOUTDIR_LTR} or {@link #SCREENLAYOUT_LAYOUTDIR_RTL}. * * <p>See <a href="{@docRoot}guide/practices/screens_support.html">Supporting * Multiple Screens</a> for more information. */ Loading Loading @@ -441,11 +463,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration /** @hide Hack to get this information from WM to app running in compat mode. */ public int compatSmallestScreenWidthDp; /** * @hide The layout direction associated to the current Locale */ public int layoutDirection; /** * @hide Internal book-keeping. */ Loading @@ -472,7 +489,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration mnc = o.mnc; if (o.locale != null) { locale = (Locale) o.locale.clone(); layoutDirection = o.layoutDirection; } userSetLocale = o.userSetLocale; touchscreen = o.touchscreen; Loading Loading @@ -517,10 +533,13 @@ public final class Configuration implements Parcelable, Comparable<Configuration } else { sb.append(" ?locale"); } switch (layoutDirection) { case View.LAYOUT_DIRECTION_LTR: /* ltr not interesting */ break; case View.LAYOUT_DIRECTION_RTL: sb.append(" rtl"); break; default: sb.append(" layoutDir="); sb.append(layoutDirection); break; int layoutDir = (screenLayout&SCREENLAYOUT_LAYOUTDIR_MASK); switch (layoutDir) { case SCREENLAYOUT_LAYOUTDIR_UNDEFINED: sb.append(" ?layoutDir"); break; case SCREENLAYOUT_LAYOUTDIR_LTR: sb.append(" ltr"); break; case SCREENLAYOUT_LAYOUTDIR_RTL: sb.append(" rtl"); break; default: sb.append(" layoutDir="); sb.append(layoutDir >> SCREENLAYOUT_LAYOUTDIR_SHIFT); break; } if (smallestScreenWidthDp != SMALLEST_SCREEN_WIDTH_DP_UNDEFINED) { sb.append(" sw"); sb.append(smallestScreenWidthDp); sb.append("dp"); Loading Loading @@ -643,13 +662,12 @@ public final class Configuration implements Parcelable, Comparable<Configuration navigation = NAVIGATION_UNDEFINED; navigationHidden = NAVIGATIONHIDDEN_UNDEFINED; orientation = ORIENTATION_UNDEFINED; screenLayout = SCREENLAYOUT_SIZE_UNDEFINED; screenLayout = SCREENLAYOUT_UNDEFINED; uiMode = UI_MODE_TYPE_UNDEFINED; screenWidthDp = compatScreenWidthDp = SCREEN_WIDTH_DP_UNDEFINED; screenHeightDp = compatScreenHeightDp = SCREEN_HEIGHT_DP_UNDEFINED; smallestScreenWidthDp = compatSmallestScreenWidthDp = SMALLEST_SCREEN_WIDTH_DP_UNDEFINED; densityDpi = DENSITY_DPI_UNDEFINED; layoutDirection = View.LAYOUT_DIRECTION_LTR; seq = 0; } Loading Loading @@ -685,7 +703,11 @@ public final class Configuration implements Parcelable, Comparable<Configuration changed |= ActivityInfo.CONFIG_LOCALE; locale = delta.locale != null ? (Locale) delta.locale.clone() : null; layoutDirection = LocaleUtil.getLayoutDirectionFromLocale(locale); // If locale has changed, then layout direction is also changed ... changed |= ActivityInfo.CONFIG_LAYOUT_DIRECTION; // ... and we need to update the layout direction (represented by the first // 2 most significant bits in screenLayout). setLayoutDirection(locale); } if (delta.userSetLocale && (!userSetLocale || ((changed & ActivityInfo.CONFIG_LOCALE) != 0))) { Loading Loading @@ -727,11 +749,18 @@ public final class Configuration implements Parcelable, Comparable<Configuration changed |= ActivityInfo.CONFIG_ORIENTATION; orientation = delta.orientation; } if (delta.screenLayout != SCREENLAYOUT_SIZE_UNDEFINED && screenLayout != delta.screenLayout) { if (getScreenLayoutNoDirection(delta.screenLayout) != (SCREENLAYOUT_SIZE_UNDEFINED | SCREENLAYOUT_LONG_UNDEFINED) && (getScreenLayoutNoDirection(screenLayout) != getScreenLayoutNoDirection(delta.screenLayout))) { changed |= ActivityInfo.CONFIG_SCREEN_LAYOUT; // We need to preserve the previous layout dir bits if they were defined if ((delta.screenLayout&SCREENLAYOUT_LAYOUTDIR_MASK) == 0) { screenLayout = (screenLayout&SCREENLAYOUT_LAYOUTDIR_MASK)|delta.screenLayout; } else { screenLayout = delta.screenLayout; } } if (delta.uiMode != (UI_MODE_TYPE_UNDEFINED|UI_MODE_NIGHT_UNDEFINED) && uiMode != delta.uiMode) { changed |= ActivityInfo.CONFIG_UI_MODE; Loading Loading @@ -771,7 +800,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration if (delta.compatSmallestScreenWidthDp != SMALLEST_SCREEN_WIDTH_DP_UNDEFINED) { compatSmallestScreenWidthDp = delta.compatSmallestScreenWidthDp; } if (delta.seq != 0) { seq = delta.seq; } Loading Loading @@ -807,6 +835,8 @@ public final class Configuration implements Parcelable, Comparable<Configuration * PackageManager.ActivityInfo.CONFIG_SCREEN_SIZE}, or * {@link android.content.pm.ActivityInfo#CONFIG_SMALLEST_SCREEN_SIZE * PackageManager.ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE}. * {@link android.content.pm.ActivityInfo#CONFIG_LAYOUT_DIRECTION * PackageManager.ActivityInfo.CONFIG_LAYOUT_DIRECTION}. */ public int diff(Configuration delta) { int changed = 0; Loading @@ -822,6 +852,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration if (delta.locale != null && (locale == null || !locale.equals(delta.locale))) { changed |= ActivityInfo.CONFIG_LOCALE; changed |= ActivityInfo.CONFIG_LAYOUT_DIRECTION; } if (delta.touchscreen != TOUCHSCREEN_UNDEFINED && touchscreen != delta.touchscreen) { Loading Loading @@ -851,8 +882,10 @@ public final class Configuration implements Parcelable, Comparable<Configuration && orientation != delta.orientation) { changed |= ActivityInfo.CONFIG_ORIENTATION; } if (delta.screenLayout != SCREENLAYOUT_SIZE_UNDEFINED && screenLayout != delta.screenLayout) { if (getScreenLayoutNoDirection(delta.screenLayout) != (SCREENLAYOUT_SIZE_UNDEFINED | SCREENLAYOUT_LONG_UNDEFINED) && getScreenLayoutNoDirection(screenLayout) != getScreenLayoutNoDirection(delta.screenLayout)) { changed |= ActivityInfo.CONFIG_SCREEN_LAYOUT; } if (delta.uiMode != (UI_MODE_TYPE_UNDEFINED|UI_MODE_NIGHT_UNDEFINED) Loading Loading @@ -963,7 +996,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration dest.writeInt(compatScreenWidthDp); dest.writeInt(compatScreenHeightDp); dest.writeInt(compatSmallestScreenWidthDp); dest.writeInt(layoutDirection); dest.writeInt(seq); } Loading Loading @@ -992,7 +1024,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration compatScreenWidthDp = source.readInt(); compatScreenHeightDp = source.readInt(); compatSmallestScreenWidthDp = source.readInt(); layoutDirection = source.readInt(); seq = source.readInt(); } Loading Loading @@ -1100,4 +1131,50 @@ public final class Configuration implements Parcelable, Comparable<Configuration result = 31 * result + densityDpi; return result; } /** * Set the locale. This is the preferred way for setting up the locale (instead of using the * direct accessor). This will also set the userLocale and layout direction according to * the locale. * * @param loc The locale. Can be null. */ public void setLocale(Locale loc) { locale = loc; userSetLocale = true; setLayoutDirection(locale); } /** * Return the layout direction. Will be either {@link View#LAYOUT_DIRECTION_LTR} or * {@link View#LAYOUT_DIRECTION_RTL}. * * @return the layout direction */ public int getLayoutDirection() { // We need to substract one here as the configuration values are using "0" as undefined thus // having LRT set to "1" and RTL set to "2" return ((screenLayout&SCREENLAYOUT_LAYOUTDIR_MASK) >> SCREENLAYOUT_LAYOUTDIR_SHIFT) - 1; } /** * Set the layout direction from the Locale. * * @param locale The Locale. If null will set the layout direction to * {@link View#LAYOUT_DIRECTION_LTR}. If not null will set it to the layout direction * corresponding to the Locale. * * @see {@link View#LAYOUT_DIRECTION_LTR} and {@link View#LAYOUT_DIRECTION_RTL} */ public void setLayoutDirection(Locale locale) { // There is a "1" difference between the configuration values for // layout direction and View constants for layout direction, just add "1". final int layoutDirection = 1 + LocaleUtil.getLayoutDirectionFromLocale(locale); screenLayout = (screenLayout&~SCREENLAYOUT_LAYOUTDIR_MASK)| (layoutDirection << SCREENLAYOUT_LAYOUTDIR_SHIFT); } private static int getScreenLayoutNoDirection(int screenLayout) { return screenLayout&~SCREENLAYOUT_LAYOUTDIR_MASK; } } core/java/android/content/res/Resources.java +2 −0 Original line number Diff line number Diff line Loading @@ -1444,12 +1444,14 @@ public class Resources { } if (mTmpConfig.locale == null) { mTmpConfig.locale = Locale.getDefault(); mTmpConfig.setLayoutDirection(mTmpConfig.locale); } configChanges = mConfiguration.updateFrom(mTmpConfig); configChanges = ActivityInfo.activityInfoConfigToNative(configChanges); } if (mConfiguration.locale == null) { mConfiguration.locale = Locale.getDefault(); mConfiguration.setLayoutDirection(mConfiguration.locale); } if (mConfiguration.densityDpi != Configuration.DENSITY_DPI_UNDEFINED) { mMetrics.densityDpi = mConfiguration.densityDpi; Loading core/java/android/widget/Toast.java +1 −1 Original line number Diff line number Diff line Loading @@ -379,7 +379,7 @@ public class Toast { // We can resolve the Gravity here by using the Locale for getting // the layout direction final Configuration config = mView.getContext().getResources().getConfiguration(); final int gravity = Gravity.getAbsoluteGravity(mGravity, config.layoutDirection); final int gravity = Gravity.getAbsoluteGravity(mGravity, config.getLayoutDirection()); mParams.gravity = gravity; if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.FILL_HORIZONTAL) { mParams.horizontalWeight = 1.0f; Loading Loading
api/current.txt +10 −0 Original line number Diff line number Diff line Loading @@ -6250,6 +6250,7 @@ package android.content.pm { field public static final int CONFIG_FONT_SCALE = 1073741824; // 0x40000000 field public static final int CONFIG_KEYBOARD = 16; // 0x10 field public static final int CONFIG_KEYBOARD_HIDDEN = 32; // 0x20 field public static final int CONFIG_LAYOUT_DIRECTION = 8192; // 0x2000 field public static final int CONFIG_LOCALE = 4; // 0x4 field public static final int CONFIG_MCC = 1; // 0x1 field public static final int CONFIG_MNC = 2; // 0x2 Loading Loading @@ -6852,9 +6853,12 @@ package android.content.res { method public int describeContents(); method public int diff(android.content.res.Configuration); method public boolean equals(android.content.res.Configuration); method public int getLayoutDirection(); method public boolean isLayoutSizeAtLeast(int); method public static boolean needNewResources(int, int); method public void readFromParcel(android.os.Parcel); method public void setLayoutDirection(java.util.Locale); method public void setLocale(java.util.Locale); method public void setTo(android.content.res.Configuration); method public void setToDefaults(); method public int updateFrom(android.content.res.Configuration); Loading Loading @@ -6883,6 +6887,11 @@ package android.content.res { field public static final int ORIENTATION_PORTRAIT = 1; // 0x1 field public static final deprecated int ORIENTATION_SQUARE = 3; // 0x3 field public static final int ORIENTATION_UNDEFINED = 0; // 0x0 field public static final int SCREENLAYOUT_LAYOUTDIR_LTR = 64; // 0x40 field public static final int SCREENLAYOUT_LAYOUTDIR_MASK = 192; // 0xc0 field public static final int SCREENLAYOUT_LAYOUTDIR_RTL = 128; // 0x80 field public static final int SCREENLAYOUT_LAYOUTDIR_SHIFT = 6; // 0x6 field public static final int SCREENLAYOUT_LAYOUTDIR_UNDEFINED = 0; // 0x0 field public static final int SCREENLAYOUT_LONG_MASK = 48; // 0x30 field public static final int SCREENLAYOUT_LONG_NO = 16; // 0x10 field public static final int SCREENLAYOUT_LONG_UNDEFINED = 0; // 0x0 Loading @@ -6893,6 +6902,7 @@ package android.content.res { field public static final int SCREENLAYOUT_SIZE_SMALL = 1; // 0x1 field public static final int SCREENLAYOUT_SIZE_UNDEFINED = 0; // 0x0 field public static final int SCREENLAYOUT_SIZE_XLARGE = 4; // 0x4 field public static final int SCREENLAYOUT_UNDEFINED = 0; // 0x0 field public static final int SCREEN_HEIGHT_DP_UNDEFINED = 0; // 0x0 field public static final int SCREEN_WIDTH_DP_UNDEFINED = 0; // 0x0 field public static final int SMALLEST_SCREEN_WIDTH_DP_UNDEFINED = 0; // 0x0
core/java/android/content/pm/ActivityInfo.java +10 −2 Original line number Diff line number Diff line Loading @@ -370,6 +370,12 @@ public class ActivityInfo extends ComponentInfo * {@link android.R.attr#configChanges} attribute. */ public static final int CONFIG_DENSITY = 0x1000; /** * Bit in {@link #configChanges} that indicates that the activity * can itself handle the change to layout direction. Set from the * {@link android.R.attr#configChanges} attribute. */ public static final int CONFIG_LAYOUT_DIRECTION = 0x2000; /** * Bit in {@link #configChanges} that indicates that the activity * can itself handle changes to the font scaling factor. Set from the Loading Loading @@ -398,6 +404,7 @@ public class ActivityInfo extends ComponentInfo 0x0200, // SCREEN SIZE 0x2000, // SMALLEST SCREEN SIZE 0x0100, // DENSITY 0x4000, // LAYOUT DIRECTION }; /** @hide * Convert Java change bits to native. Loading Loading @@ -434,8 +441,9 @@ public class ActivityInfo extends ComponentInfo * {@link #CONFIG_MCC}, {@link #CONFIG_MNC}, * {@link #CONFIG_LOCALE}, {@link #CONFIG_TOUCHSCREEN}, * {@link #CONFIG_KEYBOARD}, {@link #CONFIG_NAVIGATION}, * {@link #CONFIG_ORIENTATION}, and {@link #CONFIG_SCREEN_LAYOUT}. Set from the * {@link android.R.attr#configChanges} attribute. * {@link #CONFIG_ORIENTATION}, {@link #CONFIG_SCREEN_LAYOUT} and * {@link #CONFIG_LAYOUT_DIRECTION}. Set from the {@link android.R.attr#configChanges} * attribute. */ public int configChanges; Loading
core/java/android/content/res/Configuration.java +100 −23 Original line number Diff line number Diff line Loading @@ -126,6 +126,24 @@ public final class Configuration implements Parcelable, Comparable<Configuration * resource qualifier. */ public static final int SCREENLAYOUT_LONG_YES = 0x20; /** Constant for {@link #screenLayout}: bits that encode the layout direction. */ public static final int SCREENLAYOUT_LAYOUTDIR_MASK = 0xC0; /** Constant for {@link #screenLayout}: bits shift to get the layout direction. */ public static final int SCREENLAYOUT_LAYOUTDIR_SHIFT = 6; /** Constant for {@link #screenLayout}: a {@link #SCREENLAYOUT_LAYOUTDIR_MASK} * value indicating that no layout dir has been set. */ public static final int SCREENLAYOUT_LAYOUTDIR_UNDEFINED = 0x00; /** Constant for {@link #screenLayout}: a {@link #SCREENLAYOUT_LAYOUTDIR_MASK} * value indicating that a layout dir has been set to LTR. */ public static final int SCREENLAYOUT_LAYOUTDIR_LTR = 0x01 << SCREENLAYOUT_LAYOUTDIR_SHIFT; /** Constant for {@link #screenLayout}: a {@link #SCREENLAYOUT_LAYOUTDIR_MASK} * value indicating that a layout dir has been set to RTL. */ public static final int SCREENLAYOUT_LAYOUTDIR_RTL = 0x02 << SCREENLAYOUT_LAYOUTDIR_SHIFT; /** Constant for {@link #screenLayout}: a value indicating that screenLayout is undefined */ public static final int SCREENLAYOUT_UNDEFINED = SCREENLAYOUT_SIZE_UNDEFINED | SCREENLAYOUT_LONG_UNDEFINED | SCREENLAYOUT_LAYOUTDIR_UNDEFINED; /** * Special flag we generate to indicate that the screen layout requires * us to use a compatibility mode for apps that are not modern layout Loading @@ -146,6 +164,10 @@ public final class Configuration implements Parcelable, Comparable<Configuration * is wider/taller than normal. They may be one of * {@link #SCREENLAYOUT_LONG_NO} or {@link #SCREENLAYOUT_LONG_YES}. * * <p>The {@link #SCREENLAYOUT_LAYOUTDIR_MASK} defines whether the screen layout * is either LTR or RTL. They may be one of * {@link #SCREENLAYOUT_LAYOUTDIR_LTR} or {@link #SCREENLAYOUT_LAYOUTDIR_RTL}. * * <p>See <a href="{@docRoot}guide/practices/screens_support.html">Supporting * Multiple Screens</a> for more information. */ Loading Loading @@ -441,11 +463,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration /** @hide Hack to get this information from WM to app running in compat mode. */ public int compatSmallestScreenWidthDp; /** * @hide The layout direction associated to the current Locale */ public int layoutDirection; /** * @hide Internal book-keeping. */ Loading @@ -472,7 +489,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration mnc = o.mnc; if (o.locale != null) { locale = (Locale) o.locale.clone(); layoutDirection = o.layoutDirection; } userSetLocale = o.userSetLocale; touchscreen = o.touchscreen; Loading Loading @@ -517,10 +533,13 @@ public final class Configuration implements Parcelable, Comparable<Configuration } else { sb.append(" ?locale"); } switch (layoutDirection) { case View.LAYOUT_DIRECTION_LTR: /* ltr not interesting */ break; case View.LAYOUT_DIRECTION_RTL: sb.append(" rtl"); break; default: sb.append(" layoutDir="); sb.append(layoutDirection); break; int layoutDir = (screenLayout&SCREENLAYOUT_LAYOUTDIR_MASK); switch (layoutDir) { case SCREENLAYOUT_LAYOUTDIR_UNDEFINED: sb.append(" ?layoutDir"); break; case SCREENLAYOUT_LAYOUTDIR_LTR: sb.append(" ltr"); break; case SCREENLAYOUT_LAYOUTDIR_RTL: sb.append(" rtl"); break; default: sb.append(" layoutDir="); sb.append(layoutDir >> SCREENLAYOUT_LAYOUTDIR_SHIFT); break; } if (smallestScreenWidthDp != SMALLEST_SCREEN_WIDTH_DP_UNDEFINED) { sb.append(" sw"); sb.append(smallestScreenWidthDp); sb.append("dp"); Loading Loading @@ -643,13 +662,12 @@ public final class Configuration implements Parcelable, Comparable<Configuration navigation = NAVIGATION_UNDEFINED; navigationHidden = NAVIGATIONHIDDEN_UNDEFINED; orientation = ORIENTATION_UNDEFINED; screenLayout = SCREENLAYOUT_SIZE_UNDEFINED; screenLayout = SCREENLAYOUT_UNDEFINED; uiMode = UI_MODE_TYPE_UNDEFINED; screenWidthDp = compatScreenWidthDp = SCREEN_WIDTH_DP_UNDEFINED; screenHeightDp = compatScreenHeightDp = SCREEN_HEIGHT_DP_UNDEFINED; smallestScreenWidthDp = compatSmallestScreenWidthDp = SMALLEST_SCREEN_WIDTH_DP_UNDEFINED; densityDpi = DENSITY_DPI_UNDEFINED; layoutDirection = View.LAYOUT_DIRECTION_LTR; seq = 0; } Loading Loading @@ -685,7 +703,11 @@ public final class Configuration implements Parcelable, Comparable<Configuration changed |= ActivityInfo.CONFIG_LOCALE; locale = delta.locale != null ? (Locale) delta.locale.clone() : null; layoutDirection = LocaleUtil.getLayoutDirectionFromLocale(locale); // If locale has changed, then layout direction is also changed ... changed |= ActivityInfo.CONFIG_LAYOUT_DIRECTION; // ... and we need to update the layout direction (represented by the first // 2 most significant bits in screenLayout). setLayoutDirection(locale); } if (delta.userSetLocale && (!userSetLocale || ((changed & ActivityInfo.CONFIG_LOCALE) != 0))) { Loading Loading @@ -727,11 +749,18 @@ public final class Configuration implements Parcelable, Comparable<Configuration changed |= ActivityInfo.CONFIG_ORIENTATION; orientation = delta.orientation; } if (delta.screenLayout != SCREENLAYOUT_SIZE_UNDEFINED && screenLayout != delta.screenLayout) { if (getScreenLayoutNoDirection(delta.screenLayout) != (SCREENLAYOUT_SIZE_UNDEFINED | SCREENLAYOUT_LONG_UNDEFINED) && (getScreenLayoutNoDirection(screenLayout) != getScreenLayoutNoDirection(delta.screenLayout))) { changed |= ActivityInfo.CONFIG_SCREEN_LAYOUT; // We need to preserve the previous layout dir bits if they were defined if ((delta.screenLayout&SCREENLAYOUT_LAYOUTDIR_MASK) == 0) { screenLayout = (screenLayout&SCREENLAYOUT_LAYOUTDIR_MASK)|delta.screenLayout; } else { screenLayout = delta.screenLayout; } } if (delta.uiMode != (UI_MODE_TYPE_UNDEFINED|UI_MODE_NIGHT_UNDEFINED) && uiMode != delta.uiMode) { changed |= ActivityInfo.CONFIG_UI_MODE; Loading Loading @@ -771,7 +800,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration if (delta.compatSmallestScreenWidthDp != SMALLEST_SCREEN_WIDTH_DP_UNDEFINED) { compatSmallestScreenWidthDp = delta.compatSmallestScreenWidthDp; } if (delta.seq != 0) { seq = delta.seq; } Loading Loading @@ -807,6 +835,8 @@ public final class Configuration implements Parcelable, Comparable<Configuration * PackageManager.ActivityInfo.CONFIG_SCREEN_SIZE}, or * {@link android.content.pm.ActivityInfo#CONFIG_SMALLEST_SCREEN_SIZE * PackageManager.ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE}. * {@link android.content.pm.ActivityInfo#CONFIG_LAYOUT_DIRECTION * PackageManager.ActivityInfo.CONFIG_LAYOUT_DIRECTION}. */ public int diff(Configuration delta) { int changed = 0; Loading @@ -822,6 +852,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration if (delta.locale != null && (locale == null || !locale.equals(delta.locale))) { changed |= ActivityInfo.CONFIG_LOCALE; changed |= ActivityInfo.CONFIG_LAYOUT_DIRECTION; } if (delta.touchscreen != TOUCHSCREEN_UNDEFINED && touchscreen != delta.touchscreen) { Loading Loading @@ -851,8 +882,10 @@ public final class Configuration implements Parcelable, Comparable<Configuration && orientation != delta.orientation) { changed |= ActivityInfo.CONFIG_ORIENTATION; } if (delta.screenLayout != SCREENLAYOUT_SIZE_UNDEFINED && screenLayout != delta.screenLayout) { if (getScreenLayoutNoDirection(delta.screenLayout) != (SCREENLAYOUT_SIZE_UNDEFINED | SCREENLAYOUT_LONG_UNDEFINED) && getScreenLayoutNoDirection(screenLayout) != getScreenLayoutNoDirection(delta.screenLayout)) { changed |= ActivityInfo.CONFIG_SCREEN_LAYOUT; } if (delta.uiMode != (UI_MODE_TYPE_UNDEFINED|UI_MODE_NIGHT_UNDEFINED) Loading Loading @@ -963,7 +996,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration dest.writeInt(compatScreenWidthDp); dest.writeInt(compatScreenHeightDp); dest.writeInt(compatSmallestScreenWidthDp); dest.writeInt(layoutDirection); dest.writeInt(seq); } Loading Loading @@ -992,7 +1024,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration compatScreenWidthDp = source.readInt(); compatScreenHeightDp = source.readInt(); compatSmallestScreenWidthDp = source.readInt(); layoutDirection = source.readInt(); seq = source.readInt(); } Loading Loading @@ -1100,4 +1131,50 @@ public final class Configuration implements Parcelable, Comparable<Configuration result = 31 * result + densityDpi; return result; } /** * Set the locale. This is the preferred way for setting up the locale (instead of using the * direct accessor). This will also set the userLocale and layout direction according to * the locale. * * @param loc The locale. Can be null. */ public void setLocale(Locale loc) { locale = loc; userSetLocale = true; setLayoutDirection(locale); } /** * Return the layout direction. Will be either {@link View#LAYOUT_DIRECTION_LTR} or * {@link View#LAYOUT_DIRECTION_RTL}. * * @return the layout direction */ public int getLayoutDirection() { // We need to substract one here as the configuration values are using "0" as undefined thus // having LRT set to "1" and RTL set to "2" return ((screenLayout&SCREENLAYOUT_LAYOUTDIR_MASK) >> SCREENLAYOUT_LAYOUTDIR_SHIFT) - 1; } /** * Set the layout direction from the Locale. * * @param locale The Locale. If null will set the layout direction to * {@link View#LAYOUT_DIRECTION_LTR}. If not null will set it to the layout direction * corresponding to the Locale. * * @see {@link View#LAYOUT_DIRECTION_LTR} and {@link View#LAYOUT_DIRECTION_RTL} */ public void setLayoutDirection(Locale locale) { // There is a "1" difference between the configuration values for // layout direction and View constants for layout direction, just add "1". final int layoutDirection = 1 + LocaleUtil.getLayoutDirectionFromLocale(locale); screenLayout = (screenLayout&~SCREENLAYOUT_LAYOUTDIR_MASK)| (layoutDirection << SCREENLAYOUT_LAYOUTDIR_SHIFT); } private static int getScreenLayoutNoDirection(int screenLayout) { return screenLayout&~SCREENLAYOUT_LAYOUTDIR_MASK; } }
core/java/android/content/res/Resources.java +2 −0 Original line number Diff line number Diff line Loading @@ -1444,12 +1444,14 @@ public class Resources { } if (mTmpConfig.locale == null) { mTmpConfig.locale = Locale.getDefault(); mTmpConfig.setLayoutDirection(mTmpConfig.locale); } configChanges = mConfiguration.updateFrom(mTmpConfig); configChanges = ActivityInfo.activityInfoConfigToNative(configChanges); } if (mConfiguration.locale == null) { mConfiguration.locale = Locale.getDefault(); mConfiguration.setLayoutDirection(mConfiguration.locale); } if (mConfiguration.densityDpi != Configuration.DENSITY_DPI_UNDEFINED) { mMetrics.densityDpi = mConfiguration.densityDpi; Loading
core/java/android/widget/Toast.java +1 −1 Original line number Diff line number Diff line Loading @@ -379,7 +379,7 @@ public class Toast { // We can resolve the Gravity here by using the Locale for getting // the layout direction final Configuration config = mView.getContext().getResources().getConfiguration(); final int gravity = Gravity.getAbsoluteGravity(mGravity, config.layoutDirection); final int gravity = Gravity.getAbsoluteGravity(mGravity, config.getLayoutDirection()); mParams.gravity = gravity; if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.FILL_HORIZONTAL) { mParams.horizontalWeight = 1.0f; Loading