OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.payments; | 5 package org.chromium.chrome.browser.payments; |
6 | 6 |
7 import android.app.ProgressDialog; | 7 import android.app.ProgressDialog; |
8 import android.os.Handler; | 8 import android.os.Handler; |
9 import android.util.Pair; | 9 import android.util.Pair; |
10 | 10 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 * If the selected country on the country dropdown list is changed, | 116 * If the selected country on the country dropdown list is changed, |
117 * the first element of eventData is the recently selected dropdown key, | 117 * the first element of eventData is the recently selected dropdown key, |
118 * the second element is the callback to invoke for when the dropdow n | 118 * the second element is the callback to invoke for when the dropdow n |
119 * change has been processed. | 119 * change has been processed. |
120 */ | 120 */ |
121 @Override | 121 @Override |
122 public void onResult(Pair<String, Runnable> eventData) { | 122 public void onResult(Pair<String, Runnable> eventData) { |
123 mEditor.removeAllFields(); | 123 mEditor.removeAllFields(); |
124 showProgressDialog(); | 124 showProgressDialog(); |
125 mRecentlySelectedCountry = eventData.first; | 125 mRecentlySelectedCountry = eventData.first; |
126 mEditorDialog.updateCountryOfPhoneFormatter(mRecentlySelectedCou ntry); | |
126 mCountryChangeCallback = eventData.second; | 127 mCountryChangeCallback = eventData.second; |
127 loadAdminAreasForCountry(mRecentlySelectedCountry); | 128 loadAdminAreasForCountry(mRecentlySelectedCountry); |
128 } | 129 } |
129 }); | 130 }); |
130 | 131 |
131 // Country dropdown is cached, so the selected item needs to be updated for the new profile | 132 // Country dropdown is cached, so the selected item needs to be updated for the new profile |
132 // that's being edited. This will not fire the dropdown callback. | 133 // that's being edited. This will not fire the dropdown callback. |
133 mCountryField.setValue(AutofillAddress.getCountryCode(mProfile)); | 134 mCountryField.setValue(AutofillAddress.getCountryCode(mProfile)); |
134 | 135 |
135 // There's a finite number of fields for address editing. Changing the c ountry will re-order | 136 // There's a finite number of fields for address editing. Changing the c ountry will re-order |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
388 } | 389 } |
389 // Phone number must be the last field. | 390 // Phone number must be the last field. |
390 mEditor.addField(mPhoneField); | 391 mEditor.addField(mPhoneField); |
391 } | 392 } |
392 | 393 |
393 private EditorFieldValidator getPhoneValidator() { | 394 private EditorFieldValidator getPhoneValidator() { |
394 if (mPhoneValidator == null) { | 395 if (mPhoneValidator == null) { |
395 mPhoneValidator = new EditorFieldValidator() { | 396 mPhoneValidator = new EditorFieldValidator() { |
396 @Override | 397 @Override |
397 public boolean isValid(@Nullable CharSequence value) { | 398 public boolean isValid(@Nullable CharSequence value) { |
398 return value != null && PhoneNumberUtil.isValidNumber(value. toString()); | 399 return value != null |
400 && PhoneNumberUtil.isValidNumber( | |
401 value.toString(), mRecentlySelectedCountr y); | |
gogerald1
2017/06/08 16:20:43
mRecentlySelectedCountry is null if the user doesn
wuandy1
2017/06/08 20:34:58
Which is handled by isValidNumber..do you mean a @
gogerald1
2017/06/09 13:33:46
NO, the selected country is set according to profi
wuandy1
2017/06/12 14:15:25
ok i see. what is your suggestion then?
gogerald1
2017/06/12 17:02:11
What about using 'mCountryField.getValue().toStrin
wuandy1
2017/06/13 19:47:25
Done.
| |
399 } | 402 } |
400 | 403 |
401 @Override | 404 @Override |
402 public boolean isLengthMaximum(@Nullable CharSequence value) { | 405 public boolean isLengthMaximum(@Nullable CharSequence value) { |
403 return false; | 406 return false; |
404 } | 407 } |
405 }; | 408 }; |
406 } | 409 } |
407 return mPhoneValidator; | 410 return mPhoneValidator; |
408 } | 411 } |
409 } | 412 } |
OLD | NEW |