Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a646145c authored by Fabrice Di Meglio's avatar Fabrice Di Meglio
Browse files

Improve TextDirection resolution

- remove unuseful heuristics
- tune Javadoc

Change-Id: Id72a158b3a17a528423d278b1cbfd95b8c2951b5
parent abb0f299
Loading
Loading
Loading
Loading
+0 −24
Original line number Diff line number Diff line
@@ -49,22 +49,6 @@ public class TextDirectionHeuristics {
    public static final TextDirectionHeuristic FIRSTSTRONG_RTL =
        new TextDirectionHeuristicInternal(FirstStrong.INSTANCE, true);

    /**
     * If the text contains any strong left to right non-format character, determines
     * that the direction is left to right, falling back to left to right if it
     * finds none.
     */
    public static final TextDirectionHeuristic ANYLTR_LTR =
        new TextDirectionHeuristicInternal(AnyStrong.INSTANCE_LTR, false);

    /**
     * If the text contains any strong left to right non-format character, determines
     * that the direction is left to right, falling back to right to left if it
     * finds none.
     */
    public static final TextDirectionHeuristic ANYLTR_RTL =
        new TextDirectionHeuristicInternal(AnyStrong.INSTANCE_LTR, true);

    /**
     * If the text contains any strong right to left non-format character, determines
     * that the direction is right to left, falling back to left to right if it
@@ -73,14 +57,6 @@ public class TextDirectionHeuristics {
    public static final TextDirectionHeuristic ANYRTL_LTR =
        new TextDirectionHeuristicInternal(AnyStrong.INSTANCE_RTL, false);

    /**
     * If the text contains any strong right to left non-format character, determines
     * that the direction is right to left, falling back to right to left if it
     * finds none.
     */
    public static final TextDirectionHeuristic ANYRTL_RTL =
        new TextDirectionHeuristicInternal(AnyStrong.INSTANCE_RTL, true);

    /**
     * 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,
+2 −1
Original line number Diff line number Diff line
@@ -9159,7 +9159,8 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit
            mPrivateFlags &= ~AWAKEN_SCROLL_BARS_ON_ATTACH;
        }
        jumpDrawablesToCurrentState();
        // Order is important here: LayoutDirection should be resolved before Padding and TextDirection
        // Order is important here: LayoutDirection MUST be resolved before Padding
        // and TextDirection
        resolveLayoutDirectionIfNeeded();
        resolvePadding();
        resolveTextDirection();
+1 −2
Original line number Diff line number Diff line
@@ -10716,8 +10716,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                        TextDirectionHeuristics.FIRSTSTRONG_LTR);
                break;
            case TEXT_DIRECTION_ANY_RTL:
                mTextDir = (defaultIsRtl ? TextDirectionHeuristics.ANYRTL_RTL:
                        TextDirectionHeuristics.ANYRTL_LTR);
                mTextDir = TextDirectionHeuristics.ANYRTL_LTR;
                break;
            case TEXT_DIRECTION_CHAR_COUNT:
                mTextDir = (defaultIsRtl ? TextDirectionHeuristics.CHARCOUNT_RTL: