Java Code Examples for android.text.style.LocaleSpan

The following are top voted examples for showing how to use android.text.style.LocaleSpan. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: 365browser   File: LollipopBrowserAccessibilityManager.java   Source Code and License 6 votes vote down vote up
@Override
protected CharSequence computeText(String text, boolean annotateAsLink, String language) {
    CharSequence charSequence = super.computeText(text, annotateAsLink, language);
    if (!language.isEmpty() && !language.equals(mSystemLanguageTag)) {
        SpannableString spannable;
        if (charSequence instanceof SpannableString) {
            spannable = (SpannableString) charSequence;
        } else {
            spannable = new SpannableString(charSequence);
        }
        Locale locale = Locale.forLanguageTag(language);
        spannable.setSpan(new LocaleSpan(locale), 0, spannable.length(), 0);
        return spannable;
    }
    return charSequence;
}
 
Example 2
Project: SpanEZ   File: SpanEZTest.java   Source Code and License 5 votes vote down vote up
@Test
public void locale_should_add_only_one_span() {
    spanBuilder.locale(range, Locale.US)
               .apply();

    verify((SpanEZ) spanBuilder, times(1))
            .addSpan(isA(TargetRange.class), isA(LocaleSpan.class));
}
 
Example 3
Project: spanner   File: Spans.java   Source Code and License 5 votes vote down vote up
/**
 * @see android.text.style.LocaleSpan#LocaleSpan(LocaleList)
 */
@RequiresApi(api = Build.VERSION_CODES.N)
public static Span locale(@NonNull final LocaleList localeList) {
    return new Span(new SpanBuilder() {
        @Override
        public Object build() {
            return new LocaleSpan(localeList);
        }
    });
}
 
Example 4
Project: AndroidSpan   File: AndroidSpan.java   Source Code and License 5 votes vote down vote up
/**
 * @param text
 * @param locale Locale.CHINESE
 * @return
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public AndroidSpan drawLocaleSpan(String text, Locale locale) {
    LocaleSpan span = new LocaleSpan(locale);
    drawSpan(text, span);
    return this;
}
 
Example 5
Project: AndroidSpan   File: SpanOptions.java   Source Code and License 5 votes vote down vote up
/**
 * @param locale Locale.CHINESE
 * @return
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public SpanOptions addLocaleSpan(Locale locale) {
    LocaleSpan span = new LocaleSpan(locale);
    listSpan.add(span);
    return this;
}