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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/firstrun/ToSAndUMAFirstRunFragment.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/firstrun/ToSAndUMAFirstRunFragment.java b/chrome/android/java/src/org/chromium/chrome/browser/firstrun/ToSAndUMAFirstRunFragment.java
index 3c4c4f53cee4271ac3a1456b9f90aac43428426a..858c51b56d01bc0eda192f3d2159f638f4c6c012 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/firstrun/ToSAndUMAFirstRunFragment.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/firstrun/ToSAndUMAFirstRunFragment.java
@@ -31,6 +31,10 @@ public class ToSAndUMAFirstRunFragment extends FirstRunPage {
private Button mAcceptButton;
private CheckBox mSendReportCheckBox;
private TextView mTosAndPrivacy;
+ private View mTitle;
+ private View mProgressSpinner;
+ private boolean mNativeInitialized;
+ private boolean mTriggerAcceptAfterNativeInit;
@Override
public View onCreateView(
@@ -42,6 +46,9 @@ public class ToSAndUMAFirstRunFragment extends FirstRunPage {
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
+ mTitle = view.findViewById(R.id.title);
+ mProgressSpinner = view.findViewById(R.id.progress_spinner);
+ mProgressSpinner.setVisibility(View.GONE);
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);
@@ -49,7 +56,7 @@ public class ToSAndUMAFirstRunFragment extends FirstRunPage {
mAcceptButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
- getPageDelegate().acceptTermsOfService(mSendReportCheckBox.isChecked());
+ acceptTermsOfService();
}
});
@@ -87,12 +94,22 @@ public class ToSAndUMAFirstRunFragment extends FirstRunPage {
mTosAndPrivacy.setText(SpanApplier.applySpans(getString(R.string.fre_tos_and_privacy),
new SpanInfo("<LINK1>", "</LINK1>", clickableTermsSpan),
new SpanInfo("<LINK2>", "</LINK2>", clickablePrivacySpan)));
+
+ // If this page should be skipped, hide all the UI elements except for the
+ // Chrome logo and the spinner.
+ if (FirstRunStatus.shouldSkipWelcomePage()) {
+ setSpinnerVisible(true);
+ }
}
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
- if (isVisibleToUser && mSendReportCheckBox != null) {
+
+ if (!isVisibleToUser) {
+ // Restore original enabled & visibility states, in case the user returns to the page.
+ setSpinnerVisible(false);
+ } else if (mSendReportCheckBox != null) {
// On certain versions of Android, the checkbox will appear unchecked upon revisiting
// the page. Force it to the end state of the drawable animation as a work around.
// crbug.com/666258
@@ -104,4 +121,42 @@ public class ToSAndUMAFirstRunFragment extends FirstRunPage {
public boolean shouldSkipPageOnCreate(Context appContext) {
return FirstRunStatus.shouldSkipWelcomePage();
}
+
+ @Override
+ public boolean shouldRecreatePageOnDataChange() {
+ // Specify that this page shouldn't be re-created on notifyDataSetChanged(), so
+ // that state like mTriggerAcceptAfterNativeInit can be preserved on the instance
+ // when native is initialized.
+ return false;
+ }
+
+ @Override
+ protected void onNativeInitialized() {
+ assert !mNativeInitialized;
+
+ mNativeInitialized = true;
+ if (mTriggerAcceptAfterNativeInit) acceptTermsOfService();
+ }
+
+ private void acceptTermsOfService() {
+ if (!mNativeInitialized) {
+ mTriggerAcceptAfterNativeInit = true;
+ setSpinnerVisible(true);
+ return;
+ }
+
+ mTriggerAcceptAfterNativeInit = false;
+ getPageDelegate().acceptTermsOfService(mSendReportCheckBox.isChecked());
+ }
+
+ private void setSpinnerVisible(boolean spinnerVisible) {
+ // When the progress spinner is visibile, we hide the other UI elements so that
+ // the user can't interact with them.
+ int otherElementsVisible = spinnerVisible ? View.INVISIBLE : View.VISIBLE;
+ mTitle.setVisibility(otherElementsVisible);
+ mAcceptButton.setVisibility(otherElementsVisible);
+ mTosAndPrivacy.setVisibility(otherElementsVisible);
+ mSendReportCheckBox.setVisibility(otherElementsVisible);
+ mProgressSpinner.setVisibility(spinnerVisible ? View.VISIBLE : View.GONE);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698