FileDocCategorySizeDatePackage
TextDirectionHeuristics.javaAPI DocAndroid 5.1 API9744Thu Mar 12 22:22:10 GMT 2015android.text

TextDirectionHeuristics

public class TextDirectionHeuristics extends Object
Some objects that implement {@link TextDirectionHeuristic}. Use these with the {@link BidiFormatter#unicodeWrap unicodeWrap()} methods in {@link BidiFormatter}. Also notice that these direction heuristics correspond to the same types of constants provided in the {@link android.view.View} class for {@link android.view.View#setTextDirection setTextDirection()}, such as {@link android.view.View#TEXT_DIRECTION_RTL}.

To support versions lower than {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2}, you can use the support library's {@link android.support.v4.text.TextDirectionHeuristicsCompat} class.

Fields Summary
public static final TextDirectionHeuristic
LTR
Always decides that the direction is left to right.
public static final TextDirectionHeuristic
RTL
Always decides that the direction is right to left.
public static final TextDirectionHeuristic
FIRSTSTRONG_LTR
Determines the direction based on the first strong directional character, including bidi format chars, falling back to left to right if it finds none. This is the default behavior of the Unicode Bidirectional Algorithm.
public static final TextDirectionHeuristic
FIRSTSTRONG_RTL
Determines the direction based on the first strong directional character, including bidi format chars, falling back to right to left if it finds none. This is similar to the default behavior of the Unicode Bidirectional Algorithm, just with different fallback behavior.
public static final TextDirectionHeuristic
ANYRTL_LTR
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 finds none.
public static final TextDirectionHeuristic
LOCALE
Force the paragraph direction to the Locale direction. Falls back to left to right.
private static final int
STATE_TRUE
State constants for taking care about true / false / unknown
private static final int
STATE_FALSE
private static final int
STATE_UNKNOWN
Constructors Summary
Methods Summary
private static intisRtlText(int directionality)


         
        switch (directionality) {
            case Character.DIRECTIONALITY_LEFT_TO_RIGHT:
                return STATE_FALSE;
            case Character.DIRECTIONALITY_RIGHT_TO_LEFT:
            case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
                return STATE_TRUE;
            default:
                return STATE_UNKNOWN;
        }
    
private static intisRtlTextOrFormat(int directionality)

        switch (directionality) {
            case Character.DIRECTIONALITY_LEFT_TO_RIGHT:
            case Character.DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING:
            case Character.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE:
                return STATE_FALSE;
            case Character.DIRECTIONALITY_RIGHT_TO_LEFT:
            case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
            case Character.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING:
            case Character.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE:
                return STATE_TRUE;
            default:
                return STATE_UNKNOWN;
        }