use of android.text.style.ForegroundColorSpan in project plaid by nickbutcher.
the class HomeActivity method setNoFiltersEmptyTextVisibility.
private void setNoFiltersEmptyTextVisibility(int visibility) {
if (visibility == View.VISIBLE) {
if (noFiltersEmptyText == null) {
// create the no filters empty text
ViewStub stub = (ViewStub) findViewById(R.id.stub_no_filters);
noFiltersEmptyText = (TextView) stub.inflate();
String emptyText = getString(R.string.no_filters_selected);
int filterPlaceholderStart = emptyText.indexOf('ࢴ');
int altMethodStart = filterPlaceholderStart + 3;
SpannableStringBuilder ssb = new SpannableStringBuilder(emptyText);
// show an image of the filter icon
ssb.setSpan(new ImageSpan(this, R.drawable.ic_filter_small, ImageSpan.ALIGN_BASELINE), filterPlaceholderStart, filterPlaceholderStart + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
// make the alt method (swipe from right) less prominent and italic
ssb.setSpan(new ForegroundColorSpan(ContextCompat.getColor(this, R.color.text_secondary_light)), altMethodStart, emptyText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
ssb.setSpan(new StyleSpan(Typeface.ITALIC), altMethodStart, emptyText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
noFiltersEmptyText.setText(ssb);
noFiltersEmptyText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
drawer.openDrawer(GravityCompat.END);
}
});
}
noFiltersEmptyText.setVisibility(visibility);
} else if (noFiltersEmptyText != null) {
noFiltersEmptyText.setVisibility(visibility);
}
}
use of android.text.style.ForegroundColorSpan in project NoHttp by yanzhenjie.
the class ResCompat method getColorText.
public static SpannableString getColorText(CharSequence content, int start, int end, int color) {
SpannableString stringSpan = new SpannableString(content);
stringSpan.setSpan(new ForegroundColorSpan(color), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return stringSpan;
}
use of android.text.style.ForegroundColorSpan in project android_frameworks_base by ResurrectionRemix.
the class RestrictedLockUtils method setMenuItemAsDisabledByAdmin.
/**
* Set the menu item as disabled by admin by adding a restricted padlock at the end of the
* text and set the click listener which will send an intent to show the admin support details
* dialog. If the admin is null, remove the padlock and disabled color span. When the admin is
* null, we also set the OnMenuItemClickListener to null, so if you want to set a custom
* OnMenuItemClickListener, set it after calling this method.
*/
public static void setMenuItemAsDisabledByAdmin(final Context context, final MenuItem item, final EnforcedAdmin admin) {
SpannableStringBuilder sb = new SpannableStringBuilder(item.getTitle());
removeExistingRestrictedSpans(sb);
if (admin != null) {
final int disabledColor = context.getColor(R.color.disabled_text_color);
sb.setSpan(new ForegroundColorSpan(disabledColor), 0, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
ImageSpan image = new RestrictedLockImageSpan(context);
sb.append(" ", image, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
sendShowAdminSupportDetailsIntent(context, admin);
return true;
}
});
} else {
item.setOnMenuItemClickListener(null);
}
item.setTitle(sb);
}
use of android.text.style.ForegroundColorSpan in project android_frameworks_base by ResurrectionRemix.
the class RestrictedLockUtils method removeExistingRestrictedSpans.
private static void removeExistingRestrictedSpans(SpannableStringBuilder sb) {
final int length = sb.length();
RestrictedLockImageSpan[] imageSpans = sb.getSpans(length - 1, length, RestrictedLockImageSpan.class);
for (ImageSpan span : imageSpans) {
final int start = sb.getSpanStart(span);
final int end = sb.getSpanEnd(span);
sb.removeSpan(span);
sb.delete(start, end);
}
ForegroundColorSpan[] colorSpans = sb.getSpans(0, length, ForegroundColorSpan.class);
for (ForegroundColorSpan span : colorSpans) {
sb.removeSpan(span);
}
}
use of android.text.style.ForegroundColorSpan in project android_frameworks_base by ResurrectionRemix.
the class HtmlToSpannedConverter method endFont.
private static void endFont(Editable text) {
Font font = getLast(text, Font.class);
if (font != null) {
setSpanFromMark(text, font, new TypefaceSpan(font.mFace));
}
Foreground foreground = getLast(text, Foreground.class);
if (foreground != null) {
setSpanFromMark(text, foreground, new ForegroundColorSpan(foreground.mForegroundColor));
}
}
Aggregations