use of android.text.style.ForegroundColorSpan in project Conversations by siacs.
the class MessageAdapter method displayHeartMessage.
private void displayHeartMessage(final ViewHolder viewHolder, final String body) {
if (viewHolder.download_button != null) {
viewHolder.download_button.setVisibility(View.GONE);
}
viewHolder.image.setVisibility(View.GONE);
viewHolder.messageBody.setVisibility(View.VISIBLE);
viewHolder.messageBody.setIncludeFontPadding(false);
Spannable span = new SpannableString(body);
span.setSpan(new RelativeSizeSpan(4.0f), 0, body.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
span.setSpan(new ForegroundColorSpan(activity.getWarningTextColor()), 0, body.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
viewHolder.messageBody.setText(span);
}
use of android.text.style.ForegroundColorSpan in project android-app by spark.
the class TinkerFragment method showInstructions.
private void showInstructions() {
View instructions = Ui.findView(this, R.id.tinker_instructions);
// set cyan on "D7" text
TextView instructions3 = Ui.findView(instructions, R.id.tinker_instructions_3);
String d7 = "D7";
String instructions3Text = getString(R.string.tinker_instructions_3);
int idx = instructions3Text.indexOf(d7);
int cyan = getResources().getColor(R.color.cyan);
Spannable str = (Spannable) instructions3.getText();
str.setSpan(new ForegroundColorSpan(cyan), idx, idx + d7.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
// set visible and then set it to disappear when we're done. and then
// never show up again.
instructions.setVisibility(View.VISIBLE);
instructions.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
v.setVisibility(View.GONE);
TinkerPrefs.getInstance().setVisited(true);
}
});
}
use of android.text.style.ForegroundColorSpan in project platform_frameworks_base by android.
the class FlashlightTile method handleUpdateState.
@Override
protected void handleUpdateState(BooleanState state, Object arg) {
state.label = mHost.getContext().getString(R.string.quick_settings_flashlight_label);
if (!mFlashlightController.isAvailable()) {
Drawable icon = mHost.getContext().getDrawable(R.drawable.ic_signal_flashlight_disable).mutate();
final int disabledColor = mHost.getContext().getColor(R.color.qs_tile_tint_unavailable);
icon.setTint(disabledColor);
state.icon = new DrawableIcon(icon);
state.label = new SpannableStringBuilder().append(state.label, new ForegroundColorSpan(disabledColor), SpannableStringBuilder.SPAN_INCLUSIVE_INCLUSIVE);
state.contentDescription = mContext.getString(R.string.accessibility_quick_settings_flashlight_unavailable);
return;
}
if (arg instanceof Boolean) {
boolean value = (Boolean) arg;
if (value == state.value) {
return;
}
state.value = value;
} else {
state.value = mFlashlightController.isEnabled();
}
final AnimationIcon icon = state.value ? mEnable : mDisable;
state.icon = icon;
state.contentDescription = mContext.getString(R.string.quick_settings_flashlight_label);
state.minimalAccessibilityClassName = state.expandedAccessibilityClassName = Switch.class.getName();
}
use of android.text.style.ForegroundColorSpan in project platform_frameworks_base by android.
the class CustomTile method handleUpdateState.
@Override
protected void handleUpdateState(State state, Object arg) {
int tileState = mTile.getState();
if (mServiceManager.hasPendingBind()) {
tileState = Tile.STATE_UNAVAILABLE;
}
Drawable drawable;
try {
drawable = mTile.getIcon().loadDrawable(mContext);
} catch (Exception e) {
Log.w(TAG, "Invalid icon, forcing into unavailable state");
tileState = Tile.STATE_UNAVAILABLE;
drawable = mDefaultIcon.loadDrawable(mContext);
}
int color = mContext.getColor(getColor(tileState));
drawable.setTint(color);
state.icon = new DrawableIcon(drawable);
state.label = mTile.getLabel();
if (tileState == Tile.STATE_UNAVAILABLE) {
state.label = new SpannableStringBuilder().append(state.label, new ForegroundColorSpan(color), SpannableStringBuilder.SPAN_INCLUSIVE_INCLUSIVE);
}
if (mTile.getContentDescription() != null) {
state.contentDescription = mTile.getContentDescription();
} else {
state.contentDescription = state.label;
}
}
use of android.text.style.ForegroundColorSpan in project platform_frameworks_base by android.
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);
}
Aggregations