diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2011-08-24 18:26:14 -0700 |
---|---|---|
committer | Fabrice Di Meglio <fdimeglio@google.com> | 2011-08-25 18:43:37 -0700 |
commit | 7810b5f8cffb3c2c98fd0df579f4da5a9ac6cc73 (patch) | |
tree | 044c603b00cf5c90ee2f85d8f5884e58976d40f1 /core/java/android/text/TextDirectionHeuristics.java | |
parent | a646145c335ba821f01d9e4f8be2583eb9fd7266 (diff) | |
download | frameworks_base-7810b5f8cffb3c2c98fd0df579f4da5a9ac6cc73.zip frameworks_base-7810b5f8cffb3c2c98fd0df579f4da5a9ac6cc73.tar.gz frameworks_base-7810b5f8cffb3c2c98fd0df579f4da5a9ac6cc73.tar.bz2 |
Fix bug #5199577 TextView with android:password="true" is showing the "dots" on the left even if the password chars are RTL
- force TextView to LOCALE text heuristic when in "password" mode
- remove TEXT_LAYOUT_DIRECTION_UNKNOWN_DO_NOT_USE
- LocaleUtils.getLayoutDirectionFromLocale() returns "LTR" is locale is NULL or ROOT
Change-Id: I182c46aaf2d73c8b18967fffa230bfabec91ed06
Diffstat (limited to 'core/java/android/text/TextDirectionHeuristics.java')
-rw-r--r-- | core/java/android/text/TextDirectionHeuristics.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/core/java/android/text/TextDirectionHeuristics.java b/core/java/android/text/TextDirectionHeuristics.java index 6debc6b..18b4040 100644 --- a/core/java/android/text/TextDirectionHeuristics.java +++ b/core/java/android/text/TextDirectionHeuristics.java @@ -17,6 +17,10 @@ package android.text; +import java.util.Locale; + +import android.util.LocaleUtil; + /** * Some objects that implement TextDirectionHeuristic. * @hide @@ -75,6 +79,11 @@ public class TextDirectionHeuristics { public static final TextDirectionHeuristic CHARCOUNT_RTL = new TextDirectionHeuristicInternal(CharCount.INSTANCE_DEFAULT, true); + /** + * Force the paragraph direction to the Locale direction. Falls back to left to right. + */ + public static final TextDirectionHeuristic LOCALE = TextDirectionHeuristicLocale.INSTANCE; + private static enum TriState { TRUE, FALSE, UNKNOWN; } @@ -300,4 +309,23 @@ public class TextDirectionHeuristics { public static final float DEFAULT_THRESHOLD = 0.6f; public static final CharCount INSTANCE_DEFAULT = new CharCount(DEFAULT_THRESHOLD); } + + /** + * Algorithm that uses the Locale direction to force the direction of a paragraph. + */ + public static class TextDirectionHeuristicLocale extends TextDirectionHeuristicImpl { + + public TextDirectionHeuristicLocale() { + super(null); + } + + @Override + protected boolean defaultIsRtl() { + final int dir = LocaleUtil.getLayoutDirectionFromLocale(java.util.Locale.getDefault()); + return (dir == LocaleUtil.TEXT_LAYOUT_DIRECTION_RTL_DO_NOT_USE); + } + + public static final TextDirectionHeuristicLocale INSTANCE = + new TextDirectionHeuristicLocale(); + } } |