use of android.text.style.ClickableSpan in project AndroidChromium by JackyAndroid.
the class InfoBarLayout method prepareMainMessageString.
/**
* Prepares text to be displayed as the infobar's main message, including setting up a
* clickable link if the infobar requires it.
*/
private CharSequence prepareMainMessageString() {
SpannableStringBuilder fullString = new SpannableStringBuilder();
if (mMessageMainText != null)
fullString.append(mMessageMainText);
// Concatenate the text to display for the link and make it clickable.
if (!TextUtils.isEmpty(mMessageLinkText)) {
if (fullString.length() > 0)
fullString.append(" ");
int spanStart = fullString.length();
fullString.append(mMessageLinkText);
fullString.setSpan(new ClickableSpan() {
@Override
public void onClick(View view) {
mInfoBarView.onLinkClicked();
}
}, spanStart, fullString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
return fullString;
}
use of android.text.style.ClickableSpan in project AndroidChromium by JackyAndroid.
the class SavePasswordInfoBar method createContent.
@Override
public void createContent(InfoBarLayout layout) {
super.createContent(layout);
if (mTitleLinkRangeStart != 0 && mTitleLinkRangeEnd != 0) {
SpannableString title = new SpannableString(mTitle);
title.setSpan(new ClickableSpan() {
@Override
public void onClick(View view) {
onLinkClicked();
}
}, mTitleLinkRangeStart, mTitleLinkRangeEnd, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
layout.setMessage(title);
}
if (!TextUtils.isEmpty(mFirstRunExperienceMessage)) {
InfoBarControlLayout controlLayout = layout.addControlLayout();
controlLayout.addDescription(mFirstRunExperienceMessage);
}
}
use of android.text.style.ClickableSpan in project AndroidChromium by JackyAndroid.
the class AutofillSaveCardInfoBar method createContent.
@Override
public void createContent(InfoBarLayout layout) {
super.createContent(layout);
InfoBarControlLayout control = layout.addControlLayout();
for (int i = 0; i < mCardDetails.size(); i++) {
CardDetail detail = mCardDetails.get(i);
control.addIcon(detail.issuerIconDrawableId, 0, detail.label, detail.subLabel);
}
for (LegalMessageLine line : mLegalMessageLines) {
SpannableString text = new SpannableString(line.text);
for (final LegalMessageLine.Link link : line.links) {
text.setSpan(new ClickableSpan() {
@Override
public void onClick(View view) {
nativeOnLegalMessageLinkClicked(mNativeAutofillSaveCardInfoBar, link.url);
}
}, link.start, link.end, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
}
control.addDescription(text);
}
}
use of android.text.style.ClickableSpan in project AndroidChromium by JackyAndroid.
the class DownloadOverwriteInfoBar method formatInfoBarMessage.
/**
* Create infobar message in the form of CharSequence.
*
* @param context The context.
* @param template The template CharSequence.
* @param fileName The file name.
* @param dirName The directory name.
* @param dirNameIntent The intent to be launched when user touches the directory name link.
* @return CharSequence formatted message for InfoBar.
*/
private CharSequence formatInfoBarMessage(final Context context, String template, String fileName, String dirName, final Intent dirNameIntent) {
SpannableString formattedFileName = new SpannableString(fileName);
formattedFileName.setSpan(new StyleSpan(Typeface.BOLD), 0, fileName.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
SpannableString formattedDirName = new SpannableString(dirName);
if (canResolveIntent(context, dirNameIntent)) {
formattedDirName.setSpan(new ClickableSpan() {
@Override
public void onClick(View view) {
context.startActivity(dirNameIntent);
}
}, 0, dirName.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
} else if (opensDownloadManager()) {
formattedDirName.setSpan(new ClickableSpan() {
@Override
public void onClick(View view) {
DownloadUtils.showDownloadManager(null, null);
}
}, 0, dirName.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
return TextUtils.expandTemplate(template, formattedFileName, formattedDirName);
}
use of android.text.style.ClickableSpan in project AndroidChromium by JackyAndroid.
the class GeneratedPasswordSavedInfoBar method createContent.
/**
* Used to specify button layout and custom content. Makes infobar display a single button and
* an inline link in the message.
* @param layout Handles user interface for the infobar.
*/
@Override
public void createContent(InfoBarLayout layout) {
layout.setButtons(mButtonLabel, null);
SpannableString message = new SpannableString(mMessageText);
message.setSpan(new ClickableSpan() {
@Override
public void onClick(View view) {
onLinkClicked();
}
}, mInlineLinkRangeStart, mInlineLinkRangeEnd, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
layout.setMessage(message);
}
Aggregations