diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index d030c93a1211d..166d6b7a5b1c7 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -127,6 +127,7 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Arrays; +import java.util.Calendar; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -1078,6 +1079,29 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * {@code android:autofillHint} (in which case the * value should be {@value #AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE}). * + *

When annotating a view with this hint, it's recommended to use a date autofill value to + * avoid ambiguity when the autofill service provides a value for it. To understand why a + * value can be ambiguous, consider "April of 2020", which could be represented as either of + * the following options: + * + *

+ * + *

You define a date autofill value for the view by overriding the following methods: + * + *

    + *
  1. {@link #getAutofillType()} to return {@link #AUTOFILL_TYPE_DATE}. + *
  2. {@link #getAutofillValue()} to return a + * {@link AutofillValue#forDate(long) date autofillvalue}. + *
  3. {@link #autofill(AutofillValue)} to expect a data autofillvalue. + *
+ * *

See {@link #setAutofillHints(String...)} for more info about autofill hints. */ public static final String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE = @@ -1090,6 +1114,22 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * {@code android:autofillHint} (in which case the * value should be {@value #AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH}). * + *

When annotating a view with this hint, it's recommended to use a text autofill value + * whose value is the numerical representation of the month, starting on {@code 1} to avoid + * ambiguity when the autofill service provides a value for it. To understand why a + * value can be ambiguous, consider "January", which could be represented as either of + * + *

+ * + *

Another recommended approach is to use a date autofill value - see + * {@link #AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE} for more details. + * *

See {@link #setAutofillHints(String...)} for more info about autofill hints. */ public static final String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH =