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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/SyncedAccountPreference.java

Issue 2784353002: Android: Remove GetApplicationContext part 2 (Closed)
Patch Set: Fix tests Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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
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(getContext()).getGoogleAcc ounts(); 50 Account[] accounts = AccountManagerHelper.get().getGoogleAccounts();
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 = 54 String signedInAccountName = ChromeSigninController.get().getSignedInAcc ountName();
55 ChromeSigninController.get(getContext()).getSignedInAccountName( );
56 String signedInSettingsKey = ""; 55 String signedInSettingsKey = "";
57 56
58 for (int i = 0; i < accounts.length; ++i) { 57 for (int i = 0; i < accounts.length; ++i) {
59 Account account = accounts[i]; 58 Account account = accounts[i];
60 accountNames[i] = account.name; 59 accountNames[i] = account.name;
61 accountValues[i] = account.name; 60 accountValues[i] = account.name;
62 boolean isPrimaryAccount = TextUtils.equals(account.name, signedInAc countName); 61 boolean isPrimaryAccount = TextUtils.equals(account.name, signedInAc countName);
63 if (isPrimaryAccount) { 62 if (isPrimaryAccount) {
64 signedInSettingsKey = accountValues[i]; 63 signedInSettingsKey = accountValues[i];
65 } 64 }
66 } 65 }
67 66
68 setEntries(accountNames); 67 setEntries(accountNames);
69 setEntryValues(accountValues); 68 setEntryValues(accountValues);
70 setValue(signedInSettingsKey); 69 setValue(signedInSettingsKey);
71 setSummary(signedInAccountName); 70 setSummary(signedInAccountName);
72 } 71 }
73 72
74 @Override 73 @Override
75 protected void onDialogClosed(boolean positiveResult) { 74 protected void onDialogClosed(boolean positiveResult) {
76 super.onDialogClosed(positiveResult); 75 super.onDialogClosed(positiveResult);
77 } 76 }
78 } 77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698