Java Code Examples for android.text.TextDirectionHeuristics#FIRSTSTRONG_LTR
The following examples show how to use
android.text.TextDirectionHeuristics#FIRSTSTRONG_LTR .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StaticLayoutProxy.java From TextLayoutBuilder with Apache License 2.0 | 6 votes |
public static TextDirectionHeuristic fromTextDirectionHeuristicCompat( TextDirectionHeuristicCompat textDirection) { if (textDirection == TextDirectionHeuristicsCompat.LTR) { return TextDirectionHeuristics.LTR; } else if (textDirection == TextDirectionHeuristicsCompat.RTL) { return TextDirectionHeuristics.RTL; } else if (textDirection == TextDirectionHeuristicsCompat.FIRSTSTRONG_LTR) { return TextDirectionHeuristics.FIRSTSTRONG_LTR; } else if (textDirection == TextDirectionHeuristicsCompat.FIRSTSTRONG_RTL) { return TextDirectionHeuristics.FIRSTSTRONG_RTL; } else if (textDirection == TextDirectionHeuristicsCompat.ANYRTL_LTR) { return TextDirectionHeuristics.ANYRTL_LTR; } else if (textDirection == TextDirectionHeuristicsCompat.LOCALE) { return TextDirectionHeuristics.LOCALE; } else { return TextDirectionHeuristics.FIRSTSTRONG_LTR; } }
Example 2
Source File: StaticLayoutEx.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public static void init() { if (initialized) { return; } try { final Class<?> textDirClass; if (Build.VERSION.SDK_INT >= 18) { textDirClass = TextDirectionHeuristic.class; sTextDirection = TextDirectionHeuristics.FIRSTSTRONG_LTR; } else { ClassLoader loader = StaticLayoutEx.class.getClassLoader(); textDirClass = loader.loadClass(TEXT_DIR_CLASS); Class<?> textDirsClass = loader.loadClass(TEXT_DIRS_CLASS); sTextDirection = textDirsClass.getField(TEXT_DIR_FIRSTSTRONG_LTR).get(textDirsClass); } final Class<?>[] signature = new Class[]{ CharSequence.class, int.class, int.class, TextPaint.class, int.class, Layout.Alignment.class, textDirClass, float.class, float.class, boolean.class, TextUtils.TruncateAt.class, int.class, int.class }; sConstructor = StaticLayout.class.getDeclaredConstructor(signature); sConstructor.setAccessible(true); sConstructorArgs = new Object[signature.length]; initialized = true; } catch (Throwable e) { FileLog.e(e); } }
Example 3
Source File: StaticLayoutEx.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public static void init() { if (initialized) { return; } try { final Class<?> textDirClass; if (Build.VERSION.SDK_INT >= 18) { textDirClass = TextDirectionHeuristic.class; sTextDirection = TextDirectionHeuristics.FIRSTSTRONG_LTR; } else { ClassLoader loader = StaticLayoutEx.class.getClassLoader(); textDirClass = loader.loadClass(TEXT_DIR_CLASS); Class<?> textDirsClass = loader.loadClass(TEXT_DIRS_CLASS); sTextDirection = textDirsClass.getField(TEXT_DIR_FIRSTSTRONG_LTR).get(textDirsClass); } final Class<?>[] signature = new Class[]{ CharSequence.class, int.class, int.class, TextPaint.class, int.class, Layout.Alignment.class, textDirClass, float.class, float.class, boolean.class, TextUtils.TruncateAt.class, int.class, int.class }; sConstructor = StaticLayout.class.getDeclaredConstructor(signature); sConstructor.setAccessible(true); sConstructorArgs = new Object[signature.length]; initialized = true; } catch (Throwable e) { FileLog.e(e); } }
Example 4
Source File: CustomTypefaceSpan.java From edx-app-android with Apache License 2.0 | 4 votes |
@TargetApi(JELLY_BEAN_MR1) @CheckResult private boolean needMirroring() { if (!mirrorable) return false; // Passwords fields should be LTR if (view.getTransformationMethod() instanceof PasswordTransformationMethod) { return false; } // Always need to resolve layout direction first final boolean defaultIsRtl = view.getLayoutDirection() == LAYOUT_DIRECTION_RTL; if (SDK_INT < JELLY_BEAN_MR2) { return defaultIsRtl; } // Select the text direction heuristic according to the // package-private getTextDirectionHeuristic() method in TextView TextDirectionHeuristic textDirectionHeuristic; switch (view.getTextDirection()) { default: case TEXT_DIRECTION_FIRST_STRONG: textDirectionHeuristic = defaultIsRtl ? TextDirectionHeuristics.FIRSTSTRONG_RTL : TextDirectionHeuristics.FIRSTSTRONG_LTR; break; case TEXT_DIRECTION_ANY_RTL: textDirectionHeuristic = TextDirectionHeuristics.ANYRTL_LTR; break; case TEXT_DIRECTION_LTR: textDirectionHeuristic = TextDirectionHeuristics.LTR; break; case TEXT_DIRECTION_RTL: textDirectionHeuristic = TextDirectionHeuristics.RTL; break; case TEXT_DIRECTION_LOCALE: textDirectionHeuristic = TextDirectionHeuristics.LOCALE; break; case TEXT_DIRECTION_FIRST_STRONG_LTR: textDirectionHeuristic = TextDirectionHeuristics.FIRSTSTRONG_LTR; break; case TEXT_DIRECTION_FIRST_STRONG_RTL: textDirectionHeuristic = TextDirectionHeuristics.FIRSTSTRONG_RTL; break; } CharSequence text = view.getText(); return textDirectionHeuristic.isRtl(text, 0, text.length()); }
Example 5
Source File: StaticLayoutEx.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public static void init() { if (initialized) { return; } try { final Class<?> textDirClass; if (Build.VERSION.SDK_INT >= 18) { textDirClass = TextDirectionHeuristic.class; sTextDirection = TextDirectionHeuristics.FIRSTSTRONG_LTR; } else { ClassLoader loader = StaticLayoutEx.class.getClassLoader(); textDirClass = loader.loadClass(TEXT_DIR_CLASS); Class<?> textDirsClass = loader.loadClass(TEXT_DIRS_CLASS); sTextDirection = textDirsClass.getField(TEXT_DIR_FIRSTSTRONG_LTR).get(textDirsClass); } final Class<?>[] signature = new Class[]{ CharSequence.class, int.class, int.class, TextPaint.class, int.class, Layout.Alignment.class, textDirClass, float.class, float.class, boolean.class, TextUtils.TruncateAt.class, int.class, int.class }; sConstructor = StaticLayout.class.getDeclaredConstructor(signature); sConstructor.setAccessible(true); sConstructorArgs = new Object[signature.length]; initialized = true; } catch (Throwable e) { FileLog.e(e); } }
Example 6
Source File: StaticLayoutEx.java From Telegram with GNU General Public License v2.0 | 4 votes |
public static void init() { if (initialized) { return; } try { final Class<?> textDirClass; if (Build.VERSION.SDK_INT >= 18) { textDirClass = TextDirectionHeuristic.class; sTextDirection = TextDirectionHeuristics.FIRSTSTRONG_LTR; } else { ClassLoader loader = StaticLayoutEx.class.getClassLoader(); textDirClass = loader.loadClass(TEXT_DIR_CLASS); Class<?> textDirsClass = loader.loadClass(TEXT_DIRS_CLASS); sTextDirection = textDirsClass.getField(TEXT_DIR_FIRSTSTRONG_LTR).get(textDirsClass); } final Class<?>[] signature = new Class[]{ CharSequence.class, int.class, int.class, TextPaint.class, int.class, Layout.Alignment.class, textDirClass, float.class, float.class, boolean.class, TextUtils.TruncateAt.class, int.class, int.class }; sConstructor = StaticLayout.class.getDeclaredConstructor(signature); sConstructor.setAccessible(true); sConstructorArgs = new Object[signature.length]; initialized = true; } catch (Throwable e) { FileLog.e(e); } }