summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/current.txt35
-rw-r--r--api/system-current.txt35
-rw-r--r--api/test-current.txt35
-rw-r--r--core/java/android/app/assist/AssistStructure.java13
-rw-r--r--core/java/android/view/View.java165
-rw-r--r--core/java/android/view/ViewStructure.java3
-rw-r--r--core/res/res/values/attrs.xml34
7 files changed, 153 insertions, 167 deletions
diff --git a/api/current.txt b/api/current.txt
index 97a6794c200c..f11bcb0ddd19 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -6565,7 +6565,7 @@ package android.app.assist {
public static class AssistStructure.ViewNode {
method public float getAlpha();
- method public int getAutoFillHint();
+ method public java.lang.String[] getAutoFillHint();
method public android.view.autofill.AutofillId getAutofillId();
method public java.lang.String[] getAutofillOptions();
method public int getAutofillType();
@@ -45091,7 +45091,7 @@ package android.view {
method public float getAlpha();
method public android.view.animation.Animation getAnimation();
method public android.os.IBinder getApplicationWindowToken();
- method public int getAutofillHint();
+ method public java.lang.String[] getAutofillHint();
method public int getAutofillMode();
method public int getAutofillType();
method public android.view.autofill.AutofillValue getAutofillValue();
@@ -45412,7 +45412,7 @@ package android.view {
method public void setActivated(boolean);
method public void setAlpha(float);
method public void setAnimation(android.view.animation.Animation);
- method public void setAutofillHint(int);
+ method public void setAutofillHint(java.lang.String[]);
method public void setAutofillMode(int);
method public void setBackground(android.graphics.drawable.Drawable);
method public void setBackgroundColor(int);
@@ -45555,20 +45555,19 @@ package android.view {
field public static final int ACCESSIBILITY_LIVE_REGION_NONE = 0; // 0x0
field public static final int ACCESSIBILITY_LIVE_REGION_POLITE = 1; // 0x1
field public static final android.util.Property<android.view.View, java.lang.Float> ALPHA;
- field public static final int AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE = 512; // 0x200
- field public static final int AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY = 4096; // 0x1000
- field public static final int AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH = 1024; // 0x400
- field public static final int AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR = 2048; // 0x800
- field public static final int AUTOFILL_HINT_CREDIT_CARD_NUMBER = 128; // 0x80
- field public static final int AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE = 256; // 0x100
- field public static final int AUTOFILL_HINT_EMAIL_ADDRESS = 1; // 0x1
- field public static final int AUTOFILL_HINT_NAME = 2; // 0x2
- field public static final int AUTOFILL_HINT_NONE = 0; // 0x0
- field public static final int AUTOFILL_HINT_PASSWORD = 8; // 0x8
- field public static final int AUTOFILL_HINT_PHONE = 16; // 0x10
- field public static final int AUTOFILL_HINT_POSTAL_ADDRESS = 32; // 0x20
- field public static final int AUTOFILL_HINT_POSTAL_CODE = 64; // 0x40
- field public static final int AUTOFILL_HINT_USERNAME = 4; // 0x4
+ field public static final java.lang.String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE = "creditCardExpirationDate";
+ field public static final java.lang.String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY = "creditCardExpirationDay";
+ field public static final java.lang.String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH = "creditCardExpirationMonth";
+ field public static final java.lang.String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR = "creditCardExpirationYear";
+ field public static final java.lang.String AUTOFILL_HINT_CREDIT_CARD_NUMBER = "creditCardNumber";
+ field public static final java.lang.String AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE = "creditCardSecurityCode";
+ field public static final java.lang.String AUTOFILL_HINT_EMAIL_ADDRESS = "emailAddress";
+ field public static final java.lang.String AUTOFILL_HINT_NAME = "name";
+ field public static final java.lang.String AUTOFILL_HINT_PASSWORD = "password";
+ field public static final java.lang.String AUTOFILL_HINT_PHONE = "phone";
+ field public static final java.lang.String AUTOFILL_HINT_POSTAL_ADDRESS = "postalAddress";
+ field public static final java.lang.String AUTOFILL_HINT_POSTAL_CODE = "postalCode";
+ field public static final java.lang.String AUTOFILL_HINT_USERNAME = "username";
field public static final int AUTOFILL_MODE_AUTO = 1; // 0x1
field public static final int AUTOFILL_MODE_INHERIT = 0; // 0x0
field public static final int AUTOFILL_MODE_MANUAL = 2; // 0x2
@@ -46230,7 +46229,7 @@ package android.view {
method public abstract void setAccessibilityFocused(boolean);
method public abstract void setActivated(boolean);
method public abstract void setAlpha(float);
- method public abstract void setAutofillHint(int);
+ method public abstract void setAutofillHint(java.lang.String[]);
method public abstract void setAutofillOptions(java.lang.String[]);
method public abstract void setAutofillType(int);
method public abstract void setAutofillValue(android.view.autofill.AutofillValue);
diff --git a/api/system-current.txt b/api/system-current.txt
index 517c748cf608..82d59ae61fe0 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -6815,7 +6815,7 @@ package android.app.assist {
public static class AssistStructure.ViewNode {
method public float getAlpha();
- method public int getAutoFillHint();
+ method public java.lang.String[] getAutoFillHint();
method public android.view.autofill.AutofillId getAutofillId();
method public java.lang.String[] getAutofillOptions();
method public int getAutofillType();
@@ -48551,7 +48551,7 @@ package android.view {
method public float getAlpha();
method public android.view.animation.Animation getAnimation();
method public android.os.IBinder getApplicationWindowToken();
- method public int getAutofillHint();
+ method public java.lang.String[] getAutofillHint();
method public int getAutofillMode();
method public int getAutofillType();
method public android.view.autofill.AutofillValue getAutofillValue();
@@ -48872,7 +48872,7 @@ package android.view {
method public void setActivated(boolean);
method public void setAlpha(float);
method public void setAnimation(android.view.animation.Animation);
- method public void setAutofillHint(int);
+ method public void setAutofillHint(java.lang.String[]);
method public void setAutofillMode(int);
method public void setBackground(android.graphics.drawable.Drawable);
method public void setBackgroundColor(int);
@@ -49015,20 +49015,19 @@ package android.view {
field public static final int ACCESSIBILITY_LIVE_REGION_NONE = 0; // 0x0
field public static final int ACCESSIBILITY_LIVE_REGION_POLITE = 1; // 0x1
field public static final android.util.Property<android.view.View, java.lang.Float> ALPHA;
- field public static final int AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE = 512; // 0x200
- field public static final int AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY = 4096; // 0x1000
- field public static final int AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH = 1024; // 0x400
- field public static final int AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR = 2048; // 0x800
- field public static final int AUTOFILL_HINT_CREDIT_CARD_NUMBER = 128; // 0x80
- field public static final int AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE = 256; // 0x100
- field public static final int AUTOFILL_HINT_EMAIL_ADDRESS = 1; // 0x1
- field public static final int AUTOFILL_HINT_NAME = 2; // 0x2
- field public static final int AUTOFILL_HINT_NONE = 0; // 0x0
- field public static final int AUTOFILL_HINT_PASSWORD = 8; // 0x8
- field public static final int AUTOFILL_HINT_PHONE = 16; // 0x10
- field public static final int AUTOFILL_HINT_POSTAL_ADDRESS = 32; // 0x20
- field public static final int AUTOFILL_HINT_POSTAL_CODE = 64; // 0x40
- field public static final int AUTOFILL_HINT_USERNAME = 4; // 0x4
+ field public static final java.lang.String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE = "creditCardExpirationDate";
+ field public static final java.lang.String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY = "creditCardExpirationDay";
+ field public static final java.lang.String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH = "creditCardExpirationMonth";
+ field public static final java.lang.String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR = "creditCardExpirationYear";
+ field public static final java.lang.String AUTOFILL_HINT_CREDIT_CARD_NUMBER = "creditCardNumber";
+ field public static final java.lang.String AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE = "creditCardSecurityCode";
+ field public static final java.lang.String AUTOFILL_HINT_EMAIL_ADDRESS = "emailAddress";
+ field public static final java.lang.String AUTOFILL_HINT_NAME = "name";
+ field public static final java.lang.String AUTOFILL_HINT_PASSWORD = "password";
+ field public static final java.lang.String AUTOFILL_HINT_PHONE = "phone";
+ field public static final java.lang.String AUTOFILL_HINT_POSTAL_ADDRESS = "postalAddress";
+ field public static final java.lang.String AUTOFILL_HINT_POSTAL_CODE = "postalCode";
+ field public static final java.lang.String AUTOFILL_HINT_USERNAME = "username";
field public static final int AUTOFILL_MODE_AUTO = 1; // 0x1
field public static final int AUTOFILL_MODE_INHERIT = 0; // 0x0
field public static final int AUTOFILL_MODE_MANUAL = 2; // 0x2
@@ -49690,7 +49689,7 @@ package android.view {
method public abstract void setAccessibilityFocused(boolean);
method public abstract void setActivated(boolean);
method public abstract void setAlpha(float);
- method public abstract void setAutofillHint(int);
+ method public abstract void setAutofillHint(java.lang.String[]);
method public abstract void setAutofillOptions(java.lang.String[]);
method public abstract void setAutofillType(int);
method public abstract void setAutofillValue(android.view.autofill.AutofillValue);
diff --git a/api/test-current.txt b/api/test-current.txt
index bcd1614b51aa..b161034b5ef1 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -6592,7 +6592,7 @@ package android.app.assist {
public static class AssistStructure.ViewNode {
method public float getAlpha();
- method public int getAutoFillHint();
+ method public java.lang.String[] getAutoFillHint();
method public android.view.autofill.AutofillId getAutofillId();
method public java.lang.String[] getAutofillOptions();
method public int getAutofillType();
@@ -45451,7 +45451,7 @@ package android.view {
method public float getAlpha();
method public android.view.animation.Animation getAnimation();
method public android.os.IBinder getApplicationWindowToken();
- method public int getAutofillHint();
+ method public java.lang.String[] getAutofillHint();
method public int getAutofillMode();
method public int getAutofillType();
method public android.view.autofill.AutofillValue getAutofillValue();
@@ -45775,7 +45775,7 @@ package android.view {
method public void setActivated(boolean);
method public void setAlpha(float);
method public void setAnimation(android.view.animation.Animation);
- method public void setAutofillHint(int);
+ method public void setAutofillHint(java.lang.String[]);
method public void setAutofillMode(int);
method public void setBackground(android.graphics.drawable.Drawable);
method public void setBackgroundColor(int);
@@ -45918,20 +45918,19 @@ package android.view {
field public static final int ACCESSIBILITY_LIVE_REGION_NONE = 0; // 0x0
field public static final int ACCESSIBILITY_LIVE_REGION_POLITE = 1; // 0x1
field public static final android.util.Property<android.view.View, java.lang.Float> ALPHA;
- field public static final int AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE = 512; // 0x200
- field public static final int AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY = 4096; // 0x1000
- field public static final int AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH = 1024; // 0x400
- field public static final int AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR = 2048; // 0x800
- field public static final int AUTOFILL_HINT_CREDIT_CARD_NUMBER = 128; // 0x80
- field public static final int AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE = 256; // 0x100
- field public static final int AUTOFILL_HINT_EMAIL_ADDRESS = 1; // 0x1
- field public static final int AUTOFILL_HINT_NAME = 2; // 0x2
- field public static final int AUTOFILL_HINT_NONE = 0; // 0x0
- field public static final int AUTOFILL_HINT_PASSWORD = 8; // 0x8
- field public static final int AUTOFILL_HINT_PHONE = 16; // 0x10
- field public static final int AUTOFILL_HINT_POSTAL_ADDRESS = 32; // 0x20
- field public static final int AUTOFILL_HINT_POSTAL_CODE = 64; // 0x40
- field public static final int AUTOFILL_HINT_USERNAME = 4; // 0x4
+ field public static final java.lang.String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE = "creditCardExpirationDate";
+ field public static final java.lang.String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY = "creditCardExpirationDay";
+ field public static final java.lang.String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH = "creditCardExpirationMonth";
+ field public static final java.lang.String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR = "creditCardExpirationYear";
+ field public static final java.lang.String AUTOFILL_HINT_CREDIT_CARD_NUMBER = "creditCardNumber";
+ field public static final java.lang.String AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE = "creditCardSecurityCode";
+ field public static final java.lang.String AUTOFILL_HINT_EMAIL_ADDRESS = "emailAddress";
+ field public static final java.lang.String AUTOFILL_HINT_NAME = "name";
+ field public static final java.lang.String AUTOFILL_HINT_PASSWORD = "password";
+ field public static final java.lang.String AUTOFILL_HINT_PHONE = "phone";
+ field public static final java.lang.String AUTOFILL_HINT_POSTAL_ADDRESS = "postalAddress";
+ field public static final java.lang.String AUTOFILL_HINT_POSTAL_CODE = "postalCode";
+ field public static final java.lang.String AUTOFILL_HINT_USERNAME = "username";
field public static final int AUTOFILL_MODE_AUTO = 1; // 0x1
field public static final int AUTOFILL_MODE_INHERIT = 0; // 0x0
field public static final int AUTOFILL_MODE_MANUAL = 2; // 0x2
@@ -46597,7 +46596,7 @@ package android.view {
method public abstract void setAccessibilityFocused(boolean);
method public abstract void setActivated(boolean);
method public abstract void setAlpha(float);
- method public abstract void setAutofillHint(int);
+ method public abstract void setAutofillHint(java.lang.String[]);
method public abstract void setAutofillOptions(java.lang.String[]);
method public abstract void setAutofillType(int);
method public abstract void setAutofillValue(android.view.autofill.AutofillValue);
diff --git a/core/java/android/app/assist/AssistStructure.java b/core/java/android/app/assist/AssistStructure.java
index 1f2ed00fa79d..f41b05fd9a81 100644
--- a/core/java/android/app/assist/AssistStructure.java
+++ b/core/java/android/app/assist/AssistStructure.java
@@ -1,5 +1,6 @@
package android.app.assist;
+import android.annotation.Nullable;
import android.app.Activity;
import android.content.ComponentName;
import android.graphics.Matrix;
@@ -590,7 +591,7 @@ public class AssistStructure implements Parcelable {
// fields (viewId and childId) of the field.
AutofillId mAutofillId;
@View.AutofillType int mAutofillType;
- @View.AutofillHint int mAutofillHint;
+ @Nullable String[] mAutofillHint;
AutofillValue mAutofillValue;
String[] mAutofillOptions;
boolean mSanitized;
@@ -676,7 +677,7 @@ public class AssistStructure implements Parcelable {
mSanitized = in.readInt() == 1;
mAutofillId = in.readParcelable(null);
mAutofillType = in.readInt();
- mAutofillHint = in.readInt();
+ mAutofillHint = in.readStringArray();
mAutofillValue = in.readParcelable(null);
mAutofillOptions = in.readStringArray();
}
@@ -810,7 +811,7 @@ public class AssistStructure implements Parcelable {
out.writeInt(mSanitized ? 1 : 0);
out.writeParcelable(mAutofillId, 0);
out.writeInt(mAutofillType);
- out.writeInt(mAutofillHint);
+ out.writeStringArray(mAutofillHint);
final AutofillValue sanitizedValue = writeSensitive ? mAutofillValue : null;
out.writeParcelable(sanitizedValue, 0);
out.writeStringArray(mAutofillOptions);
@@ -949,7 +950,7 @@ public class AssistStructure implements Parcelable {
*
* @return The hint for this view
*/
- @View.AutofillHint public int getAutoFillHint() {
+ @Nullable public String[] getAutoFillHint() {
return mAutofillHint;
}
@@ -1663,7 +1664,7 @@ public class AssistStructure implements Parcelable {
}
@Override
- public void setAutofillHint(@View.AutofillHint int hint) {
+ public void setAutofillHint(@Nullable String[] hint) {
mNode.mAutofillHint = hint;
}
@@ -1812,7 +1813,7 @@ public class AssistStructure implements Parcelable {
+ ", type=" + node.getAutofillType()
+ ", options=" + Arrays.toString(node.getAutofillOptions())
+ ", inputType=" + node.getInputType()
- + ", hint=" + Integer.toHexString(node.getAutoFillHint())
+ + ", hint=" + Arrays.toString(node.getAutoFillHint())
+ ", value=" + node.getAutofillValue()
+ ", sanitized=" + node.isSanitized());
}
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index aa1cbf2d642e..8aef61b7c866 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -978,142 +978,123 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*/
public static final int AUTOFILL_MODE_MANUAL = 2;
- /** @hide */
- @IntDef({
- AUTOFILL_HINT_NONE,
- AUTOFILL_HINT_EMAIL_ADDRESS,
- AUTOFILL_HINT_NAME,
- AUTOFILL_HINT_POSTAL_ADDRESS,
- AUTOFILL_HINT_PASSWORD,
- AUTOFILL_HINT_PHONE,
- AUTOFILL_HINT_USERNAME,
- AUTOFILL_HINT_POSTAL_CODE,
- AUTOFILL_HINT_CREDIT_CARD_NUMBER,
- AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE,
- AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE,
- AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH,
- AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR,
- AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY,
- })
- @Retention(RetentionPolicy.SOURCE)
- public @interface AutofillHint {}
-
- /**
- * No autofill hint is set.
- *
- * Use with {@link #setAutofillHint(int)} and <a href="#attr_android:autofillHint">
- * {@code android:autofillHint}.
- */
- public static final int AUTOFILL_HINT_NONE = 0;
-
/**
* This view contains an email address.
*
- * Use with {@link #setAutofillHint(int)} and <a href="#attr_android:autofillHint">
- * {@code android:autofillHint}.
+ * Use with {@link #setAutofillHint(String[])}, or set "{@value #AUTOFILL_HINT_EMAIL_ADDRESS}"
+ * to <a href="#attr_android:autofillHint"> {@code android:autofillHint}.
*/
- public static final int AUTOFILL_HINT_EMAIL_ADDRESS = 0x1;
+ public static final String AUTOFILL_HINT_EMAIL_ADDRESS = "emailAddress";
/**
* The view contains a real name.
*
- * Use with {@link #setAutofillHint(int)} and <a href="#attr_android:autofillHint">
- * {@code android:autofillHint}.
+ * Use with {@link #setAutofillHint(String[])}, or set "{@value #AUTOFILL_HINT_NAME}" to
+ * <a href="#attr_android:autofillHint"> {@code android:autofillHint}.
*/
- public static final int AUTOFILL_HINT_NAME = 0x2;
+ public static final String AUTOFILL_HINT_NAME = "name";
/**
* The view contains a user name.
*
- * Use with {@link #setAutofillHint(int)} and <a href="#attr_android:autofillHint">
- * {@code android:autofillHint}.
+ * Use with {@link #setAutofillHint(String[])}, or set "{@value #AUTOFILL_HINT_USERNAME}" to
+ * <a href="#attr_android:autofillHint"> {@code android:autofillHint}.
*/
- public static final int AUTOFILL_HINT_USERNAME = 0x4;
+ public static final String AUTOFILL_HINT_USERNAME = "username";
/**
* The view contains a password.
*
- * Use with {@link #setAutofillHint(int)} and <a href="#attr_android:autofillHint">
- * {@code android:autofillHint}.
+ * Use with {@link #setAutofillHint(String[])}, or set "{@value #AUTOFILL_HINT_PASSWORD}" to
+ * <a href="#attr_android:autofillHint"> {@code android:autofillHint}.
*/
- public static final int AUTOFILL_HINT_PASSWORD = 0x8;
+ public static final String AUTOFILL_HINT_PASSWORD = "password";
/**
* The view contains a phone number.
*
- * Use with {@link #setAutofillHint(int)} and <a href="#attr_android:autofillHint">
- * {@code android:autofillHint}.
+ * Use with {@link #setAutofillHint(String[])}, or set "{@value #AUTOFILL_HINT_PHONE}" to
+ * <a href="#attr_android:autofillHint"> {@code android:autofillHint}.
*/
- public static final int AUTOFILL_HINT_PHONE = 0x10;
+ public static final String AUTOFILL_HINT_PHONE = "phone";
/**
* The view contains a postal address.
*
- * Use with {@link #setAutofillHint(int)} and <a href="#attr_android:autofillHint">
- * {@code android:autofillHint}.
+ * Use with {@link #setAutofillHint(String[])}, or set "{@value #AUTOFILL_HINT_POSTAL_ADDRESS}"
+ * to <a href="#attr_android:autofillHint"> {@code android:autofillHint}.
*/
- public static final int AUTOFILL_HINT_POSTAL_ADDRESS = 0x20;
+ public static final String AUTOFILL_HINT_POSTAL_ADDRESS = "postalAddress";
/**
* The view contains a postal code.
*
- * Use with {@link #setAutofillHint(int)} and <a href="#attr_android:autofillHint">
- * {@code android:autofillHint}.
+ * Use with {@link #setAutofillHint(String[])}, or set "{@value #AUTOFILL_HINT_POSTAL_CODE}" to
+ * <a href="#attr_android:autofillHint"> {@code android:autofillHint}.
*/
- public static final int AUTOFILL_HINT_POSTAL_CODE = 0x40;
+ public static final String AUTOFILL_HINT_POSTAL_CODE = "postalCode";
/**
* The view contains a credit card number.
*
- * Use with {@link #setAutofillHint(int)} and <a href="#attr_android:autofillHint">
- * {@code android:autofillHint}.
+ * Use with {@link #setAutofillHint(String[])}, or set "{@value
+ * #AUTOFILL_HINT_CREDIT_CARD_NUMBER}" to <a href="#attr_android:autofillHint"> {@code
+ * android:autofillHint}.
*/
- public static final int AUTOFILL_HINT_CREDIT_CARD_NUMBER = 0x80;
+ public static final String AUTOFILL_HINT_CREDIT_CARD_NUMBER = "creditCardNumber";
/**
* The view contains a credit card security code.
*
- * Use with {@link #setAutofillHint(int)} and <a href="#attr_android:autofillHint">
- * {@code android:autofillHint}.
+ * Use with {@link #setAutofillHint(String[])}, or set "{@value
+ * #AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE}" to <a href="#attr_android:autofillHint"> {@code
+ * android:autofillHint}.
*/
- public static final int AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE = 0x100;
+ public static final String AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE = "creditCardSecurityCode";
/**
* The view contains a credit card expiration date.
*
- * Use with {@link #setAutofillHint(int)} and <a href="#attr_android:autofillHint">
- * {@code android:autofillHint}.
+ * Use with {@link #setAutofillHint(String[])}, or set "{@value
+ * #AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE}" to <a href="#attr_android:autofillHint"> {@code
+ * android:autofillHint}.
*/
- public static final int AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE = 0x200;
+ public static final String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE =
+ "creditCardExpirationDate";
/**
* The view contains the month a credit card expires.
*
- * Use with {@link #setAutofillHint(int)} and <a href="#attr_android:autofillHint">
- * {@code android:autofillHint}.
+ * Use with {@link #setAutofillHint(String[])}, or set "{@value
+ * #AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH}" to <a href="#attr_android:autofillHint"> {@code
+ * android:autofillHint}.
*/
- public static final int AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH = 0x400;
+ public static final String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH =
+ "creditCardExpirationMonth";
/**
* The view contains the year a credit card expires.
*
- * Use with {@link #setAutofillHint(int)} and <a href="#attr_android:autofillHint">
- * {@code android:autofillHint}.
+ * Use with {@link #setAutofillHint(String[])}, or set "{@value
+ * #AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR}" to <a href="#attr_android:autofillHint"> {@code
+ * android:autofillHint}.
*/
- public static final int AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR = 0x800;
+ public static final String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR =
+ "creditCardExpirationYear";
/**
* The view contains the day a credit card expires.
*
- * Use with {@link #setAutofillHint(int)} and <a href="#attr_android:autofillHint">
- * {@code android:autofillHint}.
+ * Use with {@link #setAutofillHint(String[])}, or set "{@value
+ * #AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY}" to <a href="#attr_android:autofillHint"> {@code
+ * android:autofillHint}.
*/
- public static final int AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY = 0x1000;
+ public static final String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY = "creditCardExpirationDay";
/**
- * Hint for the autofill services that describes the content of the view.
+ * Hintd for the autofill services that describes the content of the view.
*/
- @AutofillHint private int mAutofillHint;
+ private @Nullable String[] mAutofillHint;
/** @hide */
@IntDef({
@@ -5049,7 +5030,37 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
break;
case R.styleable.View_autofillHint:
if (a.peekValue(attr) != null) {
- setAutofillHint(a.getInt(attr, AUTOFILL_HINT_NONE));
+ CharSequence[] rawHints = null;
+ String rawString = null;
+
+ if (a.getType(attr) == TypedValue.TYPE_REFERENCE) {
+ int resId = a.getResourceId(attr, 0);
+
+ try {
+ rawHints = a.getTextArray(attr);
+ } catch (NullPointerException e) {
+ rawString = getResources().getString(resId);
+ }
+ } else {
+ rawString = a.getString(attr);
+ }
+
+ if (rawHints == null) {
+ if (rawString == null) {
+ throw new IllegalArgumentException(
+ "Could not resolve autofillHint");
+ } else {
+ rawHints = rawString.split(",");
+ }
+ }
+
+ String[] hints = new String[rawHints.length];
+
+ int numHints = rawHints.length;
+ for (int rawHintNum = 0; rawHintNum < numHints; rawHintNum++) {
+ hints[rawHintNum] = rawHints[rawHintNum].toString().trim();
+ }
+ setAutofillHint(hints);
}
break;
case R.styleable.View_importantForAutofill:
@@ -7453,12 +7464,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
/**
* Describes the content of a view so that a autofill service can fill in the appropriate data.
*
- * @return The hint set via the attribute
+ * @return The hint set via the attribute or {@code null} if no hint it set.
*
* @attr ref android.R.styleable#View_autofillHint
*/
@ViewDebug.ExportedProperty()
- @AutofillHint public int getAutofillHint() {
+ @Nullable public String[] getAutofillHint() {
return mAutofillHint;
}
@@ -9088,11 +9099,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* Sets the a hint that helps the autofill service to select the appropriate data to fill the
* view.
*
- * @param autofillHint The autofill hint to set
+ * @param autofillHint The autofill hint to set. If the array is emtpy, {@code null} is set.
* @attr ref android.R.styleable#View_autofillHint
*/
- public void setAutofillHint(@AutofillHint int autofillHint) {
- mAutofillHint = autofillHint;
+ public void setAutofillHint(@Nullable String... autofillHint) {
+ if (autofillHint == null || autofillHint.length == 0) {
+ mAutofillHint = null;
+ } else {
+ mAutofillHint = autofillHint;
+ }
}
/**
diff --git a/core/java/android/view/ViewStructure.java b/core/java/android/view/ViewStructure.java
index bccaca2c8baa..5eac708a9aeb 100644
--- a/core/java/android/view/ViewStructure.java
+++ b/core/java/android/view/ViewStructure.java
@@ -16,6 +16,7 @@
package android.view;
+import android.annotation.Nullable;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.os.Bundle;
@@ -323,7 +324,7 @@ public abstract class ViewStructure {
* Sets the a hint that helps the autofill service to select the appropriate data to fill the
* view.
*/
- public abstract void setAutofillHint(@View.AutofillHint int hint);
+ public abstract void setAutofillHint(@Nullable String[] hint);
/**
* Sets the {@link AutofillValue} representing the current value of this node.
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 21c8780096f9..cb81c495efb8 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -2307,37 +2307,9 @@
</attr>
<!-- Describes the content of a view so that a autofill service can fill in the appropriate
- data. Multiple flags can be combined to mean e.g. emailAddress or postalAddress. -->
- <attr name="autofillHint">
- <!-- No hint. -->
- <flag name="none" value="0" />
- <!-- The view contains an email address. -->
- <flag name="emailAddress" value="0x1" />
- <!-- The view contains a real name. -->
- <flag name="name" value="0x2" />
- <!-- The view contains a user name. -->
- <flag name="username" value="0x4" />
- <!-- The view contains a password. -->
- <flag name="password" value="0x8" />
- <!-- The view contains a phone number. -->
- <flag name="phone" value="0x10" />
- <!-- The view contains a postal address. -->
- <flag name="postalAddress" value="0x20" />
- <!-- The view contains a postal code. -->
- <flag name="postalCode" value="0x40" />
- <!-- The view contains a credit card number. -->
- <flag name="creditCardNumber" value="0x80" />
- <!-- The view contains a credit card security code -->
- <flag name="creditCardSecurityCode" value="0x100" />
- <!-- The view contains a credit card expiration date -->
- <flag name="creditCardExpirationDate" value="0x200" />
- <!-- The view contains the month a credit card expires -->
- <flag name="creditCardExpirationMonth" value="0x400" />
- <!-- The view contains the year a credit card expires -->
- <flag name="creditCardExpirationYear" value="0x800" />
- <!-- The view contains the day a credit card expires -->
- <flag name="creditCardExpirationDay" value="0x1000" />
- </attr>
+ data. Multiple hints can be combined in a comma separated list or an array of strings
+ to mean e.g. emailAddress or postalAddress. -->
+ <attr name="autofillHint" format="string|reference" />
<!-- Hints the Android System whether the view node associated with this View should be
included in a view structure used for autofill purposes. -->