summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/accounts
diff options
context:
space:
mode:
authorAlexandra Gherghina <alexgherghina@google.com>2014-08-11 12:40:13 +0100
committerAlexandra Gherghina <alexgherghina@google.com>2014-12-03 10:50:54 +0000
commit62464b819e185ce4a1642442fcf4cc18a4932a78 (patch)
tree2b5718c1180722a7457a76039b1f9e277c67cf39 /src/com/android/settings/accounts
parent2d93f36f00226a45adf9ad2f001e599f95e61692 (diff)
downloadpackages_apps_Settings-62464b819e185ce4a1642442fcf4cc18a4932a78.zip
packages_apps_Settings-62464b819e185ce4a1642442fcf4cc18a4932a78.tar.gz
packages_apps_Settings-62464b819e185ce4a1642442fcf4cc18a4932a78.tar.bz2
Modify account settings for better locale resolution
Bug: 16282173 Change-Id: I2ab861464cdbbb1c1b0a5a7231f960d8ed9e90c6
Diffstat (limited to 'src/com/android/settings/accounts')
-rw-r--r--src/com/android/settings/accounts/AccountSettings.java31
-rw-r--r--src/com/android/settings/accounts/AuthenticatorHelper.java27
2 files changed, 52 insertions, 6 deletions
diff --git a/src/com/android/settings/accounts/AccountSettings.java b/src/com/android/settings/accounts/AccountSettings.java
index 1bfa611..ffcb3b8 100644
--- a/src/com/android/settings/accounts/AccountSettings.java
+++ b/src/com/android/settings/accounts/AccountSettings.java
@@ -369,6 +369,8 @@ public class AccountSettings extends SettingsPreferenceFragment
if (label == null) {
continue;
}
+ final String titleResPackageName = helper.getPackageForType(accountType);
+ final int titleResId = helper.getLabelIdForType(accountType);
final Account[] accounts = AccountManager.get(getActivity())
.getAccountsByTypeAsUser(accountType, userHandle);
@@ -382,7 +384,8 @@ public class AccountSettings extends SettingsPreferenceFragment
fragmentArguments.putParcelable(EXTRA_USER, userHandle);
accountTypePreferences.add(new AccountPreference(getActivity(), label,
- AccountSyncSettings.class.getName(), fragmentArguments,
+ titleResPackageName, titleResId, AccountSyncSettings.class.getName(),
+ fragmentArguments,
helper.getDrawableForType(getActivity(), accountType)));
} else {
final Bundle fragmentArguments = new Bundle();
@@ -392,7 +395,8 @@ public class AccountSettings extends SettingsPreferenceFragment
fragmentArguments.putParcelable(EXTRA_USER, userHandle);
accountTypePreferences.add(new AccountPreference(getActivity(), label,
- ManageAccountsSettings.class.getName(), fragmentArguments,
+ titleResPackageName, titleResId, ManageAccountsSettings.class.getName(),
+ fragmentArguments,
helper.getDrawableForType(getActivity(), accountType)));
}
helper.preloadDrawableForType(getActivity(), accountType);
@@ -435,6 +439,17 @@ public class AccountSettings extends SettingsPreferenceFragment
private final CharSequence mTitle;
/**
+ * Packange name used to resolve the resources of the title shown to the user in the new
+ * fragment.
+ */
+ private final String mTitleResPackageName;
+
+ /**
+ * Resource id of the title shown to the user in the new fragment.
+ */
+ private final int mTitleResId;
+
+ /**
* Full class name of the fragment to display when this tile is
* selected.
* @attr ref android.R.styleable#PreferenceHeader_fragment
@@ -447,10 +462,13 @@ public class AccountSettings extends SettingsPreferenceFragment
*/
private final Bundle mFragmentArguments;
- public AccountPreference(Context context, CharSequence title, String fragment,
- Bundle fragmentArguments, Drawable icon) {
+ public AccountPreference(Context context, CharSequence title, String titleResPackageName,
+ int titleResId, String fragment, Bundle fragmentArguments,
+ Drawable icon) {
super(context);
mTitle = title;
+ mTitleResPackageName = titleResPackageName;
+ mTitleResId = titleResId;
mFragment = fragment;
mFragmentArguments = fragmentArguments;
setWidgetLayoutResource(R.layout.account_type_preference);
@@ -464,8 +482,9 @@ public class AccountSettings extends SettingsPreferenceFragment
@Override
public boolean onPreferenceClick(Preference preference) {
if (mFragment != null) {
- Utils.startWithFragment(
- getContext(), mFragment, mFragmentArguments, null, 0, 0, mTitle);
+ Utils.startWithFragment(getContext(), mFragment, mFragmentArguments,
+ null /* resultTo */, 0 /* resultRequestCode */, mTitleResPackageName,
+ mTitleResId, null /* title */);
return true;
}
return false;
diff --git a/src/com/android/settings/accounts/AuthenticatorHelper.java b/src/com/android/settings/accounts/AuthenticatorHelper.java
index 3757d97..86e0da5 100644
--- a/src/com/android/settings/accounts/AuthenticatorHelper.java
+++ b/src/com/android/settings/accounts/AuthenticatorHelper.java
@@ -148,6 +148,33 @@ final public class AuthenticatorHelper extends BroadcastReceiver {
}
/**
+ * Gets the package associated with a particular account type. If none found, return null.
+ * @param accountType the type of account
+ * @return the package name or null if one cannot be found.
+ */
+ public String getPackageForType(final String accountType) {
+ if (mTypeToAuthDescription.containsKey(accountType)) {
+ AuthenticatorDescription desc = mTypeToAuthDescription.get(accountType);
+ return desc.packageName;
+ }
+ return null;
+ }
+
+ /**
+ * Gets the resource id of the label associated with a particular account type. If none found,
+ * return -1.
+ * @param accountType the type of account
+ * @return a resource id for the label or -1 if none found;
+ */
+ public int getLabelIdForType(final String accountType) {
+ if (mTypeToAuthDescription.containsKey(accountType)) {
+ AuthenticatorDescription desc = mTypeToAuthDescription.get(accountType);
+ return desc.labelId;
+ }
+ return -1;
+ }
+
+ /**
* Updates provider icons. Subclasses should call this in onCreate()
* and update any UI that depends on AuthenticatorDescriptions in onAuthDescriptionsUpdated().
*/