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

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

Issue 2561433002: Make FirstRunActivity extend AsyncInitializationActivity. (Closed)
Patch Set: Update UX. Created 3 years, 11 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.method.LinkMovementMethod; 9 import android.text.method.LinkMovementMethod;
10 import android.view.LayoutInflater; 10 import android.view.LayoutInflater;
(...skipping 13 matching lines...) Expand all
24 24
25 /** 25 /**
26 * The First Run Experience fragment that allows the user to accept Terms of Ser vice ("ToS") and 26 * The First Run Experience fragment that allows the user to accept Terms of Ser vice ("ToS") and
27 * Privacy Notice, and to opt-in to the usage statistics and crash reports colle ction ("UMA", 27 * Privacy Notice, and to opt-in to the usage statistics and crash reports colle ction ("UMA",
28 * User Metrics Analysis) as defined in the Chrome Privacy Notice. 28 * User Metrics Analysis) as defined in the Chrome Privacy Notice.
29 */ 29 */
30 public class ToSAndUMAFirstRunFragment extends FirstRunPage { 30 public class ToSAndUMAFirstRunFragment extends FirstRunPage {
31 private Button mAcceptButton; 31 private Button mAcceptButton;
32 private CheckBox mSendReportCheckBox; 32 private CheckBox mSendReportCheckBox;
33 private TextView mTosAndPrivacy; 33 private TextView mTosAndPrivacy;
34 private View mTitle;
35 private View mProgressSpinner;
36 private boolean mNativeInitialized;
37 private boolean mTriggerAcceptAfterNativeInit;
34 38
35 @Override 39 @Override
36 public View onCreateView( 40 public View onCreateView(
37 LayoutInflater inflater, ViewGroup container, Bundle savedInstanceSt ate) { 41 LayoutInflater inflater, ViewGroup container, Bundle savedInstanceSt ate) {
38 return inflater.inflate(R.layout.fre_tosanduma, container, false); 42 return inflater.inflate(R.layout.fre_tosanduma, container, false);
39 } 43 }
40 44
41 @Override 45 @Override
42 public void onViewCreated(View view, Bundle savedInstanceState) { 46 public void onViewCreated(View view, Bundle savedInstanceState) {
43 super.onViewCreated(view, savedInstanceState); 47 super.onViewCreated(view, savedInstanceState);
44 48
49 mTitle = view.findViewById(R.id.title);
50 mProgressSpinner = view.findViewById(R.id.progress_spinner);
51 mProgressSpinner.setVisibility(View.GONE);
45 mAcceptButton = (Button) view.findViewById(R.id.terms_accept); 52 mAcceptButton = (Button) view.findViewById(R.id.terms_accept);
46 mSendReportCheckBox = (CheckBox) view.findViewById(R.id.send_report_chec kbox); 53 mSendReportCheckBox = (CheckBox) view.findViewById(R.id.send_report_chec kbox);
47 mTosAndPrivacy = (TextView) view.findViewById(R.id.tos_and_privacy); 54 mTosAndPrivacy = (TextView) view.findViewById(R.id.tos_and_privacy);
48 55
49 mAcceptButton.setOnClickListener(new OnClickListener() { 56 mAcceptButton.setOnClickListener(new OnClickListener() {
50 @Override 57 @Override
51 public void onClick(View v) { 58 public void onClick(View v) {
52 getPageDelegate().acceptTermsOfService(mSendReportCheckBox.isChe cked()); 59 acceptTermsOfService();
53 } 60 }
54 }); 61 });
55 62
56 if (ChromeVersionInfo.isOfficialBuild()) { 63 if (ChromeVersionInfo.isOfficialBuild()) {
57 int paddingStart = getResources().getDimensionPixelSize( 64 int paddingStart = getResources().getDimensionPixelSize(
58 R.dimen.fre_tos_checkbox_padding); 65 R.dimen.fre_tos_checkbox_padding);
59 ApiCompatibilityUtils.setPaddingRelative(mSendReportCheckBox, 66 ApiCompatibilityUtils.setPaddingRelative(mSendReportCheckBox,
60 ApiCompatibilityUtils.getPaddingStart(mSendReportCheckBox) + paddingStart, 67 ApiCompatibilityUtils.getPaddingStart(mSendReportCheckBox) + paddingStart,
61 mSendReportCheckBox.getPaddingTop(), 68 mSendReportCheckBox.getPaddingTop(),
62 ApiCompatibilityUtils.getPaddingEnd(mSendReportCheckBox), 69 ApiCompatibilityUtils.getPaddingEnd(mSendReportCheckBox),
(...skipping 17 matching lines...) Expand all
80 NoUnderlineClickableSpan clickablePrivacySpan = new NoUnderlineClickable Span() { 87 NoUnderlineClickableSpan clickablePrivacySpan = new NoUnderlineClickable Span() {
81 @Override 88 @Override
82 public void onClick(View widget) { 89 public void onClick(View widget) {
83 if (!isAdded()) return; 90 if (!isAdded()) return;
84 getPageDelegate().showInfoPage(R.string.chrome_privacy_notice_ur l); 91 getPageDelegate().showInfoPage(R.string.chrome_privacy_notice_ur l);
85 } 92 }
86 }; 93 };
87 mTosAndPrivacy.setText(SpanApplier.applySpans(getString(R.string.fre_tos _and_privacy), 94 mTosAndPrivacy.setText(SpanApplier.applySpans(getString(R.string.fre_tos _and_privacy),
88 new SpanInfo("<LINK1>", "</LINK1>", clickableTermsSpan), 95 new SpanInfo("<LINK1>", "</LINK1>", clickableTermsSpan),
89 new SpanInfo("<LINK2>", "</LINK2>", clickablePrivacySpan))); 96 new SpanInfo("<LINK2>", "</LINK2>", clickablePrivacySpan)));
97
98 // If this page should be skipped, hide all the UI elements except for t he
99 // Chrome logo and the spinner.
100 if (FirstRunStatus.shouldSkipWelcomePage()) {
101 setSpinnerVisible(true);
102 }
90 } 103 }
91 104
92 @Override 105 @Override
93 public void setUserVisibleHint(boolean isVisibleToUser) { 106 public void setUserVisibleHint(boolean isVisibleToUser) {
94 super.setUserVisibleHint(isVisibleToUser); 107 super.setUserVisibleHint(isVisibleToUser);
95 if (isVisibleToUser && mSendReportCheckBox != null) { 108
109 if (!isVisibleToUser) {
110 // Restore original enabled & visibility states, in case the user re turns to the page.
111 setSpinnerVisible(false);
112 } else if (mSendReportCheckBox != null) {
96 // On certain versions of Android, the checkbox will appear unchecke d upon revisiting 113 // On certain versions of Android, the checkbox will appear unchecke d upon revisiting
97 // the page. Force it to the end state of the drawable animation as a work around. 114 // the page. Force it to the end state of the drawable animation as a work around.
98 // crbug.com/666258 115 // crbug.com/666258
99 mSendReportCheckBox.jumpDrawablesToCurrentState(); 116 mSendReportCheckBox.jumpDrawablesToCurrentState();
100 } 117 }
101 } 118 }
102 119
103 @Override 120 @Override
104 public boolean shouldSkipPageOnCreate(Context appContext) { 121 public boolean shouldSkipPageOnCreate(Context appContext) {
105 return FirstRunStatus.shouldSkipWelcomePage(); 122 return FirstRunStatus.shouldSkipWelcomePage();
106 } 123 }
124
125 @Override
126 public boolean shouldRecreatePageOnDataChange() {
127 // Specify that this page shouldn't be re-created on notifyDataSetChange d(), so
128 // that state like mTriggerAcceptAfterNativeInit can be preserved on the instance
129 // when native is initialized.
130 return false;
131 }
132
133 @Override
134 protected void onNativeInitialized() {
135 assert !mNativeInitialized;
136
137 mNativeInitialized = true;
138 if (mTriggerAcceptAfterNativeInit) acceptTermsOfService();
139 }
140
141 private void acceptTermsOfService() {
142 if (!mNativeInitialized) {
143 mTriggerAcceptAfterNativeInit = true;
144 setSpinnerVisible(true);
145 return;
146 }
147
148 mTriggerAcceptAfterNativeInit = false;
149 getPageDelegate().acceptTermsOfService(mSendReportCheckBox.isChecked());
150 }
151
152 private void setSpinnerVisible(boolean spinnerVisible) {
153 // When the progress spinner is visibile, we hide the other UI elements so that
154 // the user can't interact with them.
155 int otherElementsVisible = spinnerVisible ? View.INVISIBLE : View.VISIBL E;
156 mTitle.setVisibility(otherElementsVisible);
157 mAcceptButton.setVisibility(otherElementsVisible);
158 mTosAndPrivacy.setVisibility(otherElementsVisible);
159 mSendReportCheckBox.setVisibility(otherElementsVisible);
160 mProgressSpinner.setVisibility(spinnerVisible ? View.VISIBLE : View.GONE );
161 }
107 } 162 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698