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

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 85%
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..6c57ea364a03b038ceb8e32b5af01f93a6714b0b 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,7 +2,7 @@
// 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.content.Context;
import android.graphics.Bitmap;
@@ -25,9 +25,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 +41,10 @@ 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
+ * {@link AccountSigninView#setListener(Listener)} after the view has been
* inflated.
*/
-public class AccountFirstRunView extends FrameLayout
+public class AccountSigninView extends FrameLayout
implements ImageCarouselPositionChangeListener, ProfileDownloader.Observer {
/**
@@ -59,7 +63,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
*/
@@ -82,6 +86,17 @@ public class AccountFirstRunView extends FrameLayout
* @param forcedAccountName The name of the forced-sign-in account
*/
public void onFailedToSetForcedAccount(String forcedAccountName);
+
+ /**
+ * The user has selected an account to sign into but has previous account information.
+ * You should deal with the conflict (for example displaying ConfirmImportSyncDataFragment)
+ * and ensure the callback is used afterwards.
+ * @param oldAccountName Name of the previously signed in account.
+ * @param newAccountName Name of the account we are hoping to sign in to.
+ * @param callback A callback that must be called after the conflict is dealt with.
+ */
+ public void onPreviousAccountFound(String oldAccountName, String newAccountName,
+ ConfirmImportSyncDataFragment.Listener callback);
}
private class SpinnerOnItemSelectedListener implements AdapterView.OnItemSelectedListener {
@@ -107,7 +122,7 @@ public class AccountFirstRunView extends FrameLayout
}
}
- private static final String TAG = "AccountFirstRunView";
+ private static final String TAG = "AccountSigninView";
private static final int EXPERIMENT_TITLE_VARIANT_MASK = 1;
private static final int EXPERIMENT_SUMMARY_VARIANT_MASK = 2;
@@ -140,7 +155,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());
}
@@ -182,16 +197,16 @@ public class AccountFirstRunView extends FrameLayout
mDescriptionText = (TextView) findViewById(R.id.description);
// For the spans to be clickable.
mDescriptionText.setMovementMethod(LinkMovementMethod.getInstance());
- mDescriptionTextId = R.string.fre_account_choice_description;
+ mDescriptionTextId = R.string.signin_account_choice_description;
// TODO(peconn): Ensure this is changed to R.string.cancel when used in Settings > Sign In.
- mCancelButtonTextId = R.string.fre_skip_text;
+ mCancelButtonTextId = R.string.no_thanks;
// Set the invisible TextView to contain the longest text the visible TextView can hold.
// It assumes that the signed in description for child accounts is the longest text.
((TextView) findViewById(R.id.longest_description)).setText(getSignedInDescription(true));
- mAddAnotherAccount = getResources().getString(R.string.fre_add_account);
+ mAddAnotherAccount = getResources().getString(R.string.signin_add_account);
mSpinner = (Spinner) findViewById(R.id.google_accounts_spinner);
mSpinnerBackground = mSpinner.getBackground();
@@ -213,13 +228,13 @@ public class AccountFirstRunView extends FrameLayout
public boolean performAccessibilityAction(View host, int action, Bundle args) {
if (mSpinner.getContentDescription() == null) {
mSpinner.setContentDescription(getResources().getString(
- R.string.accessibility_fre_account_spinner));
+ R.string.accessibility_signin_account_spinner));
}
return super.performAccessibilityAction(host, action, args);
}
});
- showSignInPage();
+ showSigninPage();
}
@Override
@@ -236,7 +251,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();
+ checkForPreviousAccountThenShowConfirmSigninPage();
}
}
}
@@ -247,7 +262,7 @@ public class AccountFirstRunView extends FrameLayout
assert MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY;
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = MeasureSpec.getSize(heightMeasureSpec);
- LinearLayout content = (LinearLayout) findViewById(R.id.fre_content);
+ LinearLayout content = (LinearLayout) findViewById(R.id.content);
int paddingStart = 0;
if (mHorizontalModeEnabled
&& width >= 2 * getResources().getDimension(R.dimen.fre_image_carousel_width)
@@ -297,7 +312,8 @@ public class AccountFirstRunView extends FrameLayout
}
mDescriptionTextId = (experimentGroup & EXPERIMENT_SUMMARY_VARIANT_MASK) != 0
- ? R.string.sign_in_to_chrome_summary_variant : R.string.sign_in_to_chrome_summary;
+ ? R.string.signin_sign_in_to_chrome_summary_variant
+ : R.string.sign_in_to_chrome_summary;
if ((experimentGroup & EXPERIMENT_LAYOUT_VARIANT_MASK) != 0) {
mImageCarousel.setVisibility(GONE);
@@ -307,7 +323,7 @@ public class AccountFirstRunView extends FrameLayout
illustrationView.setBackgroundColor(ApiCompatibilityUtils.getColor(getResources(),
R.color.illustration_background_color));
- LinearLayout linearLayout = (LinearLayout) findViewById(R.id.fre_account_linear_layout);
+ LinearLayout linearLayout = (LinearLayout) findViewById(R.id.account_linear_layout);
linearLayout.addView(illustrationView, 0);
}
}
@@ -359,14 +375,14 @@ 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);
- mDescriptionText.setText(R.string.fre_no_account_choice_description);
+ setUpSigninButton(false);
+ mDescriptionText.setText(R.string.signin_no_account_choice_description);
}
if (mProfileData != null) mProfileData.update();
@@ -438,18 +454,21 @@ public class AccountFirstRunView extends FrameLayout
if (name == null) name = mProfileData.getFullName(mAccountName);
}
if (name == null) name = mAccountName;
- String text = String.format(getResources().getString(R.string.fre_hi_name), name);
+ String text = String.format(getResources().getString(R.string.signin_hi_name), name);
mTitle.setText(text);
}
/**
* 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 +482,7 @@ public class AccountFirstRunView extends FrameLayout
mImageCarousel.setSignedInMode(false);
}
- private void showConfirmSignInPage() {
+ private void showConfirmSigninPage() {
mSignedIn = true;
updateProfileName();
@@ -499,6 +518,25 @@ public class AccountFirstRunView extends FrameLayout
mImageCarousel.setSignedInMode(true);
}
+ private void checkForPreviousAccountThenShowConfirmSigninPage() {
+ if (SigninInvestigator.investigate(mAccountName) == InvestigatedScenario.DIFFERENT_ACCOUNT
+ && mAccountName != PrefServiceBridge.getInstance().getSyncLastAccountName()) {
+
+ mListener.onPreviousAccountFound(
+ PrefServiceBridge.getInstance().getSyncLastAccountName(),
+ mAccountName,
+ new ConfirmImportSyncDataFragment.Listener(){
+ @Override
+ public void onConfirm() {
+ showConfirmSigninPage();
+ }
+ }
+ );
+ } else {
+ showConfirmSigninPage();
+ }
+ }
+
private void setUpCancelButton() {
setNegativeButtonVisible(true);
@@ -512,17 +550,17 @@ public class AccountFirstRunView extends FrameLayout
});
}
- private void setUpSignInButton(boolean hasAccounts) {
+ private void setUpSigninButton(boolean hasAccounts) {
if (hasAccounts) {
mPositiveButton.setText(R.string.choose_account_sign_in);
- mPositiveButton.setOnClickListener(new OnClickListener() {
+ mPositiveButton.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
- showConfirmSignInPage();
+ checkForPreviousAccountThenShowConfirmSigninPage();
}
});
} else {
- mPositiveButton.setText(R.string.fre_no_accounts);
+ mPositiveButton.setText(R.string.signin_no_accounts);
mPositiveButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
@@ -540,13 +578,13 @@ public class AccountFirstRunView extends FrameLayout
mNegativeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
- showSignInPage();
+ showSigninPage();
}
});
}
private void setUpConfirmButton() {
- mPositiveButton.setText(getResources().getText(R.string.fre_accept));
+ mPositiveButton.setText(getResources().getText(R.string.signin_accept));
mPositiveButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
@@ -568,10 +606,10 @@ public class AccountFirstRunView extends FrameLayout
private String getSignedInDescription(boolean childAccount) {
if (childAccount) {
- return getResources().getString(R.string.fre_signed_in_description) + '\n'
- + getResources().getString(R.string.fre_signed_in_description_uca_addendum);
+ return getResources().getString(R.string.signin_signed_in_description) + '\n'
+ + getResources().getString(R.string.signin_signed_in_description_uca_addendum);
} else {
- return getResources().getString(R.string.fre_signed_in_description);
+ return getResources().getString(R.string.signin_signed_in_description);
}
}

Powered by Google App Engine
This is Rietveld 408576698