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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/ui/EditorDialog.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 unified diff | Download patch
OLDNEW
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.ui; 5 package org.chromium.chrome.browser.payments.ui;
6 6
7 import android.animation.Animator; 7 import android.animation.Animator;
8 import android.animation.AnimatorListenerAdapter; 8 import android.animation.AnimatorListenerAdapter;
9 import android.animation.AnimatorSet; 9 import android.animation.AnimatorSet;
10 import android.animation.ObjectAnimator; 10 import android.animation.ObjectAnimator;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 private final TextView.OnEditorActionListener mEditorActionListener; 78 private final TextView.OnEditorActionListener mEditorActionListener;
79 private final int mHalfRowMargin; 79 private final int mHalfRowMargin;
80 private final int mDropdownTopPadding; 80 private final int mDropdownTopPadding;
81 private final List<EditorFieldView> mFieldViews; 81 private final List<EditorFieldView> mFieldViews;
82 private final List<EditText> mEditableTextFields; 82 private final List<EditText> mEditableTextFields;
83 private final List<Spinner> mDropdownFields; 83 private final List<Spinner> mDropdownFields;
84 private final InputFilter mCardNumberInputFilter; 84 private final InputFilter mCardNumberInputFilter;
85 private final TextWatcher mCardNumberFormatter; 85 private final TextWatcher mCardNumberFormatter;
86 86
87 @Nullable 87 @Nullable
88 private TextWatcher mPhoneFormatter; 88 private PhoneNumberUtil.CountryAwareFormatTextWatcher mPhoneFormatter;
89 private View mLayout; 89 private View mLayout;
90 private EditorModel mEditorModel; 90 private EditorModel mEditorModel;
91 private Button mDoneButton; 91 private Button mDoneButton;
92 private ViewGroup mDataView; 92 private ViewGroup mDataView;
93 private View mFooter; 93 private View mFooter;
94 @Nullable 94 @Nullable
95 private TextView mCardInput; 95 private TextView mCardInput;
96 @Nullable 96 @Nullable
97 private TextView mPhoneInput; 97 private TextView mPhoneInput;
98 98
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 if (cardNumberPattern.matcher(source.subSequence(start, end)).ma tches()) { 148 if (cardNumberPattern.matcher(source.subSequence(start, end)).ma tches()) {
149 return null; 149 return null;
150 } 150 }
151 151
152 // Reject everything else. 152 // Reject everything else.
153 return ""; 153 return "";
154 } 154 }
155 }; 155 };
156 156
157 mCardNumberFormatter = new CreditCardNumberFormattingTextWatcher(); 157 mCardNumberFormatter = new CreditCardNumberFormattingTextWatcher();
158 mPhoneFormatter = new PhoneNumberUtil.FormatTextWatcher(); 158 mPhoneFormatter = new PhoneNumberUtil.CountryAwareFormatTextWatcher();
159 } 159 }
160 160
161 /** Prevents screenshots of this editor. */ 161 /** Prevents screenshots of this editor. */
162 public void disableScreenshots() { 162 public void disableScreenshots() {
163 WindowManager.LayoutParams attributes = getWindow().getAttributes(); 163 WindowManager.LayoutParams attributes = getWindow().getAttributes();
164 attributes.flags |= WindowManager.LayoutParams.FLAG_SECURE; 164 attributes.flags |= WindowManager.LayoutParams.FLAG_SECURE;
165 getWindow().setAttributes(attributes); 165 getWindow().setAttributes(attributes);
166 } 166 }
167 167
168 /** Launches the Autofill help page on top of the current Context. */ 168 /** Launches the Autofill help page on top of the current Context. */
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 for (int i = 0; i < mFieldViews.size(); i++) { 560 for (int i = 0; i < mFieldViews.size(); i++) {
561 EditorFieldView fieldView = mFieldViews.get(i); 561 EditorFieldView fieldView = mFieldViews.get(i);
562 if (!fieldView.isValid()) { 562 if (!fieldView.isValid()) {
563 invalidViews.add(fieldView); 563 invalidViews.add(fieldView);
564 if (!findAll) break; 564 if (!findAll) break;
565 } 565 }
566 } 566 }
567 return invalidViews; 567 return invalidViews;
568 } 568 }
569 569
570 /**
571 * Update the country code used by the phone formatter. This is called when either user
572 * changes country or when editor is initialized with default country.
573 */
574 public void updateCountryOfPhoneFormatter(String country) {
gogerald1 2017/06/15 17:41:35 It looks not an ideal design to let AddressEditor
wuandy1 2017/06/19 15:11:14 separate cl?
gogerald1 2017/06/19 21:30:38 I would not, this is an important part of your des
575 mPhoneFormatter.setCountryCode(country);
576 }
577
570 /** @return All editable text fields in the editor. Used only for tests. */ 578 /** @return All editable text fields in the editor. Used only for tests. */
571 @VisibleForTesting 579 @VisibleForTesting
572 public List<EditText> getEditableTextFieldsForTest() { 580 public List<EditText> getEditableTextFieldsForTest() {
573 return mEditableTextFields; 581 return mEditableTextFields;
574 } 582 }
575 583
576 /** @return All dropdown fields in the editor. Used only for tests. */ 584 /** @return All dropdown fields in the editor. Used only for tests. */
577 @VisibleForTesting 585 @VisibleForTesting
578 public List<Spinner> getDropdownFieldsForTest() { 586 public List<Spinner> getDropdownFieldsForTest() {
579 return mDropdownFields; 587 return mDropdownFields;
580 } 588 }
581 } 589 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698