Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/firstrun/ToSAndUMAFirstRunFragment.java

Issue 1774243003: Re-use NoUnderlineClickableSpan which shows a clickable link with underlines turned off (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webusb_android_chooser
Patch Set: more changes Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.firstrun; 5 package org.chromium.chrome.browser.firstrun;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.os.Bundle; 8 import android.os.Bundle;
9 import android.text.TextPaint; 9 import android.text.TextPaint;
10 import android.text.method.LinkMovementMethod; 10 import android.text.method.LinkMovementMethod;
11 import android.text.style.ClickableSpan;
12 import android.view.LayoutInflater; 11 import android.view.LayoutInflater;
13 import android.view.View; 12 import android.view.View;
14 import android.view.View.OnClickListener; 13 import android.view.View.OnClickListener;
15 import android.view.ViewGroup; 14 import android.view.ViewGroup;
16 import android.widget.Button; 15 import android.widget.Button;
17 import android.widget.CheckBox; 16 import android.widget.CheckBox;
18 import android.widget.TextView; 17 import android.widget.TextView;
19 18
20 import org.chromium.base.ApiCompatibilityUtils; 19 import org.chromium.base.ApiCompatibilityUtils;
21 import org.chromium.chrome.R; 20 import org.chromium.chrome.R;
22 import org.chromium.chrome.browser.preferences.PrefServiceBridge; 21 import org.chromium.chrome.browser.preferences.PrefServiceBridge;
22 import org.chromium.ui.text.NoUnderlineClickableSpan;
23 import org.chromium.ui.text.SpanApplier; 23 import org.chromium.ui.text.SpanApplier;
24 import org.chromium.ui.text.SpanApplier.SpanInfo; 24 import org.chromium.ui.text.SpanApplier.SpanInfo;
25 25
26 /** 26 /**
27 * The First Run Experience fragment that allows the user to accept Terms of Ser vice ("ToS") and 27 * The First Run Experience fragment that allows the user to accept Terms of Ser vice ("ToS") and
28 * Privacy Notice, and to opt-in to the usage statistics and crash reports colle ction ("UMA", 28 * Privacy Notice, and to opt-in to the usage statistics and crash reports colle ction ("UMA",
29 * User Metrics Analysis) as defined in the Chrome Privacy Notice. 29 * User Metrics Analysis) as defined in the Chrome Privacy Notice.
30 */ 30 */
31 public class ToSAndUMAFirstRunFragment extends FirstRunPage { 31 public class ToSAndUMAFirstRunFragment extends FirstRunPage {
32 private Button mAcceptButton; 32 private Button mAcceptButton;
(...skipping 25 matching lines...) Expand all
58 ApiCompatibilityUtils.setPaddingRelative(mSendReportCheckBox, 58 ApiCompatibilityUtils.setPaddingRelative(mSendReportCheckBox,
59 ApiCompatibilityUtils.getPaddingStart(mSendReportCheckBox) + pad dingStart, 59 ApiCompatibilityUtils.getPaddingStart(mSendReportCheckBox) + pad dingStart,
60 mSendReportCheckBox.getPaddingTop(), 60 mSendReportCheckBox.getPaddingTop(),
61 ApiCompatibilityUtils.getPaddingEnd(mSendReportCheckBox), 61 ApiCompatibilityUtils.getPaddingEnd(mSendReportCheckBox),
62 mSendReportCheckBox.getPaddingBottom()); 62 mSendReportCheckBox.getPaddingBottom());
63 63
64 mSendReportCheckBox.setChecked(!getPageDelegate().isNeverUploadCrashDump ()); 64 mSendReportCheckBox.setChecked(!getPageDelegate().isNeverUploadCrashDump ());
65 65
66 mTosAndPrivacy.setMovementMethod(LinkMovementMethod.getInstance()); 66 mTosAndPrivacy.setMovementMethod(LinkMovementMethod.getInstance());
67 67
68 int linkColor = getResources().getColor(R.color.ui_link_text_color); 68 int linkColor = getResources().getColor(R.color.ui_link_text_color);
newt (away) 2016/03/10 02:45:14 Get rid of linkColor and delete the FreClickableSp
juncai 2016/03/11 23:53:05 Done.
69 ClickableSpan clickableTermsSpan = new FreClickableSpan(linkColor) { 69 FreClickableSpan clickableTermsSpan = new FreClickableSpan(linkColor) {
70 @Override 70 @Override
71 public void onClick(View widget) { 71 public void onClick(View widget) {
72 if (!isAdded()) return; 72 if (!isAdded()) return;
73 getPageDelegate().showEmbedContentViewActivity(R.string.terms_of _service_title, 73 getPageDelegate().showEmbedContentViewActivity(R.string.terms_of _service_title,
74 R.string.chrome_terms_of_service_url); 74 R.string.chrome_terms_of_service_url);
75 } 75 }
76 }; 76 };
77 77
78 ClickableSpan clickablePrivacySpan = new FreClickableSpan(linkColor) { 78 FreClickableSpan clickablePrivacySpan = new FreClickableSpan(linkColor) {
79 @Override 79 @Override
80 public void onClick(View widget) { 80 public void onClick(View widget) {
81 if (!isAdded()) return; 81 if (!isAdded()) return;
82 getPageDelegate().showEmbedContentViewActivity(R.string.privacy_ notice_title, 82 getPageDelegate().showEmbedContentViewActivity(R.string.privacy_ notice_title,
83 R.string.chrome_privacy_notice_url); 83 R.string.chrome_privacy_notice_url);
84 } 84 }
85 }; 85 };
86 mTosAndPrivacy.setText(SpanApplier.applySpans(getString(R.string.fre_tos _and_privacy), 86 mTosAndPrivacy.setText(SpanApplier.applySpans(getString(R.string.fre_tos _and_privacy),
87 new SpanInfo("<LINK1>", "</LINK1>", clickableTermsSpan), 87 new SpanInfo("<LINK1>", "</LINK1>", clickableTermsSpan),
88 new SpanInfo("<LINK2>", "</LINK2>", clickablePrivacySpan))); 88 new SpanInfo("<LINK2>", "</LINK2>", clickablePrivacySpan)));
89 } 89 }
90 90
91 // TODO(peconn): Move this out into a more general class. 91 // TODO(peconn): Move this out into a more general class.
92 private abstract static class FreClickableSpan extends ClickableSpan { 92 private abstract static class FreClickableSpan extends NoUnderlineClickableS pan {
93 private final int mColor; 93 private final int mColor;
94 94
95 /** 95 /**
96 * Creates a clickable span that styles without an underline and uses th e given color. 96 * Creates a clickable span that styles without an underline and uses th e given color.
97 */ 97 */
98 public FreClickableSpan(int color) { 98 public FreClickableSpan(int color) {
99 mColor = color; 99 mColor = color;
100 } 100 }
101 101
102 @Override 102 @Override
103 public void updateDrawState(TextPaint textPaint) { 103 public void updateDrawState(TextPaint textPaint) {
104 super.updateDrawState(textPaint);
104 textPaint.setColor(mColor); 105 textPaint.setColor(mColor);
105 textPaint.setUnderlineText(false);
106 } 106 }
107 } 107 }
108 108
109 @Override 109 @Override
110 public boolean shouldSkipPageOnCreate(Context appContext) { 110 public boolean shouldSkipPageOnCreate(Context appContext) {
111 return PrefServiceBridge.getInstance().isFirstRunEulaAccepted(); 111 return PrefServiceBridge.getInstance().isFirstRunEulaAccepted();
112 } 112 }
113 } 113 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698