| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.preferences; | 5 package org.chromium.chrome.browser.preferences; |
| 6 | 6 |
| 7 import android.accounts.Account; | 7 import android.accounts.Account; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.preference.ListPreference; | 9 import android.preference.ListPreference; |
| 10 import android.text.TextUtils; | 10 import android.text.TextUtils; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 } | 40 } |
| 41 | 41 |
| 42 private void updateAccountsList() { | 42 private void updateAccountsList() { |
| 43 boolean syncEnabled = AndroidSyncSettings.isSyncEnabled(getContext()); | 43 boolean syncEnabled = AndroidSyncSettings.isSyncEnabled(getContext()); |
| 44 if (!syncEnabled) { | 44 if (!syncEnabled) { |
| 45 setEnabled(false); | 45 setEnabled(false); |
| 46 // Don't return at this point, we still want the preference to displ
ay the currently | 46 // Don't return at this point, we still want the preference to displ
ay the currently |
| 47 // signed in account | 47 // signed in account |
| 48 } | 48 } |
| 49 | 49 |
| 50 Account[] accounts = AccountManagerHelper.get().getGoogleAccounts(); | 50 Account[] accounts = AccountManagerHelper.get(getContext()).getGoogleAcc
ounts(); |
| 51 String[] accountNames = new String[accounts.length]; | 51 String[] accountNames = new String[accounts.length]; |
| 52 String[] accountValues = new String[accounts.length]; | 52 String[] accountValues = new String[accounts.length]; |
| 53 | 53 |
| 54 String signedInAccountName = ChromeSigninController.get().getSignedInAcc
ountName(); | 54 String signedInAccountName = |
| 55 ChromeSigninController.get(getContext()).getSignedInAccountName(
); |
| 55 String signedInSettingsKey = ""; | 56 String signedInSettingsKey = ""; |
| 56 | 57 |
| 57 for (int i = 0; i < accounts.length; ++i) { | 58 for (int i = 0; i < accounts.length; ++i) { |
| 58 Account account = accounts[i]; | 59 Account account = accounts[i]; |
| 59 accountNames[i] = account.name; | 60 accountNames[i] = account.name; |
| 60 accountValues[i] = account.name; | 61 accountValues[i] = account.name; |
| 61 boolean isPrimaryAccount = TextUtils.equals(account.name, signedInAc
countName); | 62 boolean isPrimaryAccount = TextUtils.equals(account.name, signedInAc
countName); |
| 62 if (isPrimaryAccount) { | 63 if (isPrimaryAccount) { |
| 63 signedInSettingsKey = accountValues[i]; | 64 signedInSettingsKey = accountValues[i]; |
| 64 } | 65 } |
| 65 } | 66 } |
| 66 | 67 |
| 67 setEntries(accountNames); | 68 setEntries(accountNames); |
| 68 setEntryValues(accountValues); | 69 setEntryValues(accountValues); |
| 69 setValue(signedInSettingsKey); | 70 setValue(signedInSettingsKey); |
| 70 setSummary(signedInAccountName); | 71 setSummary(signedInAccountName); |
| 71 } | 72 } |
| 72 | 73 |
| 73 @Override | 74 @Override |
| 74 protected void onDialogClosed(boolean positiveResult) { | 75 protected void onDialogClosed(boolean positiveResult) { |
| 75 super.onDialogClosed(positiveResult); | 76 super.onDialogClosed(positiveResult); |
| 76 } | 77 } |
| 77 } | 78 } |
| OLD | NEW |