summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/android/text/TextDirectionHeuristics.java74
-rw-r--r--core/java/android/view/View.java14
-rw-r--r--core/java/android/widget/TextView.java4
-rw-r--r--core/tests/coretests/src/android/widget/TextViewTest.java34
4 files changed, 2 insertions, 124 deletions
diff --git a/core/java/android/text/TextDirectionHeuristics.java b/core/java/android/text/TextDirectionHeuristics.java
index 18b4040..e5c1e5b 100644
--- a/core/java/android/text/TextDirectionHeuristics.java
+++ b/core/java/android/text/TextDirectionHeuristics.java
@@ -62,24 +62,6 @@ public class TextDirectionHeuristics {
new TextDirectionHeuristicInternal(AnyStrong.INSTANCE_RTL, false);
/**
- * Examines only the strong directional non-format characters, and if either
- * left to right or right to left characters are 60% or more of this total,
- * determines that the direction follows the majority of characters. Falls
- * back to left to right if neither direction meets this threshold.
- */
- public static final TextDirectionHeuristic CHARCOUNT_LTR =
- new TextDirectionHeuristicInternal(CharCount.INSTANCE_DEFAULT, false);
-
- /**
- * Examines only the strong directional non-format characters, and if either
- * left to right or right to left characters are 60% or more of this total,
- * determines that the direction follows the majority of characters. Falls
- * back to right to left if neither direction meets this threshold.
- */
- 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;
@@ -255,62 +237,6 @@ public class TextDirectionHeuristics {
}
/**
- * Algorithm that uses the relative proportion of strong directional
- * characters (excluding LRE, LRO, RLE, RLO) to determine the direction
- * of the paragraph, if the proportion exceeds a given threshold.
- *
- * @hide
- */
- public static class CharCount implements TextDirectionAlgorithm {
- private final float mThreshold;
-
- @Override
- public TriState checkRtl(char[] text, int start, int count) {
- int countLtr = 0;
- int countRtl = 0;
- for(int i = start, e = start + count; i < e; ++i) {
- switch (isRtlText(Character.getDirectionality(text[i]))) {
- case TRUE:
- ++countLtr;
- break;
- case FALSE:
- ++countRtl;
- break;
- default:
- break;
- }
- }
- int limit = (int)((countLtr + countRtl) * mThreshold);
- if (limit > 0) {
- if (countLtr > limit) {
- return TriState.FALSE;
- }
- if (countRtl > limit) {
- return TriState.TRUE;
- }
- }
- return TriState.UNKNOWN;
- }
-
- private CharCount(float threshold) {
- mThreshold = threshold;
- }
-
- public static CharCount withThreshold(float threshold) {
- if (threshold < 0 || threshold > 1) {
- throw new IllegalArgumentException();
- }
- if (threshold == DEFAULT_THRESHOLD) {
- return INSTANCE_DEFAULT;
- }
- return new CharCount(threshold);
- }
-
- 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 {
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index fa1d249..35833b0 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -2568,26 +2568,18 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit
public static final int TEXT_DIRECTION_ANY_RTL = 2;
/**
- * Text direction is the same as the one held by a 60% majority of the characters. If there is
- * no majority then the paragraph direction is the resolved layout direction of the View.
- *
- * @hide
- */
- public static final int TEXT_DIRECTION_CHAR_COUNT = 3;
-
- /**
* Text direction is forced to LTR.
*
* @hide
*/
- public static final int TEXT_DIRECTION_LTR = 4;
+ public static final int TEXT_DIRECTION_LTR = 3;
/**
* Text direction is forced to RTL.
*
* @hide
*/
- public static final int TEXT_DIRECTION_RTL = 5;
+ public static final int TEXT_DIRECTION_RTL = 4;
/**
* Default text direction is inherited
@@ -2603,7 +2595,6 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit
@ViewDebug.IntToString(from = TEXT_DIRECTION_INHERIT, to = "INHERIT"),
@ViewDebug.IntToString(from = TEXT_DIRECTION_FIRST_STRONG, to = "FIRST_STRONG"),
@ViewDebug.IntToString(from = TEXT_DIRECTION_ANY_RTL, to = "ANY_RTL"),
- @ViewDebug.IntToString(from = TEXT_DIRECTION_CHAR_COUNT, to = "CHAR_COUNT"),
@ViewDebug.IntToString(from = TEXT_DIRECTION_LTR, to = "LTR"),
@ViewDebug.IntToString(from = TEXT_DIRECTION_RTL, to = "RTL")
})
@@ -2621,7 +2612,6 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit
@ViewDebug.IntToString(from = TEXT_DIRECTION_INHERIT, to = "INHERIT"),
@ViewDebug.IntToString(from = TEXT_DIRECTION_FIRST_STRONG, to = "FIRST_STRONG"),
@ViewDebug.IntToString(from = TEXT_DIRECTION_ANY_RTL, to = "ANY_RTL"),
- @ViewDebug.IntToString(from = TEXT_DIRECTION_CHAR_COUNT, to = "CHAR_COUNT"),
@ViewDebug.IntToString(from = TEXT_DIRECTION_LTR, to = "LTR"),
@ViewDebug.IntToString(from = TEXT_DIRECTION_RTL, to = "RTL")
})
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index abf1281..76de24a 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -11244,10 +11244,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
case TEXT_DIRECTION_ANY_RTL:
mTextDir = TextDirectionHeuristics.ANYRTL_LTR;
break;
- case TEXT_DIRECTION_CHAR_COUNT:
- mTextDir = (defaultIsRtl ? TextDirectionHeuristics.CHARCOUNT_RTL:
- TextDirectionHeuristics.CHARCOUNT_LTR);
- break;
case TEXT_DIRECTION_LTR:
mTextDir = TextDirectionHeuristics.LTR;
break;
diff --git a/core/tests/coretests/src/android/widget/TextViewTest.java b/core/tests/coretests/src/android/widget/TextViewTest.java
index 7dc95db..5f65faf 100644
--- a/core/tests/coretests/src/android/widget/TextViewTest.java
+++ b/core/tests/coretests/src/android/widget/TextViewTest.java
@@ -198,40 +198,6 @@ public class TextViewTest extends ActivityInstrumentationTestCase2<TextViewTestA
}
@SmallTest
- public void testCharCountHeuristic() {
- LinearLayout ll = new LinearLayout(getActivity());
- ll.setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
-
- TextView tv = new TextView(getActivity());
- ll.addView(tv);
-
- tv.setTextDirection(View.TEXT_DIRECTION_CHAR_COUNT);
- tv.setText("this is a test");
- assertEquals(View.TEXT_DIRECTION_LTR, tv.getResolvedTextDirection());
-
- // resetResolvedTextDirection is not part of the public API so simply use setTextDirection
- tv.setTextDirection(View.TEXT_DIRECTION_LTR);
- tv.setTextDirection(View.TEXT_DIRECTION_CHAR_COUNT);
- tv.setText("\u05DD\u05DE"); // hebrew
- assertEquals(View.TEXT_DIRECTION_RTL, tv.getResolvedTextDirection());
-
- tv.setTextDirection(View.TEXT_DIRECTION_LTR);
- tv.setTextDirection(View.TEXT_DIRECTION_CHAR_COUNT);
- tv.setText("this is a test \u05DD\u05DE"); // latin more than 60% + hebrew
- assertEquals(View.TEXT_DIRECTION_LTR, tv.getResolvedTextDirection());
-
- tv.setTextDirection(View.TEXT_DIRECTION_LTR);
- tv.setTextDirection(View.TEXT_DIRECTION_CHAR_COUNT);
- tv.setText("t \u05DD\u05DE"); // latin + hebrew more than 60%
- assertEquals(View.TEXT_DIRECTION_RTL, tv.getResolvedTextDirection());
-
- tv.setTextDirection(View.TEXT_DIRECTION_LTR);
- tv.setTextDirection(View.TEXT_DIRECTION_CHAR_COUNT);
- tv.setText("ab \u05DD\u05DE"); // latin + hebrew at 50% each
- assertEquals(View.TEXT_DIRECTION_RTL, tv.getResolvedTextDirection());
- }
-
- @SmallTest
public void testResetTextDirection() {
final TextViewTestActivity activity = getActivity();