Search in sources :

Example 86 with SpannableString

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();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) SpannableString(android.text.SpannableString) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) ClickableSpan(android.text.style.ClickableSpan)

Example 87 with SpannableString

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);
        }
    }));
}
Also used : SpanInfo(org.chromium.ui.text.SpanApplier.SpanInfo) Intent(android.content.Intent) SpannableString(android.text.SpannableString) ClickableSpan(android.text.style.ClickableSpan) TextView(android.widget.TextView) View(android.view.View) TextPaint(android.text.TextPaint)

Example 88 with SpannableString

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

Example 89 with SpannableString

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

Example 90 with SpannableString

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

Aggregations

SpannableString (android.text.SpannableString)325 TextView (android.widget.TextView)61 Spannable (android.text.Spannable)60 View (android.view.View)57 StyleSpan (android.text.style.StyleSpan)53 ForegroundColorSpan (android.text.style.ForegroundColorSpan)47 TextPaint (android.text.TextPaint)25 Spanned (android.text.Spanned)24 TextAppearanceSpan (android.text.style.TextAppearanceSpan)21 Paint (android.graphics.Paint)20 RelativeSizeSpan (android.text.style.RelativeSizeSpan)19 ImageView (android.widget.ImageView)19 Bundle (android.os.Bundle)17 TypedValue (android.util.TypedValue)17 SmallTest (android.test.suitebuilder.annotation.SmallTest)16 Intent (android.content.Intent)15 SpannableStringBuilder (android.text.SpannableStringBuilder)15 ClickableSpan (android.text.style.ClickableSpan)14 URLSpan (android.text.style.URLSpan)13 LayoutInflater (android.view.LayoutInflater)13