use of android.text.style.TextAppearanceSpan in project android_frameworks_base by crdroidandroid.
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 android_frameworks_base by crdroidandroid.
the class NotificationColorUtil method invertCharSequenceColors.
/**
* Inverts all the grayscale colors set by {@link android.text.style.TextAppearanceSpan}s on
* the text.
*
* @param charSequence The text to process.
* @return The color inverted text.
*/
public CharSequence invertCharSequenceColors(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 (span instanceof TextAppearanceSpan) {
resultSpan = processTextAppearanceSpan((TextAppearanceSpan) span);
}
builder.setSpan(resultSpan, ss.getSpanStart(span), ss.getSpanEnd(span), ss.getSpanFlags(span));
}
return builder;
}
return charSequence;
}
Aggregations