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

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

Issue 2924513002: use user chosen country code to format and validate phone number for addresses. (Closed)
Patch Set: more fixing 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
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 804186b826fa310271e1c379236ff673cd97a597..6eabfa62e30cb1558e79795aa5b3ab1df5a273b7 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
@@ -60,8 +60,9 @@ public class AddressEditor
*
* @param phoneNumber The phone number to possibly add.
gogerald1 2017/06/15 17:41:35 comments: @param countryCode .....
wuandy1 2017/06/19 15:11:14 deleted
*/
- public void addPhoneNumberIfValid(@Nullable CharSequence phoneNumber) {
- if (getPhoneValidator().isValid(phoneNumber)) mPhoneNumbers.add(phoneNumber);
+ public void addPhoneNumberIfValid(
+ @Nullable CharSequence phoneNumber, @Nullable String countryCode) {
gogerald1 2017/06/15 17:41:35 this countryCode doesn't take effect, since it may
wuandy1 2017/06/19 15:11:14 removed validation.
+ if (getPhoneValidator(countryCode).isValid(phoneNumber)) mPhoneNumbers.add(phoneNumber);
}
/**
@@ -123,6 +124,7 @@ public class AddressEditor
mEditor.removeAllFields();
showProgressDialog();
mRecentlySelectedCountry = eventData.first;
+ mEditorDialog.updateCountryOfPhoneFormatter(mRecentlySelectedCountry);
gogerald1 2017/06/15 17:41:35 This not enough as I mentioned in the last review.
wuandy1 2017/06/19 15:11:14 add code to initialize it, not sure this is what y
mCountryChangeCallback = eventData.second;
loadAdminAreasForCountry(mRecentlySelectedCountry);
}
@@ -161,7 +163,7 @@ public class AddressEditor
if (mPhoneField == null) {
mPhoneField = EditorFieldModel.createTextInput(EditorFieldModel.INPUT_TYPE_HINT_PHONE,
mContext.getString(R.string.autofill_profile_editor_phone_number),
- mPhoneNumbers, getPhoneValidator(), null,
+ mPhoneNumbers, getPhoneValidator(null), null,
gogerald1 2017/06/15 17:41:35 mCountryField.getValue()? since we have set defaul
wuandy1 2017/06/19 15:11:14 Done.
mContext.getString(R.string.payments_field_required_validation_message),
mContext.getString(R.string.payments_phone_invalid_validation_message), null);
}
@@ -390,12 +392,17 @@ public class AddressEditor
mEditor.addField(mPhoneField);
}
- private EditorFieldValidator getPhoneValidator() {
+ private EditorFieldValidator getPhoneValidator(@Nullable final String countryCode) {
if (mPhoneValidator == null) {
gogerald1 2017/06/15 17:41:35 This makes the countryCode of mPhoneValidator is f
wuandy1 2017/06/19 15:11:14 Done.
mPhoneValidator = new EditorFieldValidator() {
@Override
public boolean isValid(@Nullable CharSequence value) {
- return value != null && PhoneNumberUtil.isValidNumber(value.toString());
+ String countryToValidateAgainst = countryCode != null
+ ? countryCode
+ : (mCountryField == null ? null : mCountryField.getValue().toString());
+ return value != null
+ && PhoneNumberUtil.isValidNumber(
+ value.toString(), countryToValidateAgainst);
}
@Override

Powered by Google App Engine
This is Rietveld 408576698