Chromium Code Reviews| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 | 100 |
| 101 return countries; | 101 return countries; |
| 102 } | 102 } |
| 103 | 103 |
| 104 /** @return The list of admin areas sorted by their localized display names. */ | |
| 105 public static List<DropdownKeyValue> getAdminAreaDropdownList(String[] keys) { | |
| 106 List<DropdownKeyValue> adminAreas = new ArrayList<>(); | |
| 107 | |
| 108 for (String s : keys) { | |
| 109 adminAreas.add(new DropdownKeyValue(s, s)); // TODO (@parastoog): sh ow 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.
| |
| 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 int result = collator.compare(lhs.getValue(), rhs.getValue()); | |
| 118 if (result == 0) result = lhs.getKey().compareTo(rhs.getKey()); | |
| 119 return result; | |
| 120 } | |
| 121 }); | |
| 122 return adminAreas; | |
| 123 } | |
| 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 /** |
| 112 * Description of an address editor input field. | 133 * Description of an address editor input field. |
| 113 */ | 134 */ |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 137 this.label = label; | 158 this.label = label; |
| 138 this.isRequired = isRequired; | 159 this.isRequired = isRequired; |
| 139 this.isFullLine = isFullLine; | 160 this.isFullLine = isFullLine; |
| 140 } | 161 } |
| 141 } | 162 } |
| 142 | 163 |
| 143 /** | 164 /** |
| 144 * Returns the UI components for the CLDR countryCode and languageCode provi ded. If no language | 165 * Returns the UI components for the CLDR countryCode and languageCode provi ded. If no language |
| 145 * code is provided, the application's default locale is used instead. Also stores the | 166 * code is provided, the application's default locale is used instead. Also stores the |
| 146 * currentBestLanguageCode, retrievable via getCurrentBestLanguageCode, to b e used when saving | 167 * currentBestLanguageCode, retrievable via getCurrentBestLanguageCode, to b e used when saving |
| 147 * an autofill profile. | 168 * an autofill profile |
| 148 * | 169 * |
| 149 * @param countryCode The CLDR code used to retrieve address components. | 170 * @param countryCode The CLDR code used to retrieve address components. |
| 150 * @param languageCode The language code associated with the saved autofill profile that ui | 171 * @param languageCode The language code associated with the saved autofill profile that ui |
| 151 * components are being retrieved for; can be null if ui components are | 172 * components are being retrieved for; can be null if ui components are |
| 152 * being retrieved for a new profile. | 173 * being retrieved for a new profile. |
| 153 * @return A list of address UI components. The ordering in the list specifi es the order these | 174 * @return A list of address UI components. The ordering in the list specifi es the order these |
| 154 * components should appear in the UI. | 175 * components should appear in the UI. |
| 155 */ | 176 */ |
| 156 public List<AddressUiComponent> getAddressUiComponents( | 177 public List<AddressUiComponent> getAddressUiComponents( |
| 157 String countryCode, String languageCode) { | 178 String countryCode, String languageCode) { |
| (...skipping 38 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 |