Search in sources :

Example 6 with NoUnderlineClickableSpan

use of org.chromium.ui.text.NoUnderlineClickableSpan in project AndroidChromium by JackyAndroid.

the class ToSAndUMAFirstRunFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mAcceptButton = (Button) view.findViewById(R.id.terms_accept);
    mSendReportCheckBox = (CheckBox) view.findViewById(R.id.send_report_checkbox);
    mTosAndPrivacy = (TextView) view.findViewById(R.id.tos_and_privacy);
    mAcceptButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            getPageDelegate().acceptTermsOfService(mSendReportCheckBox.isChecked());
        }
    });
    if (ChromeVersionInfo.isOfficialBuild()) {
        int paddingStart = getResources().getDimensionPixelSize(R.dimen.fre_tos_checkbox_padding);
        ApiCompatibilityUtils.setPaddingRelative(mSendReportCheckBox, ApiCompatibilityUtils.getPaddingStart(mSendReportCheckBox) + paddingStart, mSendReportCheckBox.getPaddingTop(), ApiCompatibilityUtils.getPaddingEnd(mSendReportCheckBox), mSendReportCheckBox.getPaddingBottom());
        mSendReportCheckBox.setChecked(FirstRunActivity.DEFAULT_METRICS_AND_CRASH_REPORTING);
    } else {
        mSendReportCheckBox.setVisibility(View.GONE);
    }
    mTosAndPrivacy.setMovementMethod(LinkMovementMethod.getInstance());
    NoUnderlineClickableSpan clickableTermsSpan = new NoUnderlineClickableSpan() {

        @Override
        public void onClick(View widget) {
            if (!isAdded())
                return;
            getPageDelegate().showEmbedContentViewActivity(R.string.terms_of_service_title, R.string.chrome_terms_of_service_url);
        }
    };
    NoUnderlineClickableSpan clickablePrivacySpan = new NoUnderlineClickableSpan() {

        @Override
        public void onClick(View widget) {
            if (!isAdded())
                return;
            getPageDelegate().showEmbedContentViewActivity(R.string.privacy_notice_title, R.string.chrome_privacy_notice_url);
        }
    };
    mTosAndPrivacy.setText(SpanApplier.applySpans(getString(R.string.fre_tos_and_privacy), new SpanInfo("<LINK1>", "</LINK1>", clickableTermsSpan), new SpanInfo("<LINK2>", "</LINK2>", clickablePrivacySpan)));
}
Also used : NoUnderlineClickableSpan(org.chromium.ui.text.NoUnderlineClickableSpan) OnClickListener(android.view.View.OnClickListener) SpanInfo(org.chromium.ui.text.SpanApplier.SpanInfo) TextView(android.widget.TextView) View(android.view.View)

Example 7 with NoUnderlineClickableSpan

use of org.chromium.ui.text.NoUnderlineClickableSpan in project AndroidChromium by JackyAndroid.

the class TextMessageWithLinkAndIconPreference method setSummary.

@Override
public void setSummary(CharSequence summary) {
    // If there is no link in the summary, invoke the default behavior.
    String summaryString = summary.toString();
    if (!summaryString.contains("<link>") || !summaryString.contains("</link>")) {
        super.setSummary(summary);
        return;
    }
    // Linkify <link></link> span.
    final SpannableString summaryWithLink = SpanApplier.applySpans(summaryString, new SpanApplier.SpanInfo("<link>", "</link>", new NoUnderlineClickableSpan() {

        @Override
        public void onClick(View widget) {
            if (mLinkClickDelegate != null)
                mLinkClickDelegate.run();
        }
    }));
    super.setSummary(summaryWithLink);
}
Also used : SpannableString(android.text.SpannableString) SpanApplier(org.chromium.ui.text.SpanApplier) NoUnderlineClickableSpan(org.chromium.ui.text.NoUnderlineClickableSpan) SpannableString(android.text.SpannableString) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 8 with NoUnderlineClickableSpan

