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

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

Issue 2442933003: [Payments] Show the icon for the typed in credit card in editor (Closed)
Patch Set: Created 4 years, 2 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 c299f081a92d33bb59c43d224602aef2a68fa412..48775a38ccc7f19806e648be7d6d278657abcf44 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
@@ -36,6 +36,18 @@ public class EditorFieldModel {
boolean isValid(@Nullable CharSequence value);
}
+ /**
+ * The interface to be implemented by the field value icon generator.
+ */
please use gerrit instead 2016/10/25 17:48:18 Comment indentation
gogerald1 2016/10/26 15:22:16 Done.
+ public interface EditorValueIconGenerator {
+ /**
+ * Called to get the field value icon resource Id.
+ * @param value The value of the field.
+ * @return The resouce Id of the value icon, 0 indicates no icon.
+ */
please use gerrit instead 2016/10/25 17:48:18 Ditto
gogerald1 2016/10/26 15:22:16 Done.
+ int getIconResourceId(@Nullable CharSequence value);
+ }
+
private static final int INPUT_TYPE_HINT_MIN_INCLUSIVE = 0;
/** Text input with no special formatting rules, e.g., a city, a suburb, or a company name. */
@@ -98,6 +110,7 @@ public class EditorFieldModel {
@Nullable private Set<String> mDropdownKeys;
@Nullable private List<CharSequence> mSuggestions;
@Nullable private EditorFieldValidator mValidator;
+ @Nullable private EditorValueIconGenerator mValueIconGenerator;
@Nullable private CharSequence mRequiredErrorMessage;
@Nullable private CharSequence mInvalidErrorMessage;
@Nullable private CharSequence mErrorMessage;
@@ -106,7 +119,7 @@ public class EditorFieldModel {
@Nullable private CharSequence mBottomLabel;
@Nullable private CharSequence mValue;
@Nullable private Callback<Pair<String, Runnable>> mDropdownCallback;
- @Nullable private Runnable mIconAction;
+ @Nullable private Runnable mActionIconAction;
please use gerrit instead 2016/10/25 17:48:18 Why this rename?
gogerald1 2016/10/26 15:22:16 Now there are two icons may display at the same ti
private int mLabelIconResourceId;
private int mActionIconResourceId;
private int mActionDescriptionForAccessibility;
@@ -219,6 +232,7 @@ public class EditorFieldModel {
* that should be entered into this field.
* @param suggestions Optional set of values to suggest to the user.
* @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
* cannot leave this field empty.
* @param invalidErrorMessage The optional error message that indicates to the user that the
@@ -227,6 +241,7 @@ public class EditorFieldModel {
*/
public static EditorFieldModel createTextInput(int inputTypeHint, CharSequence label,
@Nullable Set<CharSequence> suggestions, @Nullable EditorFieldValidator validator,
+ @Nullable EditorValueIconGenerator valueIconGenerator,
@Nullable CharSequence requiredErrorMessage, @Nullable CharSequence invalidErrorMessage,
@Nullable CharSequence value) {
assert label != null;
@@ -234,6 +249,7 @@ public class EditorFieldModel {
assert result.isTextField();
result.mSuggestions = suggestions == null ? null : new ArrayList<CharSequence>(suggestions);
result.mValidator = validator;
+ result.mValueIconGenerator = valueIconGenerator;
result.mInvalidErrorMessage = invalidErrorMessage;
result.mRequiredErrorMessage = requiredErrorMessage;
result.mLabel = label;
@@ -253,7 +269,7 @@ public class EditorFieldModel {
assert isTextField();
mActionIconResourceId = icon;
mActionDescriptionForAccessibility = description;
- mIconAction = action;
+ mActionIconAction = action;
}
private EditorFieldModel(int inputTypeHint) {
@@ -273,10 +289,21 @@ public class EditorFieldModel {
return mActionDescriptionForAccessibility;
}
- /** @return The action to invoke when the icon has been tapped. */
- public Runnable getIconAction() {
+ /** @return The action to invoke when the action icon has been tapped. */
+ public Runnable getActionIconAction() {
assert isTextField();
- return mIconAction;
+ return mActionIconAction;
+ }
+
+ /**
+ * @return The icon resource Id for the value in this field.
please use gerrit instead 2016/10/25 17:48:18 This whole comment can fit on the same line: /**
gogerald1 2016/10/26 15:22:16 Done.
+ */
+ public int getValueIconResourceId() {
+ assert mInputTypeHint == INPUT_TYPE_HINT_CREDIT_CARD;
+ if (mValueIconGenerator != null) {
+ return mValueIconGenerator.getIconResourceId(mValue);
+ }
+ return 0;
please use gerrit instead 2016/10/25 17:48:18 Yo can reduce the number of lines here: return mV
gogerald1 2016/10/26 15:22:16 Done. The implementation changed.
}
private boolean isTextField() {

Powered by Google App Engine
This is Rietveld 408576698