Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AutofillProfileBridge.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AutofillProfileBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AutofillProfileBridge.java |
| index 3b34d5c6a14ea46a8514a638ffde45740bae9aa3..d938f644f30502c2b4fd8e139b5ca34b16092c87 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AutofillProfileBridge.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AutofillProfileBridge.java |
| @@ -101,6 +101,27 @@ public class AutofillProfileBridge { |
| return countries; |
| } |
| + /** @return The list of admin areas sorted by their localized display names. */ |
| + public static List<DropdownKeyValue> getAdminAreaDropdownList(String[] keys) { |
| + List<DropdownKeyValue> adminAreas = new ArrayList<>(); |
| + |
| + for (String s : keys) { |
| + adminAreas.add(new DropdownKeyValue(s, s)); // TODO (@parastoog): show names, save keys. |
|
sebsg
2017/02/10 16:00:32
The new format for TODOs is to create a bug in crb
Parastoo
2017/02/13 21:57:23
Done.
|
| + } |
| + |
| + final Collator collator = Collator.getInstance(Locale.getDefault()); |
| + collator.setStrength(Collator.PRIMARY); |
| + Collections.sort(adminAreas, new Comparator<DropdownKeyValue>() { |
| + @Override |
| + public int compare(DropdownKeyValue lhs, DropdownKeyValue rhs) { |
| + int result = collator.compare(lhs.getValue(), rhs.getValue()); |
| + if (result == 0) result = lhs.getKey().compareTo(rhs.getKey()); |
| + return result; |
| + } |
| + }); |
| + return adminAreas; |
| + } |
| + |
| /** @return The list of required fields. COUNTRY is always included. RECIPIENT often omitted. */ |
| public static List<Integer> getRequiredAddressFields(String countryCode) { |
| List<Integer> requiredFields = new ArrayList<>(); |
| @@ -144,7 +165,7 @@ public class AutofillProfileBridge { |
| * Returns the UI components for the CLDR countryCode and languageCode provided. If no language |
| * code is provided, the application's default locale is used instead. Also stores the |
| * currentBestLanguageCode, retrievable via getCurrentBestLanguageCode, to be used when saving |
| - * an autofill profile. |
| + * an autofill profile |
| * |
| * @param countryCode The CLDR code used to retrieve address components. |
| * @param languageCode The language code associated with the saved autofill profile that ui |