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

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: fix assertion error and reland Created 4 years, 1 month 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 19d4bbfb22c23041ea86b8642f03c004bac2f9d3..06f09a0b60574d02611c3abbb935cee17aa00df5 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.
+ */
+ 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.
+ */
+ 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,10 +119,10 @@ 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;
private int mLabelIconResourceId;
private int mActionIconResourceId;
- private int mActionDescriptionForAccessibility;
+ private int mActionIconDescriptionForAccessibility;
private boolean mIsFullLine = true;
/**
@@ -242,6 +255,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
@@ -250,6 +264,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;
@@ -257,6 +272,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;
@@ -275,8 +291,8 @@ public class EditorFieldModel {
public void addActionIcon(int icon, int description, Runnable action) {
assert isTextField();
mActionIconResourceId = icon;
- mActionDescriptionForAccessibility = description;
- mIconAction = action;
+ mActionIconDescriptionForAccessibility = description;
+ mActionIconAction = action;
}
private EditorFieldModel(int inputTypeHint) {
@@ -290,16 +306,22 @@ public class EditorFieldModel {
return mActionIconResourceId;
}
- /** @return The string resource for the human readable description of the action. */
- public int getActionDescriptionForAccessibility() {
+ /** @return The string resource for the human readable description of the action icon. */
+ public int getActionIconDescriptionForAccessibility() {
+ assert isTextField();
+ return mActionIconDescriptionForAccessibility;
+ }
+
+ /** @return The action to invoke when the action icon has been tapped. */
+ public Runnable getActionIconAction() {
assert isTextField();
- return mActionDescriptionForAccessibility;
+ return mActionIconAction;
}
- /** @return The action to invoke when the icon has been tapped. */
- public Runnable getIconAction() {
+ /** @return The value icon generator or null if not exist. */
+ public EditorValueIconGenerator getValueIconGenerator() {
assert isTextField();
- return mIconAction;
+ return mValueIconGenerator;
}
private boolean isTextField() {

Powered by Google App Engine
This is Rietveld 408576698