Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2043)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AutofillProfileBridge.java

Issue 2680143002: Use dropdown list for admin areas in pr form. (Closed)
Patch Set: Another one with addressing Math's comments. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 7f0f63db0c8742eaadca5814a47eae45fbf82941..198218f4f9221d1370d2ecf26bba7f9317b178ac 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
@@ -97,10 +97,31 @@ public class AutofillProfileBridge {
return result;
}
});
-
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) {
please use gerrit instead 2017/03/30 18:48:58 Range loops are expensive on Android. Let's use a
Parastoo 2017/03/31 15:44:14 Done.
+ adminAreas.add(
+ new DropdownKeyValue(s, s)); // TODO (@crbug.com/691643): show names, save keys.
+ }
+
+ 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());
please use gerrit instead 2017/03/30 18:48:58 Why use a collator for the value, but not for the
Parastoo 2017/03/31 15:44:14 Well, the second line (if (result == 0) is redunda
Parastoo 2017/03/31 15:44:14 Done.
+ 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<>();

Powered by Google App Engine
This is Rietveld 408576698