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;
}
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);
}
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;
}
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;
}
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;
}
Aggregations