From e3bf88da23bfadd89a35b6dec769ea825e5ecd6e Mon Sep 17 00:00:00 2001 From: Fabrice Di Meglio Date: Tue, 6 Sep 2011 11:08:45 -0700 Subject: Fix bug #5262565 Need to remove CharCount TextDirectionHeuristics - update unit tests too Change-Id: I7c518f58a9f17cb679bc3913bdd38243f7ad2195 --- .../java/android/text/TextDirectionHeuristics.java | 74 ---------------------- 1 file changed, 74 deletions(-) (limited to 'core/java/android/text/TextDirectionHeuristics.java') diff --git a/core/java/android/text/TextDirectionHeuristics.java b/core/java/android/text/TextDirectionHeuristics.java index 18b404003d54..e5c1e5bd6bfd 100644 --- a/core/java/android/text/TextDirectionHeuristics.java +++ b/core/java/android/text/TextDirectionHeuristics.java @@ -61,24 +61,6 @@ public class TextDirectionHeuristics { public static final TextDirectionHeuristic ANYRTL_LTR = 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. */ @@ -254,62 +236,6 @@ public class TextDirectionHeuristics { public static final AnyStrong INSTANCE_LTR = new AnyStrong(false); } - /** - * 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. */ -- cgit v1.2.3