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

Side by Side 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: The one with Rouslan's comments. (this was a wrong patch) Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.preferences.autofill; 5 package org.chromium.chrome.browser.preferences.autofill;
6 6
7 import android.util.Pair; 7 import android.util.Pair;
8 8
9 import org.chromium.base.annotations.CalledByNative; 9 import org.chromium.base.annotations.CalledByNative;
10 import org.chromium.base.annotations.JNINamespace; 10 import org.chromium.base.annotations.JNINamespace;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 final Collator collator = Collator.getInstance(Locale.getDefault()); 90 final Collator collator = Collator.getInstance(Locale.getDefault());
91 collator.setStrength(Collator.PRIMARY); 91 collator.setStrength(Collator.PRIMARY);
92 Collections.sort(countries, new Comparator<DropdownKeyValue>() { 92 Collections.sort(countries, new Comparator<DropdownKeyValue>() {
93 @Override 93 @Override
94 public int compare(DropdownKeyValue lhs, DropdownKeyValue rhs) { 94 public int compare(DropdownKeyValue lhs, DropdownKeyValue rhs) {
95 int result = collator.compare(lhs.getValue(), rhs.getValue()); 95 int result = collator.compare(lhs.getValue(), rhs.getValue());
96 if (result == 0) result = lhs.getKey().compareTo(rhs.getKey()); 96 if (result == 0) result = lhs.getKey().compareTo(rhs.getKey());
97 return result; 97 return result;
98 } 98 }
99 }); 99 });
100 return countries;
101 }
100 102
101 return countries; 103 /** @return The list of admin areas sorted by their localized display names. */
104 public static List<DropdownKeyValue> getAdminAreaDropdownList(String[] keys) {
105 List<DropdownKeyValue> adminAreas = new ArrayList<>();
106
107 for (int i = 0; i < keys.length; ++i) {
108 // TODO (@crbug.com/691643): show names, save keys.
109 adminAreas.add(
110 new DropdownKeyValue(keys[i], keys[i]));
111 }
112
113 final Collator collator = Collator.getInstance(Locale.getDefault());
114 collator.setStrength(Collator.PRIMARY);
115 Collections.sort(adminAreas, new Comparator<DropdownKeyValue>() {
116 @Override
117 public int compare(DropdownKeyValue lhs, DropdownKeyValue rhs) {
118 // Sorted according to the admin area values, such as Quebec,
119 // rather than the admin area keys, such as QC.
120 int result = collator.compare(lhs.getValue(), rhs.getValue());
please use gerrit instead 2017/03/31 16:06:20 No need for temporary variable "result". Save a li
Parastoo 2017/04/03 16:18:23 Done.
121 return result;
122 }
123 });
124 return adminAreas;
102 } 125 }
103 126
104 /** @return The list of required fields. COUNTRY is always included. RECIPIE NT often omitted. */ 127 /** @return The list of required fields. COUNTRY is always included. RECIPIE NT often omitted. */
105 public static List<Integer> getRequiredAddressFields(String countryCode) { 128 public static List<Integer> getRequiredAddressFields(String countryCode) {
106 List<Integer> requiredFields = new ArrayList<>(); 129 List<Integer> requiredFields = new ArrayList<>();
107 nativeGetRequiredFields(countryCode, requiredFields); 130 nativeGetRequiredFields(countryCode, requiredFields);
108 return requiredFields; 131 return requiredFields;
109 } 132 }
110 133
111 /** 134 /**
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 219
197 private static native String nativeGetDefaultCountryCode(); 220 private static native String nativeGetDefaultCountryCode();
198 private static native void nativeGetSupportedCountries(List<String> countryC odes, 221 private static native void nativeGetSupportedCountries(List<String> countryC odes,
199 List<String> countryNames); 222 List<String> countryNames);
200 private static native void nativeGetRequiredFields( 223 private static native void nativeGetRequiredFields(
201 String countryCode, List<Integer> requiredFields); 224 String countryCode, List<Integer> requiredFields);
202 private static native String nativeGetAddressUiComponents(String countryCode , 225 private static native String nativeGetAddressUiComponents(String countryCode ,
203 String languageCode, List<Integer> componentIds, List<String> compon entNames, 226 String languageCode, List<Integer> componentIds, List<String> compon entNames,
204 List<Integer> componentRequired, List<Integer> componentLengths); 227 List<Integer> componentRequired, List<Integer> componentLengths);
205 } 228 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698