Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 25.2k
Migrate to androidx.autofill.HintConstants & Support all constant types#28008
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
f6d88d51f586a535df4a07c4d0ea1d1bdc759c15f363256410cc699ffd180a2eb654ea2cde01f22b27b391dcd0eb74bd5ae978774537eafdb9c63edf7d4fe247333f83de79a34b3073a2cdcff32a53dc9b9adfac255710892e273afef6523dac3f86a4e4c4fb42ad103abe6afee7058961dabcdb56bffcFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -30,6 +30,7 @@ | ||
| import android.widget.EditText; | ||
| import android.widget.TextView; | ||
| import androidx.annotation.Nullable; | ||
| import androidx.autofill.HintConstants; | ||
| import androidx.core.content.ContextCompat; | ||
| import com.facebook.common.logging.FLog; | ||
| import com.facebook.infer.annotation.Assertions; | ||
| @@ -72,6 +73,7 @@ | ||
| import com.facebook.react.views.text.TextTransform; | ||
| import com.facebook.yoga.YogaConstants; | ||
| import java.lang.reflect.Field; | ||
| import java.util.HashMap; | ||
| import java.util.LinkedList; | ||
| import java.util.Map; | ||
| @@ -84,6 +86,51 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout | ||
| private static final int[] SPACING_TYPES = { | ||
| Spacing.ALL, Spacing.LEFT, Spacing.RIGHT, Spacing.TOP, Spacing.BOTTOM, | ||
safaiyeh marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. safaiyeh marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| }; | ||
| private static final Map<String, String> REACT_PROPS_AUTOFILL_HINTS_MAP = | ||
| new HashMap<String, String>() { | ||
| { | ||
| put("birthdate-day", HintConstants.AUTOFILL_HINT_BIRTH_DATE_DAY); | ||
| put("birthdate-full", HintConstants.AUTOFILL_HINT_BIRTH_DATE_FULL); | ||
| put("birthdate-month", HintConstants.AUTOFILL_HINT_BIRTH_DATE_MONTH); | ||
| put("birthdate-year", HintConstants.AUTOFILL_HINT_BIRTH_DATE_YEAR); | ||
| put("cc-csc", HintConstants.AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE); | ||
| put("cc-exp", HintConstants.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE); | ||
| put("cc-exp-day", HintConstants.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY); | ||
| put("cc-exp-month", HintConstants.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH); | ||
| put("cc-exp-year", HintConstants.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR); | ||
| put("cc-number", HintConstants.AUTOFILL_HINT_CREDIT_CARD_NUMBER); | ||
| put("email", HintConstants.AUTOFILL_HINT_EMAIL_ADDRESS); | ||
| put("gender", HintConstants.AUTOFILL_HINT_GENDER); | ||
| put("name", HintConstants.AUTOFILL_HINT_PERSON_NAME); | ||
| put("name-family", HintConstants.AUTOFILL_HINT_PERSON_NAME_FAMILY); | ||
| put("name-given", HintConstants.AUTOFILL_HINT_PERSON_NAME_GIVEN); | ||
| put("name-middle", HintConstants.AUTOFILL_HINT_PERSON_NAME_MIDDLE); | ||
| put("name-middle-initial", HintConstants.AUTOFILL_HINT_PERSON_NAME_MIDDLE_INITIAL); | ||
| put("name-prefix", HintConstants.AUTOFILL_HINT_PERSON_NAME_PREFIX); | ||
| put("name-suffix", HintConstants.AUTOFILL_HINT_PERSON_NAME_SUFFIX); | ||
| put("password", HintConstants.AUTOFILL_HINT_PASSWORD); | ||
| put("password-new", HintConstants.AUTOFILL_HINT_NEW_PASSWORD); | ||
| put("postal-address", HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS); | ||
safaiyeh marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| put("postal-address-country", HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_COUNTRY); | ||
| put( | ||
| "postal-address-extended", | ||
| HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_EXTENDED_ADDRESS); | ||
| put( | ||
| "postal-address-extended-postal-code", | ||
| HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_EXTENDED_POSTAL_CODE); | ||
| put("postal-address-locality", HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_LOCALITY); | ||
| put("postal-address-region", HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_REGION); | ||
| put("postal-code", HintConstants.AUTOFILL_HINT_POSTAL_CODE); | ||
| put("street-address", HintConstants.AUTOFILL_HINT_POSTAL_ADDRESS_STREET_ADDRESS); | ||
| put("sms-otp", HintConstants.AUTOFILL_HINT_SMS_OTP); | ||
| put("tel", HintConstants.AUTOFILL_HINT_PHONE_NUMBER); | ||
| put("tel-country-code", HintConstants.AUTOFILL_HINT_PHONE_COUNTRY_CODE); | ||
| put("tel-national", HintConstants.AUTOFILL_HINT_PHONE_NATIONAL); | ||
| put("tel-device", HintConstants.AUTOFILL_HINT_PHONE_NUMBER_DEVICE); | ||
| put("username", HintConstants.AUTOFILL_HINT_USERNAME); | ||
| put("username-new", HintConstants.AUTOFILL_HINT_NEW_USERNAME); | ||
| } | ||
| }; | ||
| private static final int FOCUS_TEXT_INPUT = 1; | ||
| private static final int BLUR_TEXT_INPUT = 2; | ||
| @@ -659,32 +706,10 @@ public void setMaxLength(ReactEditText view, @Nullable Integer maxLength) { | ||
| public void setTextContentType(ReactEditText view, @Nullable String autoCompleteType) { | ||
| if (autoCompleteType == null) { | ||
| setImportantForAutofill(view, View.IMPORTANT_FOR_AUTOFILL_NO); | ||
| } else if ("username".equals(autoCompleteType)) { | ||
| setAutofillHints(view, View.AUTOFILL_HINT_USERNAME); | ||
| } else if ("password".equals(autoCompleteType)) { | ||
| setAutofillHints(view, View.AUTOFILL_HINT_PASSWORD); | ||
| } else if ("email".equals(autoCompleteType)) { | ||
| setAutofillHints(view, View.AUTOFILL_HINT_EMAIL_ADDRESS); | ||
| } else if ("name".equals(autoCompleteType)) { | ||
| setAutofillHints(view, View.AUTOFILL_HINT_NAME); | ||
| } else if ("tel".equals(autoCompleteType)) { | ||
| setAutofillHints(view, View.AUTOFILL_HINT_PHONE); | ||
| } else if ("street-address".equals(autoCompleteType)) { | ||
| setAutofillHints(view, View.AUTOFILL_HINT_POSTAL_ADDRESS); | ||
| } else if ("postal-code".equals(autoCompleteType)) { | ||
| setAutofillHints(view, View.AUTOFILL_HINT_POSTAL_CODE); | ||
| } else if ("cc-number".equals(autoCompleteType)) { | ||
| setAutofillHints(view, View.AUTOFILL_HINT_CREDIT_CARD_NUMBER); | ||
| } else if ("cc-csc".equals(autoCompleteType)) { | ||
| setAutofillHints(view, View.AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE); | ||
| } else if ("cc-exp".equals(autoCompleteType)) { | ||
| setAutofillHints(view, View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE); | ||
| } else if ("cc-exp-month".equals(autoCompleteType)) { | ||
| setAutofillHints(view, View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH); | ||
| } else if ("cc-exp-year".equals(autoCompleteType)) { | ||
| setAutofillHints(view, View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR); | ||
| } else if ("off".equals(autoCompleteType)) { | ||
| setImportantForAutofill(view, View.IMPORTANT_FOR_AUTOFILL_NO); | ||
| } else if (REACT_PROPS_AUTOFILL_HINTS_MAP.containsKey(autoCompleteType)) { | ||
| setAutofillHints(view, REACT_PROPS_AUTOFILL_HINTS_MAP.get(autoCompleteType)); | ||
| } else { | ||
| throw new JSApplicationIllegalArgumentException( | ||
| "Invalid autoCompleteType: " + autoCompleteType); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -32,6 +32,15 @@ fb_native.android_library( | ||
| ], | ||
| ) | ||
| fb_native.android_library( | ||
| name = "autofill", | ||
| visibility = ["PUBLIC"], | ||
| exported_deps = [ | ||
safaiyeh marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ":autofill-binary", | ||
| ":core", | ||
| ], | ||
| ) | ||
| fb_native.android_library( | ||
| name = "collection", | ||
| visibility = ["PUBLIC"], | ||
| @@ -342,6 +351,11 @@ fb_native.android_prebuilt_aar( | ||
| aar = ":asynclayoutinflater-binary-aar", | ||
| ) | ||
| fb_native.android_prebuilt_aar( | ||
| name = "autofill-binary", | ||
| aar = ":autofill-binary-aar", | ||
| ) | ||
| fb_native.prebuilt_jar( | ||
| name = "collection-binary", | ||
| binary_jar = ":collection-binary.jar", | ||
| @@ -501,6 +515,12 @@ fb_native.remote_file( | ||
| url = "mvn:androidx.asynclayoutinflater:asynclayoutinflater:aar:1.0.0", | ||
| ) | ||
| fb_native.remote_file( | ||
| name = "autofill-binary-aar", | ||
| sha1 = "d9cdaa22b9c373ba75a35dcc33ee8871543164e5", | ||
| url = "mvn:androidx.autofill:autofill:aar:1.1.0", | ||
| ) | ||
| fb_native.remote_file( | ||
| name = "collection-binary.jar", | ||
| sha1 = "42858b26cafdaa69b6149f45dfc2894007bc2c7a", | ||
Uh oh!
There was an error while loading. Please reload this page.