Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/signin/AccountSigninActivity.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/signin/AccountSigninActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/signin/AccountSigninActivity.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..33ee0e3d008e7e1b6cca916bf503ecc314831ada |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/signin/AccountSigninActivity.java |
| @@ -0,0 +1,95 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// 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.signin; |
| + |
| +import android.app.Activity; |
| +import android.content.Intent; |
| +import android.os.Bundle; |
| +import android.view.LayoutInflater; |
| + |
| +import org.chromium.chrome.R; |
| +import org.chromium.chrome.browser.firstrun.ProfileDataCache; |
| +import org.chromium.chrome.browser.preferences.Preferences; |
| +import org.chromium.chrome.browser.preferences.PreferencesLauncher; |
| +import org.chromium.chrome.browser.profiles.Profile; |
| +import org.chromium.chrome.browser.sync.ui.SyncCustomizationFragment; |
| + |
| +/** |
| + * An Activity displayed from the MainPreferences to allow the user to pick an account to |
| + * sign in to. |
| + */ |
| +public class AccountSigninActivity extends Activity |
|
Yusuf
2016/02/18 19:16:16
extends AppcompatActivity for getting themes to wo
PEConn
2016/02/19 18:10:10
Done.
|
| + implements AccountSigninView.Listener, SigninManager.SignInCallback{ |
| + private static final String TAG = "AccountSigninFragment"; |
| + |
| + private AccountSigninView mView; |
| + private String mAccountName; |
| + private boolean mShowSyncSettings = false; |
| + |
| + @Override |
| + protected void onCreate(Bundle savedInstanceState) { |
| + super.onCreate(savedInstanceState); |
| + |
| + mView = (AccountSigninView) LayoutInflater.from(this).inflate( |
| + R.layout.account_signin_view, null); |
| + mView.init(new ProfileDataCache(this, Profile.getLastUsedProfile())); |
| + mView.setListener(this); |
| + mView.setFragmentManager(getFragmentManager()); |
| + |
| + setContentView(mView); |
| + } |
| + |
| + @Override |
| + public void onAccountSelectionCanceled() { |
| + finish(); |
| + } |
| + |
| + @Override |
| + public void onNewAccount() { |
| + AccountAdder.getInstance().addAccount(this, AccountAdder.ADD_ACCOUNT_RESULT); |
| + } |
| + |
| + @Override |
| + public void onAccountSelected(String accountName) { |
| + mAccountName = accountName; |
| + |
| + } |
| + |
| + @Override |
| + public void onDoneClicked() { |
| + SigninManager.get(this).signIn(mAccountName, null, this); |
| + } |
| + |
| + @Override |
| + public void onSettingsClicked() { |
| + mShowSyncSettings = true; |
| + SigninManager.get(this).signIn(mAccountName, null, this); |
| + } |
| + |
| + @Override |
| + public void onFailedToSetForcedAccount(String forcedAccountName) { |
| + assert false : "No forced accounts in account switching preferences."; |
| + |
| + } |
| + |
| + @Override |
| + public void onSignInComplete() { |
| + if (mShowSyncSettings) { |
| + Intent intent = PreferencesLauncher.createIntentForSettingsPage(this, |
| + SyncCustomizationFragment.class.getName()); |
| + Bundle args = new Bundle(); |
| + args.putString(SyncCustomizationFragment.ARGUMENT_ACCOUNT, mAccountName); |
| + intent.putExtra(Preferences.EXTRA_SHOW_FRAGMENT_ARGUMENTS, args); |
| + startActivity(intent); |
| + } |
| + |
| + finish(); |
| + } |
| + |
| + @Override |
| + public void onSignInAborted() { |
| + assert false : "Signin cannot be aborted when forced."; |
| + } |
| +} |