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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/AddressEditor.java

Issue 2945303002: [Payments] Update country codes in phone number validator and formatter for editing profile (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/payments/AddressEditor.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/AddressEditor.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/AddressEditor.java
index f37ecd6d325c364d96ce7770488de48f8dcfba37..2e0681bb6126996e838ebde71204b1c43aabc3b3 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/payments/AddressEditor.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/AddressEditor.java
@@ -70,7 +70,7 @@ public class AddressEditor
* @param phoneNumber The phone number to possibly add.
*/
public void addPhoneNumberIfValid(@Nullable CharSequence phoneNumber) {
- if (TextUtils.isEmpty(phoneNumber)) mPhoneNumbers.add(phoneNumber.toString());
+ if (!TextUtils.isEmpty(phoneNumber)) mPhoneNumbers.add(phoneNumber.toString());
}
/**
@@ -143,6 +143,12 @@ public class AddressEditor
// that's being edited. This will not fire the dropdown callback.
mCountryField.setValue(AutofillAddress.getCountryCode(mProfile));
+ // Phone number validator and formatter are cached, so their contry code needs to be updated
+ // for the new profile that's being edited.
+ assert mCountryField.getValue() != null;
+ mPhoneValidator.setCountryCode(mCountryField.getValue().toString());
+ mPhoneFormatter.setCountryCode(mCountryField.getValue().toString());
+
// There's a finite number of fields for address editing. Changing the country will re-order
// and relabel the fields. The meaning of each field remains the same.
if (mAddressFields.isEmpty()) {
@@ -170,9 +176,6 @@ public class AddressEditor
// Phone number is present and required for all countries.
if (mPhoneField == null) {
- assert mCountryField.getValue() != null;
- mPhoneValidator.setCountryCode(mCountryField.getValue().toString());
- mPhoneFormatter.setCountryCode(mCountryField.getValue().toString());
mPhoneField = EditorFieldModel.createTextInput(EditorFieldModel.INPUT_TYPE_HINT_PHONE,
mContext.getString(R.string.autofill_profile_editor_phone_number),
mPhoneNumbers, mPhoneFormatter, mPhoneValidator, null,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698