summaryrefslogtreecommitdiffstats
path: root/core/java/android/content/res
diff options
context:
space:
mode:
authorFabrice Di Meglio <fdimeglio@google.com>2011-06-09 20:20:36 -0700
committerFabrice Di Meglio <fdimeglio@google.com>2011-06-09 20:24:43 -0700
commit7a736fbf69dd6f03db968d7d8182024eebc0e508 (patch)
treede97e7654a3249a1ec8a8713e806e7ea0400fcc6 /core/java/android/content/res
parent6b6091a14032c02ce2ba5600a651166ac0102290 (diff)
downloadframeworks_base-7a736fbf69dd6f03db968d7d8182024eebc0e508.zip
frameworks_base-7a736fbf69dd6f03db968d7d8182024eebc0e508.tar.gz
frameworks_base-7a736fbf69dd6f03db968d7d8182024eebc0e508.tar.bz2
Update Configuration for renaming and fixes
- rename layoutDirection to textLayoutDirection - rename constants for being clear that they cannot be used (work in progress) - fix a few issues concerning default switch case and relation to Locale Change-Id: Icfe9a9b5c0d1c0e28e5a893549b437fc4fa5df82
Diffstat (limited to 'core/java/android/content/res')
-rw-r--r--core/java/android/content/res/Configuration.java50
1 files changed, 26 insertions, 24 deletions
diff --git a/core/java/android/content/res/Configuration.java b/core/java/android/content/res/Configuration.java
index 906a564..9bd45d3 100644
--- a/core/java/android/content/res/Configuration.java
+++ b/core/java/android/content/res/Configuration.java
@@ -277,24 +277,24 @@ public final class Configuration implements Parcelable, Comparable<Configuration
public int compatSmallestScreenWidthDp;
/**
- * @hide
+ * @hide Do not use. Implementation not finished.
*/
- public static final int LAYOUT_DIRECTION_UNDEFINED = -1;
+ public static final int TEXT_LAYOUT_DIRECTION_UNDEFINED_DO_NOT_USE = -1;
/**
- * @hide
+ * @hide Do not use. Implementation not finished.
*/
- public static final int LAYOUT_DIRECTION_LTR = 0;
+ public static final int TEXT_LAYOUT_DIRECTION_LTR_DO_NOT_USE = 0;
/**
- * @hide
+ * @hide Do not use. Implementation not finished.
*/
- public static final int LAYOUT_DIRECTION_RTL = 1;
+ public static final int TEXT_LAYOUT_DIRECTION_RTL_DO_NOT_USE = 1;
/**
- * @hide The layout direction associated to the current Locale
+ * @hide The text layout direction associated to the current Locale
*/
- public int layoutDirection;
+ public int textLayoutDirection;
/**
* @hide Internal book-keeping.
@@ -322,7 +322,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
mnc = o.mnc;
if (o.locale != null) {
locale = (Locale) o.locale.clone();
- layoutDirection = o.layoutDirection;
+ textLayoutDirection = o.textLayoutDirection;
}
userSetLocale = o.userSetLocale;
touchscreen = o.touchscreen;
@@ -358,6 +358,11 @@ public final class Configuration implements Parcelable, Comparable<Configuration
} else {
sb.append(" (no locale)");
}
+ switch (textLayoutDirection) {
+ case TEXT_LAYOUT_DIRECTION_UNDEFINED_DO_NOT_USE: sb.append(" ?layoutdir"); break;
+ case TEXT_LAYOUT_DIRECTION_RTL_DO_NOT_USE: sb.append(" rtl"); break;
+ default: sb.append(" layoutdir="); sb.append(textLayoutDirection); break;
+ }
if (smallestScreenWidthDp != SMALLEST_SCREEN_WIDTH_DP_UNDEFINED) {
sb.append(" sw"); sb.append(smallestScreenWidthDp); sb.append("dp");
} else {
@@ -450,11 +455,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
case NAVIGATIONHIDDEN_YES: sb.append("/h"); break;
default: sb.append("/"); sb.append(navigationHidden); break;
}
- switch (layoutDirection) {
- case LAYOUT_DIRECTION_UNDEFINED: sb.append(" ?layoutdir"); break;
- case LAYOUT_DIRECTION_LTR: sb.append(" ltr"); break;
- case LAYOUT_DIRECTION_RTL: sb.append(" rtl"); break;
- }
if (seq != 0) {
sb.append(" s.");
sb.append(seq);
@@ -483,8 +483,8 @@ public final class Configuration implements Parcelable, Comparable<Configuration
screenWidthDp = compatScreenWidthDp = SCREEN_WIDTH_DP_UNDEFINED;
screenHeightDp = compatScreenHeightDp = SCREEN_HEIGHT_DP_UNDEFINED;
smallestScreenWidthDp = compatSmallestScreenWidthDp = SMALLEST_SCREEN_WIDTH_DP_UNDEFINED;
+ textLayoutDirection = TEXT_LAYOUT_DIRECTION_LTR_DO_NOT_USE;
seq = 0;
- layoutDirection = LAYOUT_DIRECTION_LTR;
}
/** {@hide} */
@@ -519,7 +519,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
changed |= ActivityInfo.CONFIG_LOCALE;
locale = delta.locale != null
? (Locale) delta.locale.clone() : null;
- layoutDirection = getLayoutDirectionFromLocale(locale);
+ textLayoutDirection = getLayoutDirectionFromLocale(locale);
}
if (delta.userSetLocale && (!userSetLocale || ((changed & ActivityInfo.CONFIG_LOCALE) != 0)))
{
@@ -611,23 +611,25 @@ public final class Configuration implements Parcelable, Comparable<Configuration
/**
* Return the layout direction for a given Locale
* @param locale the Locale for which we want the layout direction. Can be null.
- * @return the layout direction. This may be one of {@link #LAYOUT_DIRECTION_UNDEFINED},
- * {@link #LAYOUT_DIRECTION_LTR} or {@link #LAYOUT_DIRECTION_RTL}.
+ * @return the layout direction. This may be one of:
+ * {@link #TEXT_LAYOUT_DIRECTION_UNDEFINED_DO_NOT_USE} or
+ * {@link #TEXT_LAYOUT_DIRECTION_LTR_DO_NOT_USE} or
+ * {@link #TEXT_LAYOUT_DIRECTION_RTL_DO_NOT_USE}.
*
* @hide
*/
public static int getLayoutDirectionFromLocale(Locale locale) {
- if (locale == null || locale.equals(Locale.ROOT)) return LAYOUT_DIRECTION_UNDEFINED;
+ if (locale == null || locale.equals(Locale.ROOT)) return TEXT_LAYOUT_DIRECTION_UNDEFINED_DO_NOT_USE;
// Be careful: this code will need to be changed when vertical scripts will be supported
// OR if ICU4C is updated to have the "likelySubtags" file
switch(Character.getDirectionality(locale.getDisplayName(locale).charAt(0))) {
case Character.DIRECTIONALITY_LEFT_TO_RIGHT:
- return LAYOUT_DIRECTION_LTR;
+ return TEXT_LAYOUT_DIRECTION_LTR_DO_NOT_USE;
case Character.DIRECTIONALITY_RIGHT_TO_LEFT:
case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
- return LAYOUT_DIRECTION_RTL;
+ return TEXT_LAYOUT_DIRECTION_RTL_DO_NOT_USE;
default:
- return LAYOUT_DIRECTION_UNDEFINED;
+ return TEXT_LAYOUT_DIRECTION_UNDEFINED_DO_NOT_USE;
}
}
@@ -810,7 +812,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
dest.writeInt(compatScreenWidthDp);
dest.writeInt(compatScreenHeightDp);
dest.writeInt(compatSmallestScreenWidthDp);
- dest.writeInt(layoutDirection);
+ dest.writeInt(textLayoutDirection);
dest.writeInt(seq);
}
@@ -838,7 +840,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
compatScreenWidthDp = source.readInt();
compatScreenHeightDp = source.readInt();
compatSmallestScreenWidthDp = source.readInt();
- layoutDirection = source.readInt();
+ textLayoutDirection = source.readInt();
seq = source.readInt();
}