Revert "Revert "Hide sort order and name format prefs for CJK locales""
This reverts commit f5678f1049dc5ffdd0ea8829f754de93542abbce.
Change-Id: I0cdbc6873e0d42a2bd8f8d24fa2d13c48fa965bf
diff --git a/src/com/android/contacts/common/preference/DisplayOptionsPreferenceFragment.java b/src/com/android/contacts/common/preference/DisplayOptionsPreferenceFragment.java
index 3a5c536..a8d1460 100644
--- a/src/com/android/contacts/common/preference/DisplayOptionsPreferenceFragment.java
+++ b/src/com/android/contacts/common/preference/DisplayOptionsPreferenceFragment.java
@@ -20,6 +20,7 @@
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
+import android.content.res.Resources;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
@@ -45,19 +46,7 @@
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preference_display_options);
- // Remove "Default account" setting if no writable accounts.
- final AccountTypeManager accountTypeManager = AccountTypeManager.getInstance(getContext());
- final List<AccountWithDataSet> accounts = accountTypeManager.getAccounts(
- /* contactWritableOnly */ true);
- if (accounts.isEmpty()) {
- final PreferenceScreen preferenceScreen = getPreferenceScreen();
- preferenceScreen.removePreference((ListPreference) findPreference("accounts"));
- }
-
- // STOPSHIP Show this option when 1) metadata sync is enabled and 2) at least one
- // focus google account.
- final PreferenceScreen preferenceScreen = getPreferenceScreen();
- preferenceScreen.removePreference((ListPreference) findPreference("contactMetadata"));
+ removeUnsupportedPreferences();
// Set build version of Contacts App.
final PackageManager manager = getActivity().getPackageManager();
@@ -75,6 +64,31 @@
licensePreference.setIntent(new Intent(getActivity(), LicenseActivity.class));
}
+ private void removeUnsupportedPreferences() {
+ // Disable sort order for CJK locales where it is not supported
+ final Resources resources = getResources();
+ if (!resources.getBoolean(R.bool.config_sort_order_user_changeable)) {
+ getPreferenceScreen().removePreference(findPreference("sortOrder"));
+ }
+
+ // Disable display order for CJK locales as well
+ if (!resources.getBoolean(R.bool.config_display_order_user_changeable)) {
+ getPreferenceScreen().removePreference(findPreference("displayOrder"));
+ }
+
+ // Remove the "Default account" setting if there aren't any writable accounts
+ final AccountTypeManager accountTypeManager = AccountTypeManager.getInstance(getContext());
+ final List<AccountWithDataSet> accounts = accountTypeManager.getAccounts(
+ /* contactWritableOnly */ true);
+ if (accounts.isEmpty()) {
+ getPreferenceScreen().removePreference(findPreference("accounts"));
+ }
+
+ // STOPSHIP Show this option when 1) metadata sync is enabled
+ // and 2) there is at least one focus google account
+ getPreferenceScreen().removePreference(findPreference("contactMetadata"));
+ }
+
@Override
public Context getContext() {
return getActivity();