diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2011-06-16 14:41:50 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-06-16 14:41:50 -0700 |
commit | c1f9486a3ebff71a686ed6ae89e55ec7df8e16ba (patch) | |
tree | 3d948ebc359b32e7e63e8566f41fc1a02fb88926 | |
parent | b47f2f9533ec76be0228e53959aa3c93d4e1c355 (diff) | |
parent | c01924f156710e0c92bef13ec0b1a1e057b793d1 (diff) | |
download | frameworks_base-c1f9486a3ebff71a686ed6ae89e55ec7df8e16ba.zip frameworks_base-c1f9486a3ebff71a686ed6ae89e55ec7df8e16ba.tar.gz frameworks_base-c1f9486a3ebff71a686ed6ae89e55ec7df8e16ba.tar.bz2 |
Merge "Update getLayoutDirectionFromLocale() for using ICU"
-rw-r--r-- | core/java/android/util/LocaleUtil.java | 13 | ||||
-rw-r--r-- | core/tests/coretests/src/android/util/LocaleUtilTest.java | 4 |
2 files changed, 3 insertions, 14 deletions
diff --git a/core/java/android/util/LocaleUtil.java b/core/java/android/util/LocaleUtil.java index e767a85..74a930f 100644 --- a/core/java/android/util/LocaleUtil.java +++ b/core/java/android/util/LocaleUtil.java @@ -67,17 +67,8 @@ public class LocaleUtil { return TEXT_LAYOUT_DIRECTION_UNDEFINED_DO_NOT_USE; } - final String localeWithSubtags = ICU.addLikelySubtags(locale.toString()); - if (localeWithSubtags == null) return getLayoutDirectionFromFirstChar(locale); - - // Need to check if we can extract the script subtag. For example, "Latn" in "en_Latn_US" - if (localeWithSubtags.length() <= 7 - || localeWithSubtags.charAt(2) != UNDERSCORE_CHAR - || localeWithSubtags.charAt(7) != UNDERSCORE_CHAR) { - return getLayoutDirectionFromFirstChar(locale); - } - // Extract the script subtag - final String scriptSubtag = localeWithSubtags.substring(3, 7); + final String scriptSubtag = ICU.getScript(ICU.addLikelySubtags(locale.toString())); + if (scriptSubtag == null) return getLayoutDirectionFromFirstChar(locale); if (scriptSubtag.equalsIgnoreCase(ARAB_SCRIPT_SUBTAG) || scriptSubtag.equalsIgnoreCase(HEBR_SCRIPT_SUBTAG)) { diff --git a/core/tests/coretests/src/android/util/LocaleUtilTest.java b/core/tests/coretests/src/android/util/LocaleUtilTest.java index 5aa99c1..203781f 100644 --- a/core/tests/coretests/src/android/util/LocaleUtilTest.java +++ b/core/tests/coretests/src/android/util/LocaleUtilTest.java @@ -18,14 +18,12 @@ package android.util; import java.util.Locale; -import android.content.res.Configuration; import android.test.AndroidTestCase; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetNew; -import static android.util.LocaleUtil.TEXT_LAYOUT_DIRECTION_UNDEFINED_DO_NOT_USE; import static android.util.LocaleUtil.TEXT_LAYOUT_DIRECTION_LTR_DO_NOT_USE; -import static android.util.LocaleUtil.TEXT_LAYOUT_DIRECTION_RTL_DO_NOT_USE; +import static android.util.LocaleUtil.TEXT_LAYOUT_DIRECTION_UNDEFINED_DO_NOT_USE; public class LocaleUtilTest extends AndroidTestCase { |