use of android.text.style.ForegroundColorSpan in project run-wallet-android by runplay.
the class NetworkNodeInfoFragment method generateCenterSpannableText.
private SpannableString generateCenterSpannableText() {
SpannableString s = new SpannableString("");
s.setSpan(new RelativeSizeSpan(0.75f), 0, 0, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
s.setSpan(new ForegroundColorSpan(ContextCompat.getColor(getActivity(), AppTheme.getAccent())), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return s;
}
use of android.text.style.ForegroundColorSpan in project materialistic by hidroh.
the class HelpListView method onFinishInflate.
@Override
protected void onFinishInflate() {
super.onFinishInflate();
((TextView) findViewById(R.id.item_new).findViewById(R.id.rank)).append(makeAsteriskSpan());
SpannableString spannable = new SpannableString("+5");
spannable.setSpan(new SuperscriptSpan(), 0, spannable.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
spannable.setSpan(new RelativeSizeSpan(0.6f), 0, spannable.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
spannable.setSpan(new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.greenA700)), 0, spannable.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
((TextView) findViewById(R.id.item_promoted).findViewById(R.id.rank)).append(spannable);
TextView comments = (TextView) findViewById(R.id.item_new_comments).findViewById(R.id.comment);
SpannableStringBuilder sb = new SpannableStringBuilder("46");
sb.append(makeAsteriskSpan());
comments.setText(sb);
}
use of android.text.style.ForegroundColorSpan in project android-betterpickers by code-troopers.
the class TimeZonePickerUtils method buildGmtDisplayName.
private CharSequence buildGmtDisplayName(TimeZone tz, long timeMillis, boolean grayGmt) {
Time time = new Time(tz.getID());
time.set(timeMillis);
StringBuilder sb = new StringBuilder();
String displayName = getDisplayName(tz, time.isDst != 0);
sb.append(displayName);
sb.append(" ");
final int gmtOffset = tz.getOffset(timeMillis);
int gmtStart = sb.length();
appendGmtOffset(sb, gmtOffset);
int gmtEnd = sb.length();
int symbolStart = 0;
int symbolEnd = 0;
if (tz.useDaylightTime()) {
sb.append(" ");
symbolStart = sb.length();
// Sun symbol
sb.append(getDstSymbol());
symbolEnd = sb.length();
}
// Set the gray colors.
Spannable spannableText = mSpannableFactory.newSpannable(sb);
if (grayGmt) {
spannableText.setSpan(new ForegroundColorSpan(GMT_TEXT_COLOR), gmtStart, gmtEnd, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (tz.useDaylightTime()) {
spannableText.setSpan(new ForegroundColorSpan(DST_SYMBOL_COLOR), symbolStart, symbolEnd, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
CharSequence gmtDisplayName = spannableText;
return gmtDisplayName;
}
use of android.text.style.ForegroundColorSpan in project android-betterpickers by code-troopers.
the class TimeZoneInfo method getGmtDisplayName.
/*
* The method is synchronized because there's one mSB, which is used by
* mFormatter, per instance. If there are multiple callers for
* getGmtDisplayName, the output may be mangled.
*/
public synchronized CharSequence getGmtDisplayName(Context context) {
// TODO Note: The local time is shown in current time (current GMT
// offset) which may be different from the time specified by
// mTimeMillis
final long nowMinute = System.currentTimeMillis() / DateUtils.MINUTE_IN_MILLIS;
final long now = nowMinute * DateUtils.MINUTE_IN_MILLIS;
final int gmtOffset = mTz.getOffset(now);
int cacheKey;
boolean hasFutureDST = mTz.useDaylightTime();
if (hasFutureDST) {
cacheKey = (int) (gmtOffset + 36 * DateUtils.HOUR_IN_MILLIS);
} else {
cacheKey = (int) (gmtOffset - 36 * DateUtils.HOUR_IN_MILLIS);
}
CharSequence displayName = null;
if (mGmtDisplayNameUpdateTime != nowMinute) {
mGmtDisplayNameUpdateTime = nowMinute;
mGmtDisplayNameCache.clear();
} else {
displayName = mGmtDisplayNameCache.get(cacheKey);
}
if (displayName == null) {
mSB.setLength(0);
int flags = DateUtils.FORMAT_ABBREV_ALL;
flags |= DateUtils.FORMAT_SHOW_TIME;
if (TimeZoneInfo.is24HourFormat) {
flags |= DateUtils.FORMAT_24HOUR;
}
// mFormatter writes to mSB
DateUtils.formatDateRange(context, mFormatter, now, now, flags, mTzId);
mSB.append(" ");
int gmtStart = mSB.length();
TimeZonePickerUtils.appendGmtOffset(mSB, gmtOffset);
int gmtEnd = mSB.length();
int symbolStart = 0;
int symbolEnd = 0;
if (hasFutureDST) {
mSB.append(' ');
symbolStart = mSB.length();
// Sun symbol
mSB.append(TimeZonePickerUtils.getDstSymbol());
symbolEnd = mSB.length();
}
// Set the gray colors.
Spannable spannableText = mSpannableFactory.newSpannable(mSB);
spannableText.setSpan(new ForegroundColorSpan(GMT_TEXT_COLOR), gmtStart, gmtEnd, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
if (hasFutureDST) {
spannableText.setSpan(new ForegroundColorSpan(DST_SYMBOL_COLOR), symbolStart, symbolEnd, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
displayName = spannableText;
mGmtDisplayNameCache.put(cacheKey, displayName);
}
return displayName;
}
use of android.text.style.ForegroundColorSpan in project k-9 by k9mail.
the class RecipientAdapter method highlightText.
public Spannable highlightText(String text) {
Spannable highlightedSpannable = Spannable.Factory.getInstance().newSpannable(text);
if (highlight == null) {
return highlightedSpannable;
}
Pattern pattern = Pattern.compile(highlight, Pattern.LITERAL | Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(text);
while (matcher.find()) {
highlightedSpannable.setSpan(new ForegroundColorSpan(context.getResources().getColor(android.R.color.holo_blue_light)), matcher.start(), matcher.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
return highlightedSpannable;
}
Aggregations