Search in sources :

Example 41 with ClickableSpan

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;
}
Also used : ClickableSpan(android.text.style.ClickableSpan) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) SpannableStringBuilder(android.text.SpannableStringBuilder)

Example 42 with ClickableSpan

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);
    }
}
Also used : SpannableString(android.text.SpannableString) ClickableSpan(android.text.style.ClickableSpan) View(android.view.View)

Example 43 with ClickableSpan

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);
    }
}
Also used : SpannableString(android.text.SpannableString) ClickableSpan(android.text.style.ClickableSpan) View(android.view.View)

Example 44 with ClickableSpan

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);
}
Also used : SpannableString(android.text.SpannableString) StyleSpan(android.text.style.StyleSpan) ClickableSpan(android.text.style.ClickableSpan) View(android.view.View)

Example 45 with ClickableSpan

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);
}
Also used : SpannableString(android.text.SpannableString) ClickableSpan(android.text.style.ClickableSpan) View(android.view.View)

Aggregations

ClickableSpan (android.text.style.ClickableSpan)66 View (android.view.View)29 Layout (android.text.Layout)20 TextPaint (android.text.TextPaint)19 TextView (android.widget.TextView)19 SpannableString (android.text.SpannableString)15 Spannable (android.text.Spannable)14 Paint (android.graphics.Paint)13 SpannableStringBuilder (android.text.SpannableStringBuilder)11 Intent (android.content.Intent)7 InputMethodManager (android.view.inputmethod.InputMethodManager)7 Context (android.content.Context)5 CustomTabsIntent (android.support.customtabs.CustomTabsIntent)4 StyleSpan (android.text.style.StyleSpan)4 SuppressLint (android.annotation.SuppressLint)3 DialogInterface (android.content.DialogInterface)3 AlertDialog (android.support.v7.app.AlertDialog)3 ImageView (android.widget.ImageView)3 SpanInfo (org.chromium.ui.text.SpanApplier.SpanInfo)3 PendingIntent (android.app.PendingIntent)2