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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/signin/AccountSigninView.java

Issue 1698043006: Created the dialog offering the user to merge their account data or keep it (Closed) Base URL: maybelle.lon.corp.google.com:/usr/local/google/code/clankium/src@sync_settings
Patch Set: Created 4 years, 10 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/signin/AccountSigninView.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/firstrun/AccountFirstRunView.java b/chrome/android/java/src/org/chromium/chrome/browser/signin/AccountSigninView.java
similarity index 87%
rename from chrome/android/java/src/org/chromium/chrome/browser/firstrun/AccountFirstRunView.java
rename to chrome/android/java/src/org/chromium/chrome/browser/signin/AccountSigninView.java
index 856c7d2bc0fc791d629afc0c546085aad5b44c80..2dd4c6c004a17e3f2805bafee84ef88c901d8924 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/firstrun/AccountFirstRunView.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/signin/AccountSigninView.java
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.chromium.chrome.browser.firstrun;
+package org.chromium.chrome.browser.signin;
+import android.app.Activity;
+import android.app.FragmentManager;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
@@ -25,9 +27,13 @@ import android.widget.TextView;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.chrome.R;
+import org.chromium.chrome.browser.firstrun.ImageCarousel;
import org.chromium.chrome.browser.firstrun.ImageCarousel.ImageCarouselPositionChangeListener;
+import org.chromium.chrome.browser.firstrun.ProfileDataCache;
+import org.chromium.chrome.browser.preferences.PrefServiceBridge;
import org.chromium.chrome.browser.profiles.ProfileDownloader;
-import org.chromium.chrome.browser.signin.SigninManager;
+import org.chromium.chrome.browser.sync.ui.ConfirmImportSyncDataFragment;
+import org.chromium.signin.InvestigatedScenario;
import org.chromium.sync.signin.AccountManagerHelper;
import org.chromium.ui.text.SpanApplier;
import org.chromium.ui.text.SpanApplier.SpanInfo;
@@ -37,10 +43,11 @@ import java.util.List;
/**
* This view allows the user to select an account to log in to, add an account,
* cancel account selection, etc. Users of this class should
- * {@link AccountFirstRunView#setListener(Listener)} after the view has been
- * inflated.
+ * {@link AccountSigninView#setListener(Listener)} after the view has been
+ * inflated and {@link AccountSigninView#setFragmentManager(FragmentManager)} if
+ * they expect previous sync account information will exist.
*/
-public class AccountFirstRunView extends FrameLayout
+public class AccountSigninView extends FrameLayout
implements ImageCarouselPositionChangeListener, ProfileDownloader.Observer {
/**
@@ -59,7 +66,7 @@ public class AccountFirstRunView extends FrameLayout
/**
* The user selected an account.
- * This call will be followed by either {@link #onSettingsClicked} or
+ * This call will be followed immediately by either {@link #onSettingsClicked} or
* {@link #onDoneClicked}.
* @param accountName The name of the account
*/
@@ -117,6 +124,9 @@ public class AccountFirstRunView extends FrameLayout
private static final String SETTINGS_LINK_OPEN = "<LINK1>";
private static final String SETTINGS_LINK_CLOSE = "</LINK1>";
+ private static final String CONFIRM_IMPORT_SYNC_DATA_DIALOG_TAG =
+ "signin_import_data_tag";
+
private AccountManagerHelper mAccountManagerHelper;
private List<String> mAccountNames;
private ArrayAdapter<CharSequence> mArrayAdapter;
@@ -132,6 +142,7 @@ public class AccountFirstRunView extends FrameLayout
private String mAccountName;
private String mAddAnotherAccount;
private ProfileDataCache mProfileData;
+ private FragmentManager mFragmentManager;
private boolean mSignedIn;
private boolean mPositionSetProgrammatically;
private int mDescriptionTextId;
@@ -140,7 +151,7 @@ public class AccountFirstRunView extends FrameLayout
private boolean mHorizontalModeEnabled = true;
private boolean mShowSettingsSpan = true;
- public AccountFirstRunView(Context context, AttributeSet attrs) {
+ public AccountSigninView(Context context, AttributeSet attrs) {
super(context, attrs);
mAccountManagerHelper = AccountManagerHelper.get(getContext().getApplicationContext());
}
@@ -219,7 +230,7 @@ public class AccountFirstRunView extends FrameLayout
}
});
- showSignInPage();
+ showSigninPage();
}
@Override
@@ -236,7 +247,7 @@ public class AccountFirstRunView extends FrameLayout
// A new account has been added and the visibility has returned to us.
// The updateAccounts function will have selected the new account.
// Shortcut to confirm sign in page.
- showConfirmSignInPage();
+ showConfirmSigninPage();
}
}
}
@@ -332,6 +343,16 @@ public class AccountFirstRunView extends FrameLayout
}
/**
+ * Set the FragmentManager. This is required to show the confirmation dialog asking if the user
+ * wants to merge their data with the previous account's data.
+ *
+ * @param fragmentManager The FragmentManager.
+ */
+ public void setFragmentManager(FragmentManager fragmentManager) {
+ mFragmentManager = fragmentManager;
+ }
+
+ /**
* Refresh the list of available system account.
* @return Whether any new accounts were added (the first newly added account will now be
* selected).
@@ -359,13 +380,13 @@ public class AccountFirstRunView extends FrameLayout
mArrayAdapter.addAll(mAccountNames);
mArrayAdapter.add(mAddAnotherAccount);
- setUpSignInButton(true);
+ setUpSigninButton(true);
mDescriptionText.setText(mDescriptionTextId);
} else {
mSpinner.setVisibility(View.GONE);
mArrayAdapter.add(mAddAnotherAccount);
- setUpSignInButton(false);
+ setUpSigninButton(false);
mDescriptionText.setText(R.string.fre_no_account_choice_description);
}
@@ -444,12 +465,15 @@ public class AccountFirstRunView extends FrameLayout
/**
* Updates the view to show that sign in has completed.
+ * This should only be used if the user is not currently signed in (eg on the First
+ * Run Experience).
*/
public void switchToSignedMode() {
- showConfirmSignInPage();
+ // TODO(peconn): Add a warning here
+ showConfirmSigninPage();
}
- private void showSignInPage() {
+ private void showSigninPage() {
mSignedIn = false;
mTitle.setText(R.string.sign_in_to_chrome);
@@ -463,7 +487,7 @@ public class AccountFirstRunView extends FrameLayout
mImageCarousel.setSignedInMode(false);
}
- private void showConfirmSignInPage() {
+ private void showConfirmSigninPage() {
mSignedIn = true;
updateProfileName();
@@ -512,15 +536,12 @@ public class AccountFirstRunView extends FrameLayout
});
}
- private void setUpSignInButton(boolean hasAccounts) {
+ private void setUpSigninButton(boolean hasAccounts) {
if (hasAccounts) {
+ ((Activity) getContext()).getFragmentManager();
Yusuf 2016/02/18 19:16:16 (Activity) getContext() is a fairly dangerous assu
PEConn 2016/02/19 18:10:11 Sorry, that line should have been removed.
+
mPositiveButton.setText(R.string.choose_account_sign_in);
- mPositiveButton.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- showConfirmSignInPage();
- }
- });
+ mPositiveButton.setOnClickListener(new SigninButtonOnClickListener());
} else {
mPositiveButton.setText(R.string.fre_no_accounts);
mPositiveButton.setOnClickListener(new OnClickListener() {
@@ -532,6 +553,33 @@ public class AccountFirstRunView extends FrameLayout
}
}
+ private class SigninButtonOnClickListener implements OnClickListener {
+ @Override
+ public void onClick(View v) {
+ if (mFragmentManager != null
+ && SigninInvestigator.investigate(mAccountName)
+ == InvestigatedScenario.DIFFERENT_ACCOUNT
Yusuf 2016/02/18 19:16:16 8 spaces
PEConn 2016/02/19 18:10:11 Done.
+ && mAccountName != PrefServiceBridge.getInstance().getSyncLastAccountName()) {
+
+ ConfirmImportSyncDataFragment confirmSync =
+ ConfirmImportSyncDataFragment.newInstance(
+ PrefServiceBridge.getInstance().getSyncLastAccountName(),
+ mAccountName);
+
+ confirmSync.setListener(new ConfirmImportSyncDataFragment.Listener(){
+ @Override
+ public void onConfirm() {
+ showConfirmSigninPage();
+ }
+ });
+
+ confirmSync.show(mFragmentManager, CONFIRM_IMPORT_SYNC_DATA_DIALOG_TAG);
Yusuf 2016/02/18 19:16:16 Instead of setting a FragmentManager for this clas
PEConn 2016/02/19 18:10:10 Before a Fragment is shown, it's getFragment retur
+ } else {
+ showConfirmSigninPage();
+ }
+ }
+ }
+
private void setUpUndoButton() {
setNegativeButtonVisible(!isInForcedAccountMode());
if (isInForcedAccountMode()) return;
@@ -540,7 +588,7 @@ public class AccountFirstRunView extends FrameLayout
mNegativeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
- showSignInPage();
+ showSigninPage();
}
});
}

Powered by Google App Engine
This is Rietveld 408576698