diff options
author | Amith Yamasani <yamasani@google.com> | 2012-06-07 17:03:20 -0700 |
---|---|---|
committer | Amith Yamasani <yamasani@google.com> | 2012-06-07 17:03:20 -0700 |
commit | 3882c2e215169ac021c47538e2058ca8089d426f (patch) | |
tree | 237a4a94489cae69b2a312c916d02cc39e1b9d6c /src | |
parent | ffa6f6e3e260dad0e7f75f6e8daa892eeed8df92 (diff) | |
download | packages_apps_Settings-3882c2e215169ac021c47538e2058ca8089d426f.zip packages_apps_Settings-3882c2e215169ac021c47538e2058ca8089d426f.tar.gz packages_apps_Settings-3882c2e215169ac021c47538e2058ca8089d426f.tar.bz2 |
Directly go to account sync screen if there's only one account for that type.
Bug: 6629330
Change-Id: Ieb2bad131b1580a6b75d970c9a0ea9980580f66d
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/settings/Settings.java | 39 | ||||
-rw-r--r-- | src/com/android/settings/accounts/AuthenticatorHelper.java | 10 |
2 files changed, 37 insertions, 12 deletions
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java index 50019a3..5826154 100644 --- a/src/com/android/settings/Settings.java +++ b/src/com/android/settings/Settings.java @@ -439,21 +439,36 @@ public class Settings extends PreferenceActivity List<Header> accountHeaders = new ArrayList<Header>(accountTypes.length); for (String accountType : accountTypes) { CharSequence label = mAuthenticatorHelper.getLabelForType(this, accountType); + Account[] accounts = AccountManager.get(this).getAccountsByType(accountType); + boolean skipToAccount = accounts.length == 1 + && !mAuthenticatorHelper.hasAccountPreferences(accountType); Header accHeader = new Header(); accHeader.title = label; if (accHeader.extras == null) { accHeader.extras = new Bundle(); } - accHeader.extras.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE, accountType); - accHeader.breadCrumbTitle = label; - accHeader.breadCrumbShortTitle = label; - accHeader.fragment = ManageAccountsSettings.class.getName(); - accHeader.fragmentArguments = new Bundle(); - accHeader.fragmentArguments.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE, - accountType); - if (!isMultiPane()) { - accHeader.fragmentArguments.putString(ManageAccountsSettings.KEY_ACCOUNT_LABEL, - label.toString()); + if (skipToAccount) { + accHeader.breadCrumbTitleRes = R.string.account_sync_settings_title; + accHeader.breadCrumbShortTitleRes = R.string.account_sync_settings_title; + accHeader.fragment = AccountSyncSettings.class.getName(); + accHeader.fragmentArguments = new Bundle(); + // Need this for the icon + accHeader.extras.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE, accountType); + accHeader.extras.putParcelable(AccountSyncSettings.ACCOUNT_KEY, accounts[0]); + accHeader.fragmentArguments.putParcelable(AccountSyncSettings.ACCOUNT_KEY, + accounts[0]); + } else { + accHeader.breadCrumbTitle = label; + accHeader.breadCrumbShortTitle = label; + accHeader.fragment = ManageAccountsSettings.class.getName(); + accHeader.fragmentArguments = new Bundle(); + accHeader.extras.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE, accountType); + accHeader.fragmentArguments.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE, + accountType); + if (!isMultiPane()) { + accHeader.fragmentArguments.putString(ManageAccountsSettings.KEY_ACCOUNT_LABEL, + label.toString()); + } } accountHeaders.add(accHeader); } @@ -642,8 +657,8 @@ public class Settings extends PreferenceActivity //$FALL-THROUGH$ case HEADER_TYPE_NORMAL: - if (header.extras != null && header.extras.containsKey( - ManageAccountsSettings.KEY_ACCOUNT_TYPE)) { + if (header.extras != null + && header.extras.containsKey(ManageAccountsSettings.KEY_ACCOUNT_TYPE)) { String accType = header.extras.getString( ManageAccountsSettings.KEY_ACCOUNT_TYPE); ViewGroup.LayoutParams lp = holder.icon.getLayoutParams(); diff --git a/src/com/android/settings/accounts/AuthenticatorHelper.java b/src/com/android/settings/accounts/AuthenticatorHelper.java index 9c17a36..ab2fe74 100644 --- a/src/com/android/settings/accounts/AuthenticatorHelper.java +++ b/src/com/android/settings/accounts/AuthenticatorHelper.java @@ -124,4 +124,14 @@ public class AuthenticatorHelper { public AuthenticatorDescription getAccountTypeDescription(String accountType) { return mTypeToAuthDescription.get(accountType); } + + public boolean hasAccountPreferences(final String accountType) { + if (containsAccountType(accountType)) { + AuthenticatorDescription desc = getAccountTypeDescription(accountType); + if (desc != null && desc.accountPreferencesId != 0) { + return true; + } + } + return false; + } } |