diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-12-22 23:11:49 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-12-22 23:11:49 +0000 |
commit | 1cefb73fd66d5d00e2a0ee4be1cef441ce7ccc29 (patch) | |
tree | c2873c9a49f84d5ded569fc76be5b75d44afa552 /java/com/android/dialer/assisteddialing/ui/AssistedDialingSettingFragment.java | |
parent | 88518503c1351ba86f503ebd8742d6b292928ddd (diff) | |
parent | 57bc2fb4c415a7b84cbd8736681cfbec4cc2b442 (diff) |
Merge "Use ICU Localization for country names in settings."
Diffstat (limited to 'java/com/android/dialer/assisteddialing/ui/AssistedDialingSettingFragment.java')
-rw-r--r-- | java/com/android/dialer/assisteddialing/ui/AssistedDialingSettingFragment.java | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/java/com/android/dialer/assisteddialing/ui/AssistedDialingSettingFragment.java b/java/com/android/dialer/assisteddialing/ui/AssistedDialingSettingFragment.java index d4fb3f64b..932cc6d6c 100644 --- a/java/com/android/dialer/assisteddialing/ui/AssistedDialingSettingFragment.java +++ b/java/com/android/dialer/assisteddialing/ui/AssistedDialingSettingFragment.java @@ -16,6 +16,8 @@ package com.android.dialer.assisteddialing.ui; import android.annotation.TargetApi; +import android.icu.util.ULocale; +import android.icu.util.ULocale.Builder; import android.os.Build.VERSION_CODES; import android.os.Bundle; import android.preference.ListPreference; @@ -150,8 +152,19 @@ public class AssistedDialingSettingFragment extends PreferenceFragment { } List<DisplayNameAndCountryCodeTuple> displayNamesandCountryCodes = new ArrayList<>(); + // getCountry() is actually getRegion() and conforms to the iso standards of input for the + // builder. + ULocale userLocale = + new ULocale.Builder() + .setRegion(getResources().getConfiguration().getLocales().get(0).getCountry()) + .setLanguage(getResources().getConfiguration().getLocales().get(0).getLanguage()) + .build(); for (int i = 0; i < keys.length; i++) { - displayNamesandCountryCodes.add(DisplayNameAndCountryCodeTuple.create(keys[i], values[i])); + ULocale settingRowDisplayCountry = new Builder().setRegion(values[i].toString()).build(); + String localizedDisplayCountry = settingRowDisplayCountry.getDisplayCountry(userLocale); + String settingDisplayName = localizedDisplayCountry + " " + keys[i]; + displayNamesandCountryCodes.add( + DisplayNameAndCountryCodeTuple.create(settingDisplayName, values[i])); } return displayNamesandCountryCodes; |