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)));
}
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);
}
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;
}
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));
}
Aggregations