use of org.chromium.ui.text.NoUnderlineClickableSpan in project AndroidChromium by JackyAndroid.

the class OtherFormsOfHistoryDialogFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    super.onCreateDialog(savedInstanceState);
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View view = inflater.inflate(R.layout.other_forms_of_history_dialog, null);
    // Linkify the <link></link> span in the dialog text.
    TextView textView = (TextView) view.findViewById(R.id.text);
    final SpannableString textWithLink = SpanApplier.applySpans(textView.getText().toString(), new SpanApplier.SpanInfo("<link>", "</link>", new NoUnderlineClickableSpan() {

        @Override
        public void onClick(View widget) {
            new TabDelegate(false).launchUrl(WEB_HISTORY_URL, TabLaunchType.FROM_CHROME_UI);
        }
    }));
    textView.setText(textWithLink);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    // Construct the dialog.
    AlertDialog dialog = new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme).setView(view).setTitle(R.string.clear_browsing_data_history_dialog_title).setPositiveButton(R.string.ok_got_it, this).create();
    dialog.setCanceledOnTouchOutside(false);
    return dialog;
}
Also used : SpannableString(android.text.SpannableString) AlertDialog(android.support.v7.app.AlertDialog) SpanApplier(org.chromium.ui.text.SpanApplier) LayoutInflater(android.view.LayoutInflater) NoUnderlineClickableSpan(org.chromium.ui.text.NoUnderlineClickableSpan) TextView(android.widget.TextView) TabDelegate(org.chromium.chrome.browser.tabmodel.document.TabDelegate) TextView(android.widget.TextView) View(android.view.View)

Example 9 with NoUnderlineClickableSpan

use of org.chromium.ui.text.NoUnderlineClickableSpan in project AndroidChromium by JackyAndroid.

the class SadTabViewFactory method getHelpMessage.

/**
     * Construct and return help message to be displayed on R.id.sad_tab_message.
     * @param context Context of the resulting Sad Tab view. This is needed to load the strings.
     * @param suggestionAction Action to be executed when user clicks "try these suggestions".
     * @return Help message to be displayed on R.id.sad_tab_message.
     */
private static CharSequence getHelpMessage(Context context, final OnClickListener suggestionAction) {
    String helpMessage = context.getString(R.string.sad_tab_message) + "\n\n" + context.getString(R.string.sad_tab_suggestions);
    NoUnderlineClickableSpan span = new NoUnderlineClickableSpan() {

        @Override
        public void onClick(View view) {
            suggestionAction.onClick(view);
        }
    };
    return SpanApplier.applySpans(helpMessage, new SpanInfo("<link>", "</link>", span));
}
Also used : NoUnderlineClickableSpan(org.chromium.ui.text.NoUnderlineClickableSpan) SpanInfo(org.chromium.ui.text.SpanApplier.SpanInfo) TextView(android.widget.TextView) View(android.view.View)

Aggregations

View (android.view.View)9 NoUnderlineClickableSpan (org.chromium.ui.text.NoUnderlineClickableSpan)9 TextView (android.widget.TextView)8 SpanInfo (org.chromium.ui.text.SpanApplier.SpanInfo)5 SpannableString (android.text.SpannableString)4 LayoutInflater (android.view.LayoutInflater)2 OnClickListener (android.view.View.OnClickListener)2 Button (android.widget.Button)2 ImageView (android.widget.ImageView)2 SpanApplier (org.chromium.ui.text.SpanApplier)2 AlertDialog (android.support.v7.app.AlertDialog)1 LayoutParams (android.widget.RelativeLayout.LayoutParams)1 VisibleForTesting (org.chromium.base.VisibleForTesting)1 Profile (org.chromium.chrome.browser.profiles.Profile)1 TabDelegate (org.chromium.chrome.browser.tabmodel.document.TabDelegate)1