OLD | NEW |
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; | |
10 import android.text.method.LinkMovementMethod; | 9 import android.text.method.LinkMovementMethod; |
11 import android.text.style.ClickableSpan; | |
12 import android.view.LayoutInflater; | 10 import android.view.LayoutInflater; |
13 import android.view.View; | 11 import android.view.View; |
14 import android.view.View.OnClickListener; | 12 import android.view.View.OnClickListener; |
15 import android.view.ViewGroup; | 13 import android.view.ViewGroup; |
16 import android.widget.Button; | 14 import android.widget.Button; |
17 import android.widget.CheckBox; | 15 import android.widget.CheckBox; |
18 import android.widget.TextView; | 16 import android.widget.TextView; |
19 | 17 |
20 import org.chromium.base.ApiCompatibilityUtils; | 18 import org.chromium.base.ApiCompatibilityUtils; |
21 import org.chromium.chrome.R; | 19 import org.chromium.chrome.R; |
22 import org.chromium.chrome.browser.ChromeVersionInfo; | 20 import org.chromium.chrome.browser.ChromeVersionInfo; |
23 import org.chromium.chrome.browser.preferences.PrefServiceBridge; | 21 import org.chromium.chrome.browser.preferences.PrefServiceBridge; |
| 22 import org.chromium.ui.text.NoUnderlineClickableSpan; |
24 import org.chromium.ui.text.SpanApplier; | 23 import org.chromium.ui.text.SpanApplier; |
25 import org.chromium.ui.text.SpanApplier.SpanInfo; | 24 import org.chromium.ui.text.SpanApplier.SpanInfo; |
26 | 25 |
27 /** | 26 /** |
28 * 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 |
29 * 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", |
30 * User Metrics Analysis) as defined in the Chrome Privacy Notice. | 29 * User Metrics Analysis) as defined in the Chrome Privacy Notice. |
31 */ | 30 */ |
32 public class ToSAndUMAFirstRunFragment extends FirstRunPage { | 31 public class ToSAndUMAFirstRunFragment extends FirstRunPage { |
33 private Button mAcceptButton; | 32 private Button mAcceptButton; |
(...skipping 30 matching lines...) Expand all Loading... |
64 ApiCompatibilityUtils.getPaddingEnd(mSendReportCheckBox), | 63 ApiCompatibilityUtils.getPaddingEnd(mSendReportCheckBox), |
65 mSendReportCheckBox.getPaddingBottom()); | 64 mSendReportCheckBox.getPaddingBottom()); |
66 | 65 |
67 mSendReportCheckBox.setChecked(!getPageDelegate().isNeverUploadCrash
Dump()); | 66 mSendReportCheckBox.setChecked(!getPageDelegate().isNeverUploadCrash
Dump()); |
68 } else { | 67 } else { |
69 mSendReportCheckBox.setVisibility(View.GONE); | 68 mSendReportCheckBox.setVisibility(View.GONE); |
70 } | 69 } |
71 | 70 |
72 mTosAndPrivacy.setMovementMethod(LinkMovementMethod.getInstance()); | 71 mTosAndPrivacy.setMovementMethod(LinkMovementMethod.getInstance()); |
73 | 72 |
74 int linkColor = getResources().getColor(R.color.ui_link_text_color); | 73 NoUnderlineClickableSpan clickableTermsSpan = new NoUnderlineClickableSp
an() { |
75 ClickableSpan clickableTermsSpan = new FreClickableSpan(linkColor) { | |
76 @Override | 74 @Override |
77 public void onClick(View widget) { | 75 public void onClick(View widget) { |
78 if (!isAdded()) return; | 76 if (!isAdded()) return; |
79 getPageDelegate().showEmbedContentViewActivity(R.string.terms_of
_service_title, | 77 getPageDelegate().showEmbedContentViewActivity(R.string.terms_of
_service_title, |
80 R.string.chrome_terms_of_service_url); | 78 R.string.chrome_terms_of_service_url); |
81 } | 79 } |
82 }; | 80 }; |
83 | 81 |
84 ClickableSpan clickablePrivacySpan = new FreClickableSpan(linkColor) { | 82 NoUnderlineClickableSpan clickablePrivacySpan = new NoUnderlineClickable
Span() { |
85 @Override | 83 @Override |
86 public void onClick(View widget) { | 84 public void onClick(View widget) { |
87 if (!isAdded()) return; | 85 if (!isAdded()) return; |
88 getPageDelegate().showEmbedContentViewActivity(R.string.privacy_
notice_title, | 86 getPageDelegate().showEmbedContentViewActivity(R.string.privacy_
notice_title, |
89 R.string.chrome_privacy_notice_url); | 87 R.string.chrome_privacy_notice_url); |
90 } | 88 } |
91 }; | 89 }; |
92 mTosAndPrivacy.setText(SpanApplier.applySpans(getString(R.string.fre_tos
_and_privacy), | 90 mTosAndPrivacy.setText(SpanApplier.applySpans(getString(R.string.fre_tos
_and_privacy), |
93 new SpanInfo("<LINK1>", "</LINK1>", clickableTermsSpan), | 91 new SpanInfo("<LINK1>", "</LINK1>", clickableTermsSpan), |
94 new SpanInfo("<LINK2>", "</LINK2>", clickablePrivacySpan))); | 92 new SpanInfo("<LINK2>", "</LINK2>", clickablePrivacySpan))); |
95 } | 93 } |
96 | 94 |
97 // TODO(peconn): Move this out into a more general class. | |
98 private abstract static class FreClickableSpan extends ClickableSpan { | |
99 private final int mColor; | |
100 | |
101 /** | |
102 * Creates a clickable span that styles without an underline and uses th
e given color. | |
103 */ | |
104 public FreClickableSpan(int color) { | |
105 mColor = color; | |
106 } | |
107 | |
108 @Override | |
109 public void updateDrawState(TextPaint textPaint) { | |
110 textPaint.setColor(mColor); | |
111 textPaint.setUnderlineText(false); | |
112 } | |
113 } | |
114 | |
115 @Override | 95 @Override |
116 public boolean shouldSkipPageOnCreate(Context appContext) { | 96 public boolean shouldSkipPageOnCreate(Context appContext) { |
117 return PrefServiceBridge.getInstance().isFirstRunEulaAccepted(); | 97 return PrefServiceBridge.getInstance().isFirstRunEulaAccepted(); |
118 } | 98 } |
119 } | 99 } |
OLD | NEW |