OLD | NEW |
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 Loading... |
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 (parastoog): show names, save keys. @crbug.com/691643 |
| 109 adminAreas.add(new DropdownKeyValue(keys[i], keys[i])); |
| 110 } |
| 111 |
| 112 final Collator collator = Collator.getInstance(Locale.getDefault()); |
| 113 collator.setStrength(Collator.PRIMARY); |
| 114 Collections.sort(adminAreas, new Comparator<DropdownKeyValue>() { |
| 115 @Override |
| 116 public int compare(DropdownKeyValue lhs, DropdownKeyValue rhs) { |
| 117 // Sorted according to the admin area values, such as Quebec, |
| 118 // rather than the admin area keys, such as QC. |
| 119 return collator.compare(lhs.getValue(), rhs.getValue()); |
| 120 } |
| 121 }); |
| 122 return adminAreas; |
102 } | 123 } |
103 | 124 |
104 /** @return The list of required fields. COUNTRY is always included. RECIPIE
NT often omitted. */ | 125 /** @return The list of required fields. COUNTRY is always included. RECIPIE
NT often omitted. */ |
105 public static List<Integer> getRequiredAddressFields(String countryCode) { | 126 public static List<Integer> getRequiredAddressFields(String countryCode) { |
106 List<Integer> requiredFields = new ArrayList<>(); | 127 List<Integer> requiredFields = new ArrayList<>(); |
107 nativeGetRequiredFields(countryCode, requiredFields); | 128 nativeGetRequiredFields(countryCode, requiredFields); |
108 return requiredFields; | 129 return requiredFields; |
109 } | 130 } |
110 | 131 |
111 /** | 132 /** |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 217 |
197 private static native String nativeGetDefaultCountryCode(); | 218 private static native String nativeGetDefaultCountryCode(); |
198 private static native void nativeGetSupportedCountries(List<String> countryC
odes, | 219 private static native void nativeGetSupportedCountries(List<String> countryC
odes, |
199 List<String> countryNames); | 220 List<String> countryNames); |
200 private static native void nativeGetRequiredFields( | 221 private static native void nativeGetRequiredFields( |
201 String countryCode, List<Integer> requiredFields); | 222 String countryCode, List<Integer> requiredFields); |
202 private static native String nativeGetAddressUiComponents(String countryCode
, | 223 private static native String nativeGetAddressUiComponents(String countryCode
, |
203 String languageCode, List<Integer> componentIds, List<String> compon
entNames, | 224 String languageCode, List<Integer> componentIds, List<String> compon
entNames, |
204 List<Integer> componentRequired, List<Integer> componentLengths); | 225 List<Integer> componentRequired, List<Integer> componentLengths); |
205 } | 226 } |
OLD | NEW |