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

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

Issue 2952673002: [Payments] Format and validate phone number according to selected country in address editor (Closed)
Patch Set: Fix tests 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/ui/EditorFieldModel.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/EditorFieldModel.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/EditorFieldModel.java
index 08037a67ce51937cb072438d1bf48ce1ccc5779d..deb6e9ccd8070f374094e0a95b03f7f588f3bbb8 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/EditorFieldModel.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/EditorFieldModel.java
@@ -5,6 +5,7 @@
package org.chromium.chrome.browser.payments.ui;
import android.text.TextUtils;
+import android.text.TextWatcher;
import android.util.Pair;
import org.chromium.base.Callback;
@@ -118,6 +119,8 @@ public class EditorFieldModel {
@Nullable private List<DropdownKeyValue> mDropdownKeyValues;
@Nullable private Set<String> mDropdownKeys;
@Nullable private List<CharSequence> mSuggestions;
+ @Nullable
+ private TextWatcher mFormatter;
@Nullable private EditorFieldValidator mValidator;
@Nullable private EditorValueIconGenerator mValueIconGenerator;
@Nullable private CharSequence mRequiredErrorMessage;
@@ -267,6 +270,7 @@ public class EditorFieldModel {
* @param label The human-readable label for user to understand the type of data
* that should be entered into this field.
* @param suggestions Optional set of values to suggest to the user.
+ * @param formatter Optional formatter for the values in this field.
* @param validator Optional validator for the values in this field.
* @param valueIconGenerator Optional icon generator for the values in this field.
* @param requiredErrorMessage The optional error message that indicates to the user that they
@@ -276,7 +280,8 @@ public class EditorFieldModel {
* @param value Optional initial value of this field.
*/
public static EditorFieldModel createTextInput(int inputTypeHint, CharSequence label,
- @Nullable Set<CharSequence> suggestions, @Nullable EditorFieldValidator validator,
+ @Nullable Set<CharSequence> suggestions, @Nullable TextWatcher formatter,
+ @Nullable EditorFieldValidator validator,
@Nullable EditorValueIconGenerator valueIconGenerator,
@Nullable CharSequence requiredErrorMessage, @Nullable CharSequence invalidErrorMessage,
@Nullable CharSequence value) {
@@ -284,6 +289,7 @@ public class EditorFieldModel {
EditorFieldModel result = new EditorFieldModel(inputTypeHint);
assert result.isTextField();
result.mSuggestions = suggestions == null ? null : new ArrayList<CharSequence>(suggestions);
+ result.mFormatter = formatter;
result.mValidator = validator;
result.mValueIconGenerator = valueIconGenerator;
result.mInvalidErrorMessage = invalidErrorMessage;
@@ -331,6 +337,13 @@ public class EditorFieldModel {
return mActionIconAction;
}
+ /** @return The value formatter or null if not exist. */
+ @Nullable
+ public TextWatcher getFormatter() {
+ assert isTextField();
+ return mFormatter;
+ }
+
/** @return The value icon generator or null if not exist. */
public EditorValueIconGenerator getValueIconGenerator() {
assert isTextField();

Powered by Google App Engine
This is Rietveld 408576698