Search in sources :

Example 16 with TextAppearanceSpan

use of android.text.style.TextAppearanceSpan in project android_frameworks_base by ResurrectionRemix.

the class Notification method removeTextSizeSpans.

private static CharSequence removeTextSizeSpans(CharSequence charSequence) {
    if (charSequence instanceof Spanned) {
        Spanned ss = (Spanned) charSequence;
        Object[] spans = ss.getSpans(0, ss.length(), Object.class);
        SpannableStringBuilder builder = new SpannableStringBuilder(ss.toString());
        for (Object span : spans) {
            Object resultSpan = span;
            if (resultSpan instanceof CharacterStyle) {
                resultSpan = ((CharacterStyle) span).getUnderlying();
            }
            if (resultSpan instanceof TextAppearanceSpan) {
                TextAppearanceSpan originalSpan = (TextAppearanceSpan) resultSpan;
                resultSpan = new TextAppearanceSpan(originalSpan.getFamily(), originalSpan.getTextStyle(), -1, originalSpan.getTextColor(), originalSpan.getLinkTextColor());
            } else if (resultSpan instanceof RelativeSizeSpan || resultSpan instanceof AbsoluteSizeSpan) {
                continue;
            } else {
                resultSpan = span;
            }
            builder.setSpan(resultSpan, ss.getSpanStart(span), ss.getSpanEnd(span), ss.getSpanFlags(span));
        }
        return builder;
    }
    return charSequence;
}
Also used : TextAppearanceSpan(android.text.style.TextAppearanceSpan) RelativeSizeSpan(android.text.style.RelativeSizeSpan) Spanned(android.text.Spanned) SpannableStringBuilder(android.text.SpannableStringBuilder) CharacterStyle(android.text.style.CharacterStyle) AbsoluteSizeSpan(android.text.style.AbsoluteSizeSpan)

Example 17 with TextAppearanceSpan

use of android.text.style.TextAppearanceSpan in project UltimateAndroid by cymcsg.

the class TextDrawer method setDetailStyling.

public void setDetailStyling(int styleId) {
    mDetailSpan = new TextAppearanceSpan(this.context, styleId);
    setContentText(mDetails);
}
Also used : TextAppearanceSpan(android.text.style.TextAppearanceSpan)

Example 18 with TextAppearanceSpan

use of android.text.style.TextAppearanceSpan in project Ushahidi_Android by ushahidi.

the class SuggestionsAdapter method formatUrl.

private CharSequence formatUrl(CharSequence url) {
    if (mUrlColor == null) {
        // Lazily get the URL color from the current theme.
        TypedValue colorValue = new TypedValue();
        mContext.getTheme().resolveAttribute(R.attr.textColorSearchUrl, colorValue, true);
        mUrlColor = mContext.getResources().getColorStateList(colorValue.resourceId);
    }
    SpannableString text = new SpannableString(url);
    text.setSpan(new TextAppearanceSpan(null, 0, 0, mUrlColor, null), 0, url.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    return text;
}
Also used : SpannableString(android.text.SpannableString) TextAppearanceSpan(android.text.style.TextAppearanceSpan) TypedValue(android.util.TypedValue)

Example 19 with TextAppearanceSpan

use of android.text.style.TextAppearanceSpan in project smartmodule by carozhu.

the class LabelView method format.

public SpannableString format(Context context, CharSequence text, int style) {
    SpannableString spannableString = new SpannableString(text);
    spannableString.setSpan(new TextAppearanceSpan(context, style), 0, text.length(), 0);
    return spannableString;
}
Also used : SpannableString(android.text.SpannableString) TextAppearanceSpan(android.text.style.TextAppearanceSpan)

Example 20 with TextAppearanceSpan

use of android.text.style.TextAppearanceSpan in project android_frameworks_base by crdroidandroid.

the class NotificationColorUtil method processTextAppearanceSpan.

private TextAppearanceSpan processTextAppearanceSpan(TextAppearanceSpan span) {
    ColorStateList colorStateList = span.getTextColor();
    if (colorStateList != null) {
        int[] colors = colorStateList.getColors();
        boolean changed = false;
        for (int i = 0; i < colors.length; i++) {
            if (ImageUtils.isGrayscale(colors[i])) {
                // list.
                if (!changed) {
                    colors = Arrays.copyOf(colors, colors.length);
                }
                colors[i] = processColor(colors[i]);
                changed = true;
            }
        }
        if (changed) {
            return new TextAppearanceSpan(span.getFamily(), span.getTextStyle(), span.getTextSize(), new ColorStateList(colorStateList.getStates(), colors), span.getLinkTextColor());
        }
    }
    return span;
}
Also used : TextAppearanceSpan(android.text.style.TextAppearanceSpan) ColorStateList(android.content.res.ColorStateList)

Aggregations

TextAppearanceSpan (android.text.style.TextAppearanceSpan)52 SpannableString (android.text.SpannableString)21 SpannableStringBuilder (android.text.SpannableStringBuilder)15 Spanned (android.text.Spanned)15 TypedValue (android.util.TypedValue)15 View (android.view.View)10 ColorStateList (android.content.res.ColorStateList)9 SmallTest (android.test.suitebuilder.annotation.SmallTest)6 Intent (android.content.Intent)5 TypedArray (android.content.res.TypedArray)5 Espresso.onView (android.support.test.espresso.Espresso.onView)5 NoMatchingViewException (android.support.test.espresso.NoMatchingViewException)5 ViewAssertion (android.support.test.espresso.ViewAssertion)5 RootMatchers.withDecorView (android.support.test.espresso.matcher.RootMatchers.withDecorView)5 TextPaint (android.text.TextPaint)5 AbsoluteSizeSpan (android.text.style.AbsoluteSizeSpan)5 CharacterStyle (android.text.style.CharacterStyle)5 RelativeSizeSpan (android.text.style.RelativeSizeSpan)5 SuggestionSpan (android.text.style.SuggestionSpan)5 ImageView (android.widget.ImageView)5