diff options
author | Amith Yamasani <yamasani@google.com> | 2012-06-05 13:20:45 -0700 |
---|---|---|
committer | Amith Yamasani <yamasani@google.com> | 2012-06-05 14:28:17 -0700 |
commit | 56821dbeaa87a426ff7a358babe51a81e721c09e (patch) | |
tree | 19e1a336ed49f1a324bf5d15059ead6f85d21e1d /src | |
parent | 9050451649b920a490117462ec71e87a0aa3ee63 (diff) | |
download | packages_apps_settings-56821dbeaa87a426ff7a358babe51a81e721c09e.zip packages_apps_settings-56821dbeaa87a426ff7a358babe51a81e721c09e.tar.gz packages_apps_settings-56821dbeaa87a426ff7a358babe51a81e721c09e.tar.bz2 |
Update headers when accounts are changed.
Also pass an account to authenticator settings to avoid Email settings crash.
Bug: 6610990
Change-Id: I42884619728dd97446de65cc77e1729f3e143efa
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/settings/Settings.java | 14 | ||||
-rw-r--r-- | src/com/android/settings/accounts/ManageAccountsSettings.java | 8 |
2 files changed, 21 insertions, 1 deletions
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java index a8599bf..353bc3a 100644 --- a/src/com/android/settings/Settings.java +++ b/src/com/android/settings/Settings.java @@ -26,6 +26,9 @@ import com.android.settings.deviceinfo.Memory; import com.android.settings.fuelgauge.PowerUsageSummary; import com.android.settings.wifi.WifiEnabler; +import android.accounts.Account; +import android.accounts.AccountManager; +import android.accounts.OnAccountsUpdateListener; import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -64,7 +67,8 @@ import java.util.List; /** * Top-level settings activity to handle single pane and double pane UI layout. */ -public class Settings extends PreferenceActivity implements ButtonBarHandler { +public class Settings extends PreferenceActivity + implements ButtonBarHandler, OnAccountsUpdateListener { private static final String LOG_TAG = "Settings"; private static final String META_DATA_KEY_HEADER_ID = @@ -183,6 +187,7 @@ public class Settings extends PreferenceActivity implements ButtonBarHandler { ListAdapter listAdapter = getListAdapter(); if (listAdapter instanceof HeaderAdapter) { ((HeaderAdapter) listAdapter).resume(); + AccountManager.get(this).addOnAccountsUpdatedListener(this, null, true); } } @@ -193,6 +198,7 @@ public class Settings extends PreferenceActivity implements ButtonBarHandler { ListAdapter listAdapter = getListAdapter(); if (listAdapter instanceof HeaderAdapter) { ((HeaderAdapter) listAdapter).pause(); + AccountManager.get(this).removeOnAccountsUpdatedListener(this); } } @@ -711,6 +717,12 @@ public class Settings extends PreferenceActivity implements ButtonBarHandler { super.setListAdapter(new HeaderAdapter(this, mHeaders, mAuthenticatorHelper)); } + @Override + public void onAccountsUpdated(Account[] accounts) { + mAuthenticatorHelper.onAccountsUpdated(this, accounts); + invalidateHeaders(); + } + /* * Settings subclasses for launching independently. */ diff --git a/src/com/android/settings/accounts/ManageAccountsSettings.java b/src/com/android/settings/accounts/ManageAccountsSettings.java index 909fd92..85cf025 100644 --- a/src/com/android/settings/accounts/ManageAccountsSettings.java +++ b/src/com/android/settings/accounts/ManageAccountsSettings.java @@ -60,6 +60,7 @@ import java.util.HashSet; public class ManageAccountsSettings extends AccountPreferenceBase implements OnAccountsUpdateListener { + private static final String ACCOUNT_KEY = "account"; // to pass to auth settings public static final String KEY_ACCOUNT_TYPE = "account_type"; public static final String KEY_ACCOUNT_LABEL = "account_label"; @@ -74,6 +75,8 @@ public class ManageAccountsSettings extends AccountPreferenceBase private SettingsDialogFragment mDialogFragment; // If an account type is set, then show only accounts of that type private String mAccountType; + // Temporary hack, to deal with backward compatibility + private Account mFirstAccount; @Override public void onCreate(Bundle icicle) { @@ -299,6 +302,7 @@ public class ManageAccountsSettings extends AccountPreferenceBase public void onAccountsUpdated(Account[] accounts) { if (getActivity() == null) return; getPreferenceScreen().removeAll(); + mFirstAccount = null; addPreferencesFromResource(R.xml.manage_accounts_settings); for (int i = 0, n = accounts.length; i < n; i++) { final Account account = accounts[i]; @@ -322,6 +326,9 @@ public class ManageAccountsSettings extends AccountPreferenceBase final AccountPreference preference = new AccountPreference(getActivity(), account, icon, auths); getPreferenceScreen().addPreference(preference); + if (mFirstAccount == null) { + mFirstAccount = account; + } } } if (mAccountType != null) { @@ -347,6 +354,7 @@ public class ManageAccountsSettings extends AccountPreferenceBase prefs.removePreference(prefs.getPreference(i)); continue; } else { + intent.putExtra(ACCOUNT_KEY, mFirstAccount); intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK); } } |