Skip to content
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

Migrate to androidx.autofill.HintConstants & Support all constant types #28008

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f6d88d5
Migrate view autofill contants to androidx.autofill.HintConstants
safaiyeh Feb 9, 2020
1f586a5
Remove generated gradle files
safaiyeh Feb 9, 2020
35df4a0
BUCK dep
safaiyeh Feb 16, 2020
7c4d0ea
Merge branch 'master' into autofillhintnewpassword
safaiyeh Feb 26, 2020
1d1bdc7
Birthdate HintConstants
safaiyeh Feb 26, 2020
59c15f3
Credit Card HintConstants
safaiyeh Feb 26, 2020
6325641
Gender
safaiyeh Feb 26, 2020
0cc699f
Username new
safaiyeh Feb 26, 2020
fd180a2
Name HintConstants
safaiyeh Feb 26, 2020
eb654ea
Phone Number Hint Contants
safaiyeh Feb 26, 2020
2cde01f
Postal Address HintConstants
safaiyeh Feb 26, 2020
22b27b3
SMS OTP
safaiyeh Feb 26, 2020
91dcd0e
Merge remote-tracking branch 'origin/master' into autofillhintnewpass…
rozPierog Aug 28, 2020
b74bd5a
Merge remote-tracking branch 'upstream/master' into autofillhintnewpa…
rozPierog Aug 28, 2020
e978774
fixed typo in constant of autofill property
rozPierog Aug 28, 2020
537eafd
fix buck export of autofill
rozPierog Aug 28, 2020
b9c63ed
Merge branch 'master' into autofillhintnewpassword
Aug 28, 2020
f7d4fe2
Keep street-address
safaiyeh Aug 28, 2020
47333f8
Update BUCK
safaiyeh Aug 28, 2020
3de79a3
Merge branch 'facebook:main' into autofillhintnewpassword
safaiyeh Jul 16, 2021
4b3073a
Update BUCK dep
safaiyeh Jul 16, 2021
2cdcff3
Update BUCK files
safaiyeh Jul 16, 2021
2a53dc9
Add new autofill types
safaiyeh Jul 16, 2021
b9adfac
Convert if statements to a map and remove not yet released constants
safaiyeh Jul 18, 2021
2557108
Fix typo
safaiyeh Jul 18, 2021
92e273a
Revert gradle change
safaiyeh Jul 18, 2021
fef6523
Revert gradle change
safaiyeh Jul 18, 2021
dac3f86
Merge branch 'facebook:main' into autofillhintnewpassword
safaiyeh Jul 18, 2021
a4e4c4f
fix java style
safaiyeh Jul 18, 2021
b42ad10
Merge branch 'autofillhintnewpassword' of https://github.com/safaiyeh…
safaiyeh Jul 18, 2021
3abe6af
fix java style
safaiyeh Jul 18, 2021
ee70589
fix java style
safaiyeh Jul 18, 2021
61dabcd
fix java style
safaiyeh Jul 18, 2021
b56bffc
fix java style
safaiyeh Jul 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Libraries/Components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,18 +332,42 @@ type AndroidProps = $ReadOnly<{|
* @platform android
*/
autoCompleteType?: ?(
| 'birthdate-day'
| 'birthdate-full'
| 'birthdate-month'
| 'birthdate-year'
| 'cc-csc'
| 'cc-exp'
| 'cc-exp-day'
| 'cc-exp-month'
| 'cc-exp-year'
| 'cc-number'
| 'email'
| 'gender'
| 'name'
| 'name-family'
| 'name-given'
| 'name-middle'
| 'name-middle-initial'
| 'name-prefix'
| 'name-suffix'
| 'password'
| 'password-new'
| 'postal-address'
| 'postal-address-country'
| 'postal-address-extended'
| 'postal-address-extended-postal-code'
| 'postal-address-locality'
| 'postal-address-region'
| 'postal-code'
| 'street-address'
| 'sms-otp'
| 'tel'
| 'tel-country-code'
| 'tel-national'
| 'tel-device'
| 'username'
| 'username-new'
| 'off'
),

Expand Down
1 change: 1 addition & 0 deletions ReactAndroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ dependencies {
api("com.facebook.yoga:proguard-annotations:1.19.0")
api("javax.inject:javax.inject:1")
api("androidx.appcompat:appcompat:1.0.2")
api("androidx.autofill:autofill:1.1.0")
api("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
api("com.facebook.fresco:fresco:${FRESCO_VERSION}")
api("com.facebook.fresco:imagepipeline-okhttp3:${FRESCO_VERSION}")
Expand Down
1 change: 1 addition & 0 deletions ReactAndroid/src/main/java/com/facebook/react/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ rn_android_library(
react_native_dep("third-party/android/androidx:fragment"),
react_native_dep("third-party/android/androidx:legacy-support-core-ui"),
react_native_dep("third-party/android/androidx:legacy-support-core-utils"),
react_native_dep("third-party/android/androidx:autofill"),
],
visibility = [
"PUBLIC",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ rn_android_library(
react_native_dep("libraries/fbcore/src/main/java/com/facebook/common/logging:logging"),
react_native_dep("third-party/java/infer-annotations:infer-annotations"),
react_native_dep("third-party/java/jsr-305:jsr-305"),
react_native_dep("third-party/android/androidx:autofill"),
react_native_target("java/com/facebook/react/bridge:bridge"),
react_native_target("java/com/facebook/react/common:common"),
react_native_target("java/com/facebook/react/module/annotations:annotations"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -84,6 +86,47 @@ 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.
Show resolved Hide resolved
safaiyeh marked this conversation as resolved.
Show resolved Hide resolved
safaiyeh marked this conversation as resolved.
Show resolved Hide resolved
};
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);
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;
Expand Down Expand Up @@ -659,32 +702,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);
Expand Down
20 changes: 20 additions & 0 deletions ReactAndroid/src/main/third-party/android/androidx/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ fb_native.android_library(
],
)

fb_native.android_library(
name = "autofill",
visibility = ["PUBLIC"],
exported_deps = [
safaiyeh marked this conversation as resolved.
Show resolved Hide resolved
":autofill-binary",
":core",
],
)

fb_native.android_library(
name = "collection",
visibility = ["PUBLIC"],
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down