use of android.text.SpannableString in project AndroidChromium by JackyAndroid.
the class AutoSigninFirstRunDialog method show.
private void show() {
final AlertDialog.Builder builder = new AlertDialog.Builder(mContext, R.style.AlertDialogTheme).setTitle(mTitle).setPositiveButton(mOkButtonText, this).setNegativeButton(mTurnOffButtonText, this);
View view = LayoutInflater.from(mContext).inflate(R.layout.auto_sign_in_first_run_dialog, null);
TextView summaryView = (TextView) view.findViewById(R.id.summary);
if (mExplanationLinkStart != mExplanationLinkEnd && mExplanationLinkEnd != 0) {
SpannableString spanableExplanation = new SpannableString(mExplanation);
spanableExplanation.setSpan(new ClickableSpan() {
@Override
public void onClick(View view) {
nativeOnLinkClicked(mNativeAutoSigninFirstRunDialog);
mDialog.dismiss();
}
}, mExplanationLinkStart, mExplanationLinkEnd, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
summaryView.setText(spanableExplanation);
summaryView.setMovementMethod(LinkMovementMethod.getInstance());
} else {
summaryView.setText(mExplanation);
summaryView.setMovementMethod(LinkMovementMethod.getInstance());
}
builder.setView(view);
mDialog = builder.create();
mDialog.setCanceledOnTouchOutside(false);
mDialog.setOnDismissListener(this);
mDialog.show();
}
use of android.text.SpannableString in project AndroidChromium by JackyAndroid.
the class PhysicalWebOptInActivity method getDescriptionText.
private SpannableString getDescriptionText() {
return SpanApplier.applySpans(getString(R.string.physical_web_optin_description), new SpanInfo("<learnmore>", "</learnmore>", new ClickableSpan() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(PHYSICAL_WEB_LEARN_MORE_URL));
// Add the SESSION extra to indicate we want a Chrome custom tab. This
// allows the help page to open in the same task as the opt-in activity so
// they can share a back stack.
String session = null;
intent.putExtra(EXTRA_CUSTOM_TABS_SESSION, session);
PhysicalWebOptInActivity.this.startActivity(intent);
}
@Override
public void updateDrawState(TextPaint ds) {
// Color links but do not underline them.
ds.setColor(ds.linkColor);
}
}));
}
use of android.text.SpannableString in project AndroidChromium by JackyAndroid.
the class SyncCustomizationFragment method errorSummary.
/**
* Applies a span to the given string to give it an error color.
*/
private static Spannable errorSummary(String string, Context context) {
SpannableString summary = new SpannableString(string);
summary.setSpan(new ForegroundColorSpan(ApiCompatibilityUtils.getColor(context.getResources(), R.color.input_underline_error_color)), 0, summary.length(), 0);
return summary;
}
use of android.text.SpannableString in project AndroidChromium by JackyAndroid.
the class TranslateInfoBar method formatBeforeInfoBarMessage.
/**
* @return a formatted message with links to {@code panelId}.
*/
private CharSequence formatBeforeInfoBarMessage(String template, String sourceLanguage, String targetLanguage, final int panelId) {
SpannableString formattedSourceLanguage = new SpannableString(sourceLanguage);
formattedSourceLanguage.setSpan(new ClickableSpan() {
@Override
public void onClick(View view) {
swapPanel(panelId);
}
}, 0, sourceLanguage.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
SpannableString formattedTargetLanguage = new SpannableString(targetLanguage);
formattedTargetLanguage.setSpan(new ClickableSpan() {
@Override
public void onClick(View view) {
swapPanel(panelId);
}
}, 0, targetLanguage.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return TextUtils.expandTemplate(template, formattedSourceLanguage, formattedTargetLanguage);
}
use of android.text.SpannableString in project AndroidChromium by JackyAndroid.
the class TranslateInfoBar method formatAfterTranslateInfoBarMessage.
/**
* @return a formatted message with a link to {@code panelId}
*/
private CharSequence formatAfterTranslateInfoBarMessage(String statement, String linkText, final int panelId) {
SpannableStringBuilder result = new SpannableStringBuilder();
result.append(statement).append(" ");
SpannableString formattedChange = new SpannableString(linkText);
formattedChange.setSpan(new ClickableSpan() {
@Override
public void onClick(View view) {
swapPanel(panelId);
}
}, 0, linkText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
result.append(formattedChange);
return result;
}
Aggregations