Add more AutofillTypes
Add more AutofillTypes corresponding to the Android Autofill Hints at https://developer.android.com/reference/androidx/autofill/HintConstants.html
Fixes: 138551812, 148373103
Test: Added new test
Change-Id: If00995297b96e10c4ea9c3d6c6aef9c71d90b177
diff --git a/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/autofill/AndroidAutofillBenchmark.kt b/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/autofill/AndroidAutofillBenchmark.kt
index af0c5cd..a1ffe7c 100644
--- a/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/autofill/AndroidAutofillBenchmark.kt
+++ b/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/autofill/AndroidAutofillBenchmark.kt
@@ -61,7 +61,7 @@
// Arrange.
val autofillNode = AutofillNode(
>
- autofillTypes = listOf(AutofillType.Name),
+ autofillTypes = listOf(AutofillType.PersonFullName),
boundingBox = Rect(0, 0, 0, 0)
)
val autofillValues = SparseArray<AutofillValue>().apply {
diff --git a/ui/ui-core/api/0.1.0-dev09.txt b/ui/ui-core/api/0.1.0-dev09.txt
index 8ff5c46..1702b22 100644
--- a/ui/ui-core/api/0.1.0-dev09.txt
+++ b/ui/ui-core/api/0.1.0-dev09.txt
@@ -29,8 +29,43 @@
}
public enum AutofillType {
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressAuxiliaryDetails;
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressCountry;
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressLocality;
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressRegion;
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressStreet;
+ enum_constant public static final androidx.ui.autofill.AutofillType BirthDateDay;
+ enum_constant public static final androidx.ui.autofill.AutofillType BirthDateFull;
+ enum_constant public static final androidx.ui.autofill.AutofillType BirthDateMonth;
+ enum_constant public static final androidx.ui.autofill.AutofillType BirthDateYear;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardExpirationDate;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardExpirationDay;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardExpirationMonth;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardExpirationYear;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardNumber;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardSecurityCode;
enum_constant public static final androidx.ui.autofill.AutofillType EmailAddress;
- enum_constant public static final androidx.ui.autofill.AutofillType Name;
+ enum_constant public static final androidx.ui.autofill.AutofillType Gender;
+ enum_constant @Deprecated public static final androidx.ui.autofill.AutofillType Name;
+ enum_constant public static final androidx.ui.autofill.AutofillType NewPassword;
+ enum_constant public static final androidx.ui.autofill.AutofillType NewUsername;
+ enum_constant public static final androidx.ui.autofill.AutofillType Password;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonFirstName;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonFullName;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonLastName;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonMiddleInitial;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonMiddleName;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonNamePrefix;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonNameSuffix;
+ enum_constant public static final androidx.ui.autofill.AutofillType PhoneCountryCode;
+ enum_constant public static final androidx.ui.autofill.AutofillType PhoneNumber;
+ enum_constant public static final androidx.ui.autofill.AutofillType PhoneNumberDevice;
+ enum_constant public static final androidx.ui.autofill.AutofillType PhoneNumberNational;
+ enum_constant public static final androidx.ui.autofill.AutofillType PostalAddress;
+ enum_constant public static final androidx.ui.autofill.AutofillType PostalCode;
+ enum_constant public static final androidx.ui.autofill.AutofillType PostalCodeExtended;
+ enum_constant public static final androidx.ui.autofill.AutofillType SmsOtpCode;
+ enum_constant public static final androidx.ui.autofill.AutofillType Username;
}
}
diff --git a/ui/ui-core/api/current.txt b/ui/ui-core/api/current.txt
index 8ff5c46..1702b22 100644
--- a/ui/ui-core/api/current.txt
+++ b/ui/ui-core/api/current.txt
@@ -29,8 +29,43 @@
}
public enum AutofillType {
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressAuxiliaryDetails;
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressCountry;
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressLocality;
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressRegion;
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressStreet;
+ enum_constant public static final androidx.ui.autofill.AutofillType BirthDateDay;
+ enum_constant public static final androidx.ui.autofill.AutofillType BirthDateFull;
+ enum_constant public static final androidx.ui.autofill.AutofillType BirthDateMonth;
+ enum_constant public static final androidx.ui.autofill.AutofillType BirthDateYear;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardExpirationDate;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardExpirationDay;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardExpirationMonth;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardExpirationYear;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardNumber;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardSecurityCode;
enum_constant public static final androidx.ui.autofill.AutofillType EmailAddress;
- enum_constant public static final androidx.ui.autofill.AutofillType Name;
+ enum_constant public static final androidx.ui.autofill.AutofillType Gender;
+ enum_constant @Deprecated public static final androidx.ui.autofill.AutofillType Name;
+ enum_constant public static final androidx.ui.autofill.AutofillType NewPassword;
+ enum_constant public static final androidx.ui.autofill.AutofillType NewUsername;
+ enum_constant public static final androidx.ui.autofill.AutofillType Password;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonFirstName;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonFullName;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonLastName;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonMiddleInitial;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonMiddleName;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonNamePrefix;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonNameSuffix;
+ enum_constant public static final androidx.ui.autofill.AutofillType PhoneCountryCode;
+ enum_constant public static final androidx.ui.autofill.AutofillType PhoneNumber;
+ enum_constant public static final androidx.ui.autofill.AutofillType PhoneNumberDevice;
+ enum_constant public static final androidx.ui.autofill.AutofillType PhoneNumberNational;
+ enum_constant public static final androidx.ui.autofill.AutofillType PostalAddress;
+ enum_constant public static final androidx.ui.autofill.AutofillType PostalCode;
+ enum_constant public static final androidx.ui.autofill.AutofillType PostalCodeExtended;
+ enum_constant public static final androidx.ui.autofill.AutofillType SmsOtpCode;
+ enum_constant public static final androidx.ui.autofill.AutofillType Username;
}
}
diff --git a/ui/ui-core/api/public_plus_experimental_0.1.0-dev09.txt b/ui/ui-core/api/public_plus_experimental_0.1.0-dev09.txt
index 8ff5c46..1702b22 100644
--- a/ui/ui-core/api/public_plus_experimental_0.1.0-dev09.txt
+++ b/ui/ui-core/api/public_plus_experimental_0.1.0-dev09.txt
@@ -29,8 +29,43 @@
}
public enum AutofillType {
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressAuxiliaryDetails;
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressCountry;
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressLocality;
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressRegion;
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressStreet;
+ enum_constant public static final androidx.ui.autofill.AutofillType BirthDateDay;
+ enum_constant public static final androidx.ui.autofill.AutofillType BirthDateFull;
+ enum_constant public static final androidx.ui.autofill.AutofillType BirthDateMonth;
+ enum_constant public static final androidx.ui.autofill.AutofillType BirthDateYear;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardExpirationDate;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardExpirationDay;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardExpirationMonth;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardExpirationYear;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardNumber;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardSecurityCode;
enum_constant public static final androidx.ui.autofill.AutofillType EmailAddress;
- enum_constant public static final androidx.ui.autofill.AutofillType Name;
+ enum_constant public static final androidx.ui.autofill.AutofillType Gender;
+ enum_constant @Deprecated public static final androidx.ui.autofill.AutofillType Name;
+ enum_constant public static final androidx.ui.autofill.AutofillType NewPassword;
+ enum_constant public static final androidx.ui.autofill.AutofillType NewUsername;
+ enum_constant public static final androidx.ui.autofill.AutofillType Password;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonFirstName;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonFullName;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonLastName;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonMiddleInitial;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonMiddleName;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonNamePrefix;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonNameSuffix;
+ enum_constant public static final androidx.ui.autofill.AutofillType PhoneCountryCode;
+ enum_constant public static final androidx.ui.autofill.AutofillType PhoneNumber;
+ enum_constant public static final androidx.ui.autofill.AutofillType PhoneNumberDevice;
+ enum_constant public static final androidx.ui.autofill.AutofillType PhoneNumberNational;
+ enum_constant public static final androidx.ui.autofill.AutofillType PostalAddress;
+ enum_constant public static final androidx.ui.autofill.AutofillType PostalCode;
+ enum_constant public static final androidx.ui.autofill.AutofillType PostalCodeExtended;
+ enum_constant public static final androidx.ui.autofill.AutofillType SmsOtpCode;
+ enum_constant public static final androidx.ui.autofill.AutofillType Username;
}
}
diff --git a/ui/ui-core/api/public_plus_experimental_current.txt b/ui/ui-core/api/public_plus_experimental_current.txt
index 8ff5c46..1702b22 100644
--- a/ui/ui-core/api/public_plus_experimental_current.txt
+++ b/ui/ui-core/api/public_plus_experimental_current.txt
@@ -29,8 +29,43 @@
}
public enum AutofillType {
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressAuxiliaryDetails;
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressCountry;
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressLocality;
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressRegion;
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressStreet;
+ enum_constant public static final androidx.ui.autofill.AutofillType BirthDateDay;
+ enum_constant public static final androidx.ui.autofill.AutofillType BirthDateFull;
+ enum_constant public static final androidx.ui.autofill.AutofillType BirthDateMonth;
+ enum_constant public static final androidx.ui.autofill.AutofillType BirthDateYear;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardExpirationDate;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardExpirationDay;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardExpirationMonth;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardExpirationYear;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardNumber;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardSecurityCode;
enum_constant public static final androidx.ui.autofill.AutofillType EmailAddress;
- enum_constant public static final androidx.ui.autofill.AutofillType Name;
+ enum_constant public static final androidx.ui.autofill.AutofillType Gender;
+ enum_constant @Deprecated public static final androidx.ui.autofill.AutofillType Name;
+ enum_constant public static final androidx.ui.autofill.AutofillType NewPassword;
+ enum_constant public static final androidx.ui.autofill.AutofillType NewUsername;
+ enum_constant public static final androidx.ui.autofill.AutofillType Password;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonFirstName;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonFullName;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonLastName;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonMiddleInitial;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonMiddleName;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonNamePrefix;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonNameSuffix;
+ enum_constant public static final androidx.ui.autofill.AutofillType PhoneCountryCode;
+ enum_constant public static final androidx.ui.autofill.AutofillType PhoneNumber;
+ enum_constant public static final androidx.ui.autofill.AutofillType PhoneNumberDevice;
+ enum_constant public static final androidx.ui.autofill.AutofillType PhoneNumberNational;
+ enum_constant public static final androidx.ui.autofill.AutofillType PostalAddress;
+ enum_constant public static final androidx.ui.autofill.AutofillType PostalCode;
+ enum_constant public static final androidx.ui.autofill.AutofillType PostalCodeExtended;
+ enum_constant public static final androidx.ui.autofill.AutofillType SmsOtpCode;
+ enum_constant public static final androidx.ui.autofill.AutofillType Username;
}
}
diff --git a/ui/ui-core/api/restricted_0.1.0-dev09.txt b/ui/ui-core/api/restricted_0.1.0-dev09.txt
index 8ff5c46..1702b22 100644
--- a/ui/ui-core/api/restricted_0.1.0-dev09.txt
+++ b/ui/ui-core/api/restricted_0.1.0-dev09.txt
@@ -29,8 +29,43 @@
}
public enum AutofillType {
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressAuxiliaryDetails;
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressCountry;
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressLocality;
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressRegion;
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressStreet;
+ enum_constant public static final androidx.ui.autofill.AutofillType BirthDateDay;
+ enum_constant public static final androidx.ui.autofill.AutofillType BirthDateFull;
+ enum_constant public static final androidx.ui.autofill.AutofillType BirthDateMonth;
+ enum_constant public static final androidx.ui.autofill.AutofillType BirthDateYear;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardExpirationDate;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardExpirationDay;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardExpirationMonth;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardExpirationYear;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardNumber;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardSecurityCode;
enum_constant public static final androidx.ui.autofill.AutofillType EmailAddress;
- enum_constant public static final androidx.ui.autofill.AutofillType Name;
+ enum_constant public static final androidx.ui.autofill.AutofillType Gender;
+ enum_constant @Deprecated public static final androidx.ui.autofill.AutofillType Name;
+ enum_constant public static final androidx.ui.autofill.AutofillType NewPassword;
+ enum_constant public static final androidx.ui.autofill.AutofillType NewUsername;
+ enum_constant public static final androidx.ui.autofill.AutofillType Password;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonFirstName;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonFullName;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonLastName;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonMiddleInitial;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonMiddleName;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonNamePrefix;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonNameSuffix;
+ enum_constant public static final androidx.ui.autofill.AutofillType PhoneCountryCode;
+ enum_constant public static final androidx.ui.autofill.AutofillType PhoneNumber;
+ enum_constant public static final androidx.ui.autofill.AutofillType PhoneNumberDevice;
+ enum_constant public static final androidx.ui.autofill.AutofillType PhoneNumberNational;
+ enum_constant public static final androidx.ui.autofill.AutofillType PostalAddress;
+ enum_constant public static final androidx.ui.autofill.AutofillType PostalCode;
+ enum_constant public static final androidx.ui.autofill.AutofillType PostalCodeExtended;
+ enum_constant public static final androidx.ui.autofill.AutofillType SmsOtpCode;
+ enum_constant public static final androidx.ui.autofill.AutofillType Username;
}
}
diff --git a/ui/ui-core/api/restricted_current.txt b/ui/ui-core/api/restricted_current.txt
index 8ff5c46..1702b22 100644
--- a/ui/ui-core/api/restricted_current.txt
+++ b/ui/ui-core/api/restricted_current.txt
@@ -29,8 +29,43 @@
}
public enum AutofillType {
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressAuxiliaryDetails;
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressCountry;
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressLocality;
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressRegion;
+ enum_constant public static final androidx.ui.autofill.AutofillType AddressStreet;
+ enum_constant public static final androidx.ui.autofill.AutofillType BirthDateDay;
+ enum_constant public static final androidx.ui.autofill.AutofillType BirthDateFull;
+ enum_constant public static final androidx.ui.autofill.AutofillType BirthDateMonth;
+ enum_constant public static final androidx.ui.autofill.AutofillType BirthDateYear;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardExpirationDate;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardExpirationDay;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardExpirationMonth;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardExpirationYear;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardNumber;
+ enum_constant public static final androidx.ui.autofill.AutofillType CreditCardSecurityCode;
enum_constant public static final androidx.ui.autofill.AutofillType EmailAddress;
- enum_constant public static final androidx.ui.autofill.AutofillType Name;
+ enum_constant public static final androidx.ui.autofill.AutofillType Gender;
+ enum_constant @Deprecated public static final androidx.ui.autofill.AutofillType Name;
+ enum_constant public static final androidx.ui.autofill.AutofillType NewPassword;
+ enum_constant public static final androidx.ui.autofill.AutofillType NewUsername;
+ enum_constant public static final androidx.ui.autofill.AutofillType Password;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonFirstName;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonFullName;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonLastName;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonMiddleInitial;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonMiddleName;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonNamePrefix;
+ enum_constant public static final androidx.ui.autofill.AutofillType PersonNameSuffix;
+ enum_constant public static final androidx.ui.autofill.AutofillType PhoneCountryCode;
+ enum_constant public static final androidx.ui.autofill.AutofillType PhoneNumber;
+ enum_constant public static final androidx.ui.autofill.AutofillType PhoneNumberDevice;
+ enum_constant public static final androidx.ui.autofill.AutofillType PhoneNumberNational;
+ enum_constant public static final androidx.ui.autofill.AutofillType PostalAddress;
+ enum_constant public static final androidx.ui.autofill.AutofillType PostalCode;
+ enum_constant public static final androidx.ui.autofill.AutofillType PostalCodeExtended;
+ enum_constant public static final androidx.ui.autofill.AutofillType SmsOtpCode;
+ enum_constant public static final androidx.ui.autofill.AutofillType Username;
}
}
diff --git a/ui/ui-core/src/main/java/androidx/ui/autofill/Autofill.kt b/ui/ui-core/src/main/java/androidx/ui/autofill/Autofill.kt
index 6e13b2c..c11fd61 100644
--- a/ui/ui-core/src/main/java/androidx/ui/autofill/Autofill.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/autofill/Autofill.kt
@@ -47,13 +47,6 @@
fun cancelAutofillForNode(autofillNode: AutofillNode)
}
-// TODO(b/138551812): Add more autofill types.
-/** Autofill type information. */
-enum class AutofillType {
- EmailAddress,
- Name
-}
-
/**
* Every autofillable composable will have an [AutofillNode]. (An autofill node will be created
* for every semantics node that adds autofill properties). This node is used to request/cancel
diff --git a/ui/ui-core/src/main/java/androidx/ui/autofill/AutofillType.kt b/ui/ui-core/src/main/java/androidx/ui/autofill/AutofillType.kt
new file mode 100644
index 0000000..47d8a21
--- /dev/null
+++ b/ui/ui-core/src/main/java/androidx/ui/autofill/AutofillType.kt
@@ -0,0 +1,236 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.ui.autofill
+
+/**
+ * Autofill type information.
+ *
+ * Autofill services use the [AutofillType] to determine what value to use to autofill fields
+ * associated with this type. If the [AutofillType] is not specified, the autofill services have
+ * to use heuristics to determine the right value to use while
+ * autofilling the corresponding field.
+ */
+enum class AutofillType {
+ /**
+ * Indicates that the associated component can be aufofilled with an email address.
+ */
+ EmailAddress,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a username.
+ */
+ Username,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a password.
+ */
+ Password,
+
+ /**
+ * Indicates that the associated component can be interpreted as a newly created username for
+ * save/update.
+ */
+ NewUsername,
+
+ /**
+ * Indicates that the associated component can be interpreted as a newly created password for
+ * save/update.
+ */
+ NewPassword,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a postal address.
+ */
+ PostalAddress,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a postal code.
+ */
+ PostalCode,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a credit card number.
+ */
+ CreditCardNumber,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a credit card security code.
+ */
+ CreditCardSecurityCode,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a credit card expiration date.
+ */
+ CreditCardExpirationDate,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a credit card expiration
+ * month.
+ */
+ CreditCardExpirationMonth,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a credit card expiration
+ * year.
+ */
+ CreditCardExpirationYear,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a credit card expiration day.
+ */
+ CreditCardExpirationDay,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a country name/code.
+ */
+ AddressCountry,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a region/state.
+ */
+ AddressRegion,
+
+ /**
+ * Indicates that the associated component can be aufofilled with an address locality
+ * (city/town).
+ */
+ AddressLocality,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a street address.
+ */
+ AddressStreet,
+
+ /**
+ * Indicates that the associated component can be aufofilled with auxiliary address details.
+ */
+ AddressAuxiliaryDetails,
+
+ /**
+ * Indicates that the associated component can be aufofilled with an extended ZIP/POSTAL code.
+ *
+ * Example: In forms that split the U.S. ZIP+4 Code with nine digits 99999-9999 into two
+ * fields annotate the delivery route code with this hint.
+ */
+ PostalCodeExtended,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a name.
+ *
+ * TODO(b/153400666): Remove this deprecated value.
+ */
+ @Deprecated(
+ "It was is too generic since it did not indicate which part of the name it represents. " +
+ "Replace with PersonFullName or PersonFirstName, PersonLastName etc.",
+ ReplaceWith("PersonFullName", "androidx.ui.autofill.AutofillType.PersonFullName"),
+ DeprecationLevel.ERROR
+ )
+ Name,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a person's full name.
+ *
+ */
+ PersonFullName,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a person's first/given name.
+ */
+ PersonFirstName,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a person's last/family name.
+ */
+ PersonLastName,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a person's middle name.
+ */
+ PersonMiddleName,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a person's middle initial.
+ */
+ PersonMiddleInitial,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a person's name prefix.
+ */
+ PersonNamePrefix,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a person's name suffix.
+ */
+ PersonNameSuffix,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a phone number with
+ * country code.
+ *
+ * Example: +1 123-456-7890
+ */
+ PhoneNumber,
+
+ /**
+ * Indicates that the associated component can be aufofilled with the current device's phone number
+ * usually for Sign Up / OTP flows.
+ */
+ PhoneNumberDevice,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a phone number's country code.
+ */
+ PhoneCountryCode,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a phone number without
+ * country code.
+ */
+ PhoneNumberNational,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a gender.
+ */
+ Gender,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a full birth date.
+ */
+ BirthDateFull,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a birth day(of the month).
+ */
+ BirthDateDay,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a birth day(of the month).
+ */
+ BirthDateMonth,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a birth year.
+ */
+ BirthDateYear,
+
+ /**
+ * Indicates that the associated component can be aufofilled with a SMS One Time Password (OTP).
+ *
+ * TODO(b/153386346): Support use-case where you specify the start and end index of the OTP.
+ */
+ SmsOtpCode,
+}
diff --git a/ui/ui-framework/integration-tests/framework-demos/src/main/java/androidx/ui/framework/demos/autofill/ExplicitAutofillTypesDemo.kt b/ui/ui-framework/integration-tests/framework-demos/src/main/java/androidx/ui/framework/demos/autofill/ExplicitAutofillTypesDemo.kt
index 741e76d..005ba54 100644
--- a/ui/ui-framework/integration-tests/framework-demos/src/main/java/androidx/ui/framework/demos/autofill/ExplicitAutofillTypesDemo.kt
+++ b/ui/ui-framework/integration-tests/framework-demos/src/main/java/androidx/ui/framework/demos/autofill/ExplicitAutofillTypesDemo.kt
@@ -50,10 +50,8 @@
Text("Name", style = labelStyle)
Autofill(
- autofillTypes = listOf(AutofillType.Name),
- nameState.value =
- TextFieldValue(it)
- }
+ autofillTypes = listOf(AutofillType.PersonFullName),
+ nameState.value = TextFieldValue(it) }
) { autofillNode ->
TextField(
value = nameState.value,
@@ -71,9 +69,7 @@
Text("Email", style = labelStyle)
Autofill(
autofillTypes = listOf(AutofillType.EmailAddress),
- emailState.value =
- TextFieldValue(it)
- }
+ emailState.value = TextFieldValue(it) }
) { autofillNode ->
TextField(
value = emailState.value,
diff --git a/ui/ui-platform/api/0.1.0-dev09.txt b/ui/ui-platform/api/0.1.0-dev09.txt
index 1b6df6c..604e580 100644
--- a/ui/ui-platform/api/0.1.0-dev09.txt
+++ b/ui/ui-platform/api/0.1.0-dev09.txt
@@ -7,6 +7,9 @@
public final class AndroidAutofillKt {
}
+ public final class AndroidAutofillTypeKt {
+ }
+
}
package androidx.ui.core {
diff --git a/ui/ui-platform/api/current.txt b/ui/ui-platform/api/current.txt
index 1b6df6c..604e580 100644
--- a/ui/ui-platform/api/current.txt
+++ b/ui/ui-platform/api/current.txt
@@ -7,6 +7,9 @@
public final class AndroidAutofillKt {
}
+ public final class AndroidAutofillTypeKt {
+ }
+
}
package androidx.ui.core {
diff --git a/ui/ui-platform/api/public_plus_experimental_0.1.0-dev09.txt b/ui/ui-platform/api/public_plus_experimental_0.1.0-dev09.txt
index e5b7331..ac7848b 100644
--- a/ui/ui-platform/api/public_plus_experimental_0.1.0-dev09.txt
+++ b/ui/ui-platform/api/public_plus_experimental_0.1.0-dev09.txt
@@ -7,6 +7,9 @@
public final class AndroidAutofillKt {
}
+ public final class AndroidAutofillTypeKt {
+ }
+
}
package androidx.ui.core {
diff --git a/ui/ui-platform/api/public_plus_experimental_current.txt b/ui/ui-platform/api/public_plus_experimental_current.txt
index e5b7331..ac7848b 100644
--- a/ui/ui-platform/api/public_plus_experimental_current.txt
+++ b/ui/ui-platform/api/public_plus_experimental_current.txt
@@ -7,6 +7,9 @@
public final class AndroidAutofillKt {
}
+ public final class AndroidAutofillTypeKt {
+ }
+
}
package androidx.ui.core {
diff --git a/ui/ui-platform/api/restricted_0.1.0-dev09.txt b/ui/ui-platform/api/restricted_0.1.0-dev09.txt
index 2fe9719..100f8e4 100644
--- a/ui/ui-platform/api/restricted_0.1.0-dev09.txt
+++ b/ui/ui-platform/api/restricted_0.1.0-dev09.txt
@@ -7,6 +7,9 @@
public final class AndroidAutofillKt {
}
+ public final class AndroidAutofillTypeKt {
+ }
+
}
package androidx.ui.core {
diff --git a/ui/ui-platform/api/restricted_current.txt b/ui/ui-platform/api/restricted_current.txt
index 2fe9719..100f8e4 100644
--- a/ui/ui-platform/api/restricted_current.txt
+++ b/ui/ui-platform/api/restricted_current.txt
@@ -7,6 +7,9 @@
public final class AndroidAutofillKt {
}
+ public final class AndroidAutofillTypeKt {
+ }
+
}
package androidx.ui.core {
diff --git a/ui/ui-platform/build.gradle b/ui/ui-platform/build.gradle
index fb24910..f4b2898 100644
--- a/ui/ui-platform/build.gradle
+++ b/ui/ui-platform/build.gradle
@@ -33,6 +33,7 @@
implementation(KOTLIN_COROUTINES_ANDROID)
implementation(KOTLIN_STDLIB)
+ implementation "androidx.autofill:autofill:1.0.0"
implementation "androidx.core:core:1.0.2"
implementation "androidx.lifecycle:lifecycle-runtime:2.3.0-alpha01"
diff --git a/ui/ui-platform/src/androidTest/java/androidx/ui/core/AndroidComposeViewTest.kt b/ui/ui-platform/src/androidTest/java/androidx/ui/core/AndroidComposeViewTest.kt
index 9d3171e..975fce8 100644
--- a/ui/ui-platform/src/androidTest/java/androidx/ui/core/AndroidComposeViewTest.kt
+++ b/ui/ui-platform/src/androidTest/java/androidx/ui/core/AndroidComposeViewTest.kt
@@ -22,6 +22,7 @@
import android.view.ViewGroup
import android.view.ViewStructure
import android.view.autofill.AutofillValue
+import androidx.autofill.HintConstants.AUTOFILL_HINT_PERSON_NAME
import androidx.test.filters.SdkSuppress
import androidx.test.filters.SmallTest
import androidx.ui.autofill.AndroidAutofill
@@ -84,7 +85,7 @@
val viewStructure: ViewStructure = FakeViewStructure()
val autofillNode = AutofillNode(
>
- autofillTypes = listOf(AutofillType.Name),
+ autofillTypes = listOf(AutofillType.PersonFullName),
boundingBox = Rect(0, 0, 0, 0)
)
autofillTree += autofillNode
@@ -98,7 +99,7 @@
virtualId = autofillNode.id
packageName = PACKAGE_NAME
setAutofillType(View.AUTOFILL_TYPE_TEXT)
- setAutofillHints(arrayOf(View.AUTOFILL_HINT_NAME))
+ setAutofillHints(arrayOf(AUTOFILL_HINT_PERSON_NAME))
setDimens(0, 0, 0, 0, 0, 0)
})
})
@@ -108,11 +109,11 @@
@Test
fun autofill_triggersOnFill() {
// Arrange.
- val expectedValue = "Name"
+ val expectedValue = "PersonName"
var autofilledValue = ""
val autofillNode = AutofillNode(
autofilledValue = it },
- autofillTypes = listOf(AutofillType.Name),
+ autofillTypes = listOf(AutofillType.PersonFullName),
boundingBox = Rect(0, 0, 0, 0)
)
val autofillValues = SparseArray<AutofillValue>().apply {
diff --git a/ui/ui-platform/src/main/java/androidx/ui/autofill/AndroidAutofill.kt b/ui/ui-platform/src/main/java/androidx/ui/autofill/AndroidAutofill.kt
index ab83357..b6b38a3 100644
--- a/ui/ui-platform/src/main/java/androidx/ui/autofill/AndroidAutofill.kt
+++ b/ui/ui-platform/src/main/java/androidx/ui/autofill/AndroidAutofill.kt
@@ -72,13 +72,7 @@
setAutofillId(root.autofillId!!, id)
setId(id, view.context.packageName, null, null)
setAutofillType(View.AUTOFILL_TYPE_TEXT)
- setAutofillHints(autofillNode.autofillTypes.map {
- when (it) {
- AutofillType.Name -> View.AUTOFILL_HINT_NAME
- AutofillType.EmailAddress -> View.AUTOFILL_HINT_EMAIL_ADDRESS
- else -> error("Unsupported autofill type")
- }
- }.toTypedArray())
+ setAutofillHints(autofillNode.autofillTypes.map { it.androidType }.toTypedArray())
if (autofillNode.boundingBox == null) {
// Do we need an exception here? warning? silently ignore? If the boundingbox is
diff --git a/ui/ui-platform/src/main/java/androidx/ui/autofill/AndroidAutofillType.kt b/ui/ui-platform/src/main/java/androidx/ui/autofill/AndroidAutofillType.kt
new file mode 100644
index 0000000..7822c10
--- /dev/null
+++ b/ui/ui-platform/src/main/java/androidx/ui/autofill/AndroidAutofillType.kt
@@ -0,0 +1,143 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.ui.autofill
+
+import androidx.autofill.HintConstants.AUTOFILL_HINT_BIRTH_DATE_DAY
+import androidx.autofill.HintConstants.AUTOFILL_HINT_BIRTH_DATE_FULL
+import androidx.autofill.HintConstants.AUTOFILL_HINT_BIRTH_DATE_MONTH
+import androidx.autofill.HintConstants.AUTOFILL_HINT_BIRTH_DATE_YEAR
+import androidx.autofill.HintConstants.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE
+import androidx.autofill.HintConstants.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY
+import androidx.autofill.HintConstants.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH
+import androidx.autofill.HintConstants.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR
+import androidx.autofill.HintConstants.AUTOFILL_HINT_CREDIT_CARD_NUMBER
+import androidx.autofill.HintConstants.AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE
+import androidx.autofill.HintConstants.AUTOFILL_HINT_EMAIL_ADDRESS
+import androidx.autofill.HintConstants.AUTOFILL_HINT_GENDER
+import androidx.autofill.HintConstants.AUTOFILL_HINT_NEW_PASSWORD
+import androidx.autofill.HintConstants.AUTOFILL_HINT_NEW_USERNAME
+import androidx.autofill.HintConstants.AUTOFILL_HINT_PASSWORD
+import androidx.autofill.HintConstants.AUTOFILL_HINT_PERSON_NAME
+import androidx.autofill.HintConstants.AUTOFILL_HINT_PERSON_NAME_FAMILY
+import androidx.autofill.HintConstants.AUTOFILL_HINT_PERSON_NAME_GIVEN
+import androidx.autofill.HintConstants.AUTOFILL_HINT_PERSON_NAME_MIDDLE
+import androidx.autofill.HintConstants.AUTOFILL_HINT_PERSON_NAME_MIDDLE_INITIAL
+import androidx.autofill.HintConstants.AUTOFILL_HINT_PERSON_NAME_PREFIX
+import androidx.autofill.HintConstants.AUTOFILL_HINT_PERSON_NAME_SUFFIX
+import androidx.autofill.HintConstants.AUTOFILL_HINT_PHONE_COUNTRY_CODE
+import androidx.autofill.HintConstants.AUTOFILL_HINT_PHONE_NATIONAL
+import androidx.autofill.HintConstants.AUTOFILL_HINT_PHONE_NUMBER
+import androidx.autofill.HintConstants.AUTOFILL_HINT_PHONE_NUMBER_DEVICE
+import androidx.autofill.HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS
+import androidx.autofill.HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_COUNTRY
+import androidx.autofill.HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_EXTENDED_ADDRESS
+import androidx.autofill.HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_EXTENDED_POSTAL_CODE
+import androidx.autofill.HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_LOCALITY
+import androidx.autofill.HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_REGION
+import androidx.autofill.HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_STREET_ADDRESS
+import androidx.autofill.HintConstants.AUTOFILL_HINT_POSTAL_CODE
+import androidx.autofill.HintConstants.AUTOFILL_HINT_SMS_OTP
+import androidx.autofill.HintConstants.AUTOFILL_HINT_USERNAME
+import androidx.ui.autofill.AutofillType.EmailAddress
+import androidx.ui.autofill.AutofillType.PersonFullName
+import androidx.ui.autofill.AutofillType.Username
+import androidx.ui.autofill.AutofillType.Password
+import androidx.ui.autofill.AutofillType.NewUsername
+import androidx.ui.autofill.AutofillType.NewPassword
+import androidx.ui.autofill.AutofillType.PostalAddress
+import androidx.ui.autofill.AutofillType.PostalCode
+import androidx.ui.autofill.AutofillType.CreditCardNumber
+import androidx.ui.autofill.AutofillType.CreditCardSecurityCode
+import androidx.ui.autofill.AutofillType.CreditCardExpirationDate
+import androidx.ui.autofill.AutofillType.CreditCardExpirationMonth
+import androidx.ui.autofill.AutofillType.CreditCardExpirationYear
+import androidx.ui.autofill.AutofillType.CreditCardExpirationDay
+import androidx.ui.autofill.AutofillType.AddressCountry
+import androidx.ui.autofill.AutofillType.AddressRegion
+import androidx.ui.autofill.AutofillType.AddressLocality
+import androidx.ui.autofill.AutofillType.AddressStreet
+import androidx.ui.autofill.AutofillType.AddressAuxiliaryDetails
+import androidx.ui.autofill.AutofillType.PostalCodeExtended
+import androidx.ui.autofill.AutofillType.PersonFirstName
+import androidx.ui.autofill.AutofillType.PersonLastName
+import androidx.ui.autofill.AutofillType.PersonMiddleName
+import androidx.ui.autofill.AutofillType.PersonMiddleInitial
+import androidx.ui.autofill.AutofillType.PersonNamePrefix
+import androidx.ui.autofill.AutofillType.PersonNameSuffix
+import androidx.ui.autofill.AutofillType.PhoneNumber
+import androidx.ui.autofill.AutofillType.PhoneNumberDevice
+import androidx.ui.autofill.AutofillType.PhoneCountryCode
+import androidx.ui.autofill.AutofillType.PhoneNumberNational
+import androidx.ui.autofill.AutofillType.Gender
+import androidx.ui.autofill.AutofillType.BirthDateFull
+import androidx.ui.autofill.AutofillType.BirthDateDay
+import androidx.ui.autofill.AutofillType.BirthDateMonth
+import androidx.ui.autofill.AutofillType.BirthDateYear
+import androidx.ui.autofill.AutofillType.SmsOtpCode
+
+/**
+ * Gets the Android specific [AutofillHint][android.view.ViewStructure.setAutofillHints]
+ * corresponding to the current [AutofillType].
+ */
+internal val AutofillType.androidType: String
+ get() {
+ val androidAutofillType = androidAutofillTypes[this]
+ requireNotNull(androidAutofillType, { "Unsupported autofill type" })
+ return androidAutofillType
+ }
+
+/**
+ * Maps each [AutofillType] to one of the autofill hints in [androidx.autofill.HintConstants]
+ */
+private val androidAutofillTypes: HashMap<AutofillType, String> = hashMapOf(
+ EmailAddress to AUTOFILL_HINT_EMAIL_ADDRESS,
+ Username to AUTOFILL_HINT_USERNAME,
+ Password to AUTOFILL_HINT_PASSWORD,
+ NewUsername to AUTOFILL_HINT_NEW_USERNAME,
+ NewPassword to AUTOFILL_HINT_NEW_PASSWORD,
+ PostalAddress to AUTOFILL_HINT_POSTAL_ADDRESS,
+ PostalCode to AUTOFILL_HINT_POSTAL_CODE,
+ CreditCardNumber to AUTOFILL_HINT_CREDIT_CARD_NUMBER,
+ CreditCardSecurityCode to AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE,
+ CreditCardExpirationDate to AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE,
+ CreditCardExpirationMonth to AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH,
+ CreditCardExpirationYear to AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR,
+ CreditCardExpirationDay to AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY,
+ AddressCountry to AUTOFILL_HINT_POSTAL_ADDRESS_COUNTRY,
+ AddressRegion to AUTOFILL_HINT_POSTAL_ADDRESS_REGION,
+ AddressLocality to AUTOFILL_HINT_POSTAL_ADDRESS_LOCALITY,
+ AddressStreet to AUTOFILL_HINT_POSTAL_ADDRESS_STREET_ADDRESS,
+ AddressAuxiliaryDetails to AUTOFILL_HINT_POSTAL_ADDRESS_EXTENDED_ADDRESS,
+ PostalCodeExtended to AUTOFILL_HINT_POSTAL_ADDRESS_EXTENDED_POSTAL_CODE,
+ PersonFullName to AUTOFILL_HINT_PERSON_NAME,
+ PersonFirstName to AUTOFILL_HINT_PERSON_NAME_GIVEN,
+ PersonLastName to AUTOFILL_HINT_PERSON_NAME_FAMILY,
+ PersonMiddleName to AUTOFILL_HINT_PERSON_NAME_MIDDLE,
+ PersonMiddleInitial to AUTOFILL_HINT_PERSON_NAME_MIDDLE_INITIAL,
+ PersonNamePrefix to AUTOFILL_HINT_PERSON_NAME_PREFIX,
+ PersonNameSuffix to AUTOFILL_HINT_PERSON_NAME_SUFFIX,
+ PhoneNumber to AUTOFILL_HINT_PHONE_NUMBER,
+ PhoneNumberDevice to AUTOFILL_HINT_PHONE_NUMBER_DEVICE,
+ PhoneCountryCode to AUTOFILL_HINT_PHONE_COUNTRY_CODE,
+ PhoneNumberNational to AUTOFILL_HINT_PHONE_NATIONAL,
+ Gender to AUTOFILL_HINT_GENDER,
+ BirthDateFull to AUTOFILL_HINT_BIRTH_DATE_FULL,
+ BirthDateDay to AUTOFILL_HINT_BIRTH_DATE_DAY,
+ BirthDateMonth to AUTOFILL_HINT_BIRTH_DATE_MONTH,
+ BirthDateYear to AUTOFILL_HINT_BIRTH_DATE_YEAR,
+ SmsOtpCode to AUTOFILL_HINT_SMS_OTP
+)
diff --git a/ui/ui-platform/src/test/java/androidx/ui/autofill/AndroidAutofillTypeTest.kt b/ui/ui-platform/src/test/java/androidx/ui/autofill/AndroidAutofillTypeTest.kt
new file mode 100644
index 0000000..0456174
--- /dev/null
+++ b/ui/ui-platform/src/test/java/androidx/ui/autofill/AndroidAutofillTypeTest.kt
@@ -0,0 +1,244 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.ui.autofill
+
+import androidx.test.filters.SmallTest
+import androidx.ui.autofill.AutofillType.EmailAddress
+import androidx.ui.autofill.AutofillType.PersonFullName
+import androidx.ui.autofill.AutofillType.Username
+import androidx.ui.autofill.AutofillType.Password
+import androidx.ui.autofill.AutofillType.NewUsername
+import androidx.ui.autofill.AutofillType.NewPassword
+import androidx.ui.autofill.AutofillType.PostalAddress
+import androidx.ui.autofill.AutofillType.PostalCode
+import androidx.ui.autofill.AutofillType.CreditCardNumber
+import androidx.ui.autofill.AutofillType.CreditCardSecurityCode
+import androidx.ui.autofill.AutofillType.CreditCardExpirationDate
+import androidx.ui.autofill.AutofillType.CreditCardExpirationMonth
+import androidx.ui.autofill.AutofillType.CreditCardExpirationYear
+import androidx.ui.autofill.AutofillType.CreditCardExpirationDay
+import androidx.ui.autofill.AutofillType.AddressCountry
+import androidx.ui.autofill.AutofillType.AddressRegion
+import androidx.ui.autofill.AutofillType.AddressLocality
+import androidx.ui.autofill.AutofillType.AddressStreet
+import androidx.ui.autofill.AutofillType.AddressAuxiliaryDetails
+import androidx.ui.autofill.AutofillType.PostalCodeExtended
+import androidx.ui.autofill.AutofillType.PersonFirstName
+import androidx.ui.autofill.AutofillType.PersonLastName
+import androidx.ui.autofill.AutofillType.PersonMiddleName
+import androidx.ui.autofill.AutofillType.PersonMiddleInitial
+import androidx.ui.autofill.AutofillType.PersonNamePrefix
+import androidx.ui.autofill.AutofillType.PersonNameSuffix
+import androidx.ui.autofill.AutofillType.PhoneNumber
+import androidx.ui.autofill.AutofillType.PhoneNumberDevice
+import androidx.ui.autofill.AutofillType.PhoneCountryCode
+import androidx.ui.autofill.AutofillType.PhoneNumberNational
+import androidx.ui.autofill.AutofillType.Gender
+import androidx.ui.autofill.AutofillType.BirthDateFull
+import androidx.ui.autofill.AutofillType.BirthDateDay
+import androidx.ui.autofill.AutofillType.BirthDateMonth
+import androidx.ui.autofill.AutofillType.BirthDateYear
+import androidx.ui.autofill.AutofillType.SmsOtpCode
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+@SmallTest
+@RunWith(JUnit4::class)
+class AndroidAutofillTypeTest {
+
+ @Test
+ fun emailAddress() {
+ assertThat(EmailAddress.androidType).isEqualTo("emailAddress")
+ }
+
+ @Test
+ fun username() {
+ assertThat(Username.androidType).isEqualTo("username")
+ }
+
+ @Test
+ fun password() {
+ assertThat(Password.androidType).isEqualTo("password")
+ }
+
+ @Test
+ fun newUsername() {
+ assertThat(NewUsername.androidType).isEqualTo("newUsername")
+ }
+
+ @Test
+ fun newPassword() {
+ assertThat(NewPassword.androidType).isEqualTo("newPassword")
+ }
+
+ @Test
+ fun postalAddress() {
+ assertThat(PostalAddress.androidType).isEqualTo("postalAddress")
+ }
+
+ @Test
+ fun postalCode() {
+ assertThat(PostalCode.androidType).isEqualTo("postalCode")
+ }
+
+ @Test
+ fun creditCardNumber() {
+ assertThat(CreditCardNumber.androidType).isEqualTo("creditCardNumber")
+ }
+
+ @Test
+ fun creditCardSecurityCode() {
+ assertThat(CreditCardSecurityCode.androidType).isEqualTo("creditCardSecurityCode")
+ }
+
+ @Test
+ fun creditCardExpirationDate() {
+ assertThat(CreditCardExpirationDate.androidType).isEqualTo("creditCardExpirationDate")
+ }
+
+ @Test
+ fun creditCardExpirationMonth() {
+ assertThat(CreditCardExpirationMonth.androidType).isEqualTo("creditCardExpirationMonth")
+ }
+
+ @Test
+ fun creditCardExpirationYear() {
+ assertThat(CreditCardExpirationYear.androidType).isEqualTo("creditCardExpirationYear")
+ }
+
+ @Test
+ fun creditCardExpirationDay() {
+ assertThat(CreditCardExpirationDay.androidType).isEqualTo("creditCardExpirationDay")
+ }
+
+ @Test
+ fun addressCountry() {
+ assertThat(AddressCountry.androidType).isEqualTo("addressCountry")
+ }
+
+ @Test
+ fun addressRegion() {
+ assertThat(AddressRegion.androidType).isEqualTo("addressRegion")
+ }
+
+ @Test
+ fun addressLocality() {
+ assertThat(AddressLocality.androidType).isEqualTo("addressLocality")
+ }
+
+ @Test
+ fun addressStreet() {
+ assertThat(AddressStreet.androidType).isEqualTo("streetAddress")
+ }
+
+ @Test
+ fun addressAuxiliaryDetails() {
+ assertThat(AddressAuxiliaryDetails.androidType).isEqualTo("extendedAddress")
+ }
+
+ @Test
+ fun postalCodeExtended() {
+ assertThat(PostalCodeExtended.androidType).isEqualTo("extendedPostalCode")
+ }
+
+ @Test
+ fun personFullName() {
+ assertThat(PersonFullName.androidType).isEqualTo("personName")
+ }
+
+ @Test
+ fun personFirstName() {
+ assertThat(PersonFirstName.androidType).isEqualTo("personGivenName")
+ }
+
+ @Test
+ fun personLastName() {
+ assertThat(PersonLastName.androidType).isEqualTo("personFamilyName")
+ }
+
+ @Test
+ fun personMiddleName() {
+ assertThat(PersonMiddleName.androidType).isEqualTo("personMiddleName")
+ }
+
+ @Test
+ fun personMiddleInitial() {
+ assertThat(PersonMiddleInitial.androidType).isEqualTo("personMiddleInitial")
+ }
+
+ @Test
+ fun personNamePrefix() {
+ assertThat(PersonNamePrefix.androidType).isEqualTo("personNamePrefix")
+ }
+
+ @Test
+ fun personNameSuffix() {
+ assertThat(PersonNameSuffix.androidType).isEqualTo("personNameSuffix")
+ }
+
+ @Test
+ fun phoneNumber() {
+ assertThat(PhoneNumber.androidType).isEqualTo("phoneNumber")
+ }
+
+ @Test
+ fun phoneNumberDevice() {
+ assertThat(PhoneNumberDevice.androidType).isEqualTo("phoneNumberDevice")
+ }
+
+ @Test
+ fun phoneCountryCode() {
+ assertThat(PhoneCountryCode.androidType).isEqualTo("phoneCountryCode")
+ }
+
+ @Test
+ fun phoneNumberNational() {
+ assertThat(PhoneNumberNational.androidType).isEqualTo("phoneNational")
+ }
+
+ @Test
+ fun gender() {
+ assertThat(Gender.androidType).isEqualTo("gender")
+ }
+
+ @Test
+ fun birthDateFull() {
+ assertThat(BirthDateFull.androidType).isEqualTo("birthDateFull")
+ }
+
+ @Test
+ fun birthDateDay() {
+ assertThat(BirthDateDay.androidType).isEqualTo("birthDateDay")
+ }
+
+ @Test
+ fun birthDateMonth() {
+ assertThat(BirthDateMonth.androidType).isEqualTo("birthDateMonth")
+ }
+
+ @Test
+ fun birthDateYear() {
+ assertThat(BirthDateYear.androidType).isEqualTo("birthDateYear")
+ }
+
+ @Test
+ fun smsOTPCode() {
+ assertThat(SmsOtpCode.androidType).isEqualTo("smsOTPCode")
+ }
+}
diff --git a/ui/ui-platform/src/test/java/androidx/ui/autofill/AndroidPerformAutofillTest.kt b/ui/ui-platform/src/test/java/androidx/ui/autofill/AndroidPerformAutofillTest.kt
index 582d792..fc595ce 100644
--- a/ui/ui-platform/src/test/java/androidx/ui/autofill/AndroidPerformAutofillTest.kt
+++ b/ui/ui-platform/src/test/java/androidx/ui/autofill/AndroidPerformAutofillTest.kt
@@ -52,11 +52,11 @@
@Test
fun performAutofill_name() {
// Arrange.
- val expectedValue = "First Name"
+ val expectedValue = "Name"
var autofilledValue = ""
val autofillNode = AutofillNode(
autofilledValue = it },
- autofillTypes = listOf(AutofillType.Name),
+ autofillTypes = listOf(AutofillType.PersonFullName),
boundingBox = Rect(0, 0, 0, 0)
)
autofillTree += autofillNode
diff --git a/ui/ui-platform/src/test/java/androidx/ui/autofill/AndroidPopulateViewStructureTest.kt b/ui/ui-platform/src/test/java/androidx/ui/autofill/AndroidPopulateViewStructureTest.kt
index 41efdf0..0e32f1e 100644
--- a/ui/ui-platform/src/test/java/androidx/ui/autofill/AndroidPopulateViewStructureTest.kt
+++ b/ui/ui-platform/src/test/java/androidx/ui/autofill/AndroidPopulateViewStructureTest.kt
@@ -20,6 +20,7 @@
import android.graphics.Rect
import android.view.View
import android.view.ViewStructure
+import androidx.autofill.HintConstants.AUTOFILL_HINT_PERSON_NAME
import androidx.test.filters.SmallTest
import androidx.ui.ComposeUiRobolectricTestRunner
import androidx.ui.test.android.fake.FakeViewStructure
@@ -67,7 +68,7 @@
// Arrange.
val autofillNode = AutofillNode(
>
- autofillTypes = listOf(AutofillType.Name),
+ autofillTypes = listOf(AutofillType.PersonFullName),
boundingBox = Rect(0, 0, 0, 0)
)
autofillTree += autofillNode
@@ -82,7 +83,7 @@
virtualId = autofillNode.id
packageName = PACKAGE_NAME
setAutofillType(View.AUTOFILL_TYPE_TEXT)
- setAutofillHints(arrayOf(View.AUTOFILL_HINT_NAME))
+ setAutofillHints(arrayOf(AUTOFILL_HINT_PERSON_NAME))
setDimens(0, 0, 0, 0, 0, 0)
})
})
@@ -93,7 +94,7 @@
// Arrange.
val nameAutofillNode = AutofillNode(
>
- autofillTypes = listOf(AutofillType.Name),
+ autofillTypes = listOf(AutofillType.PersonFullName),
boundingBox = Rect(0, 0, 0, 0)
)
autofillTree += nameAutofillNode
@@ -115,7 +116,7 @@
virtualId = nameAutofillNode.id
packageName = PACKAGE_NAME
setAutofillType(View.AUTOFILL_TYPE_TEXT)
- setAutofillHints(arrayOf(View.AUTOFILL_HINT_NAME))
+ setAutofillHints(arrayOf(AUTOFILL_HINT_PERSON_NAME))
setDimens(0, 0, 0, 0, 0, 0)
})
children.add(FakeViewStructure().apply {