Skip to content

Commit d4aa1e7

Browse files
hramosfacebook-github-bot
authored andcommitted
Do not use autofill methods on Android APIs older than Oreo (26)
Summary: Autofill Hints were added in [Android API 26](https://developer.android.com/reference/android/view/View.html#setAutofillHints(java.lang.String...)). Without this runtime check, pre-26 devices will crash. [Android][Fixed] - Fixes crash on pre-26 Android devices when setting text content type Reviewed By: lunaleaps Differential Revision: D14479468 fbshipit-source-id: 238c1efd6aea682a93ecb45e1123aaed6bdcd9e3
1 parent 7d84d0d commit d4aa1e7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
7171
private static final int FOCUS_TEXT_INPUT = 1;
7272
private static final int BLUR_TEXT_INPUT = 2;
7373

74-
private static final int INPUT_TYPE_KEYBOARD_NUMBER_PAD = InputType.TYPE_CLASS_NUMBER;
74+
private static final int INPUT_TYPE_KEYBOARD_NUMBER_PAD = InputType.TYPE_CLASS_NUMBER;
7575
private static final int INPUT_TYPE_KEYBOARD_DECIMAL_PAD = INPUT_TYPE_KEYBOARD_NUMBER_PAD |
7676
InputType.TYPE_NUMBER_FLAG_DECIMAL;
7777
private static final int INPUT_TYPE_KEYBOARD_NUMBERED = INPUT_TYPE_KEYBOARD_DECIMAL_PAD |
@@ -569,6 +569,11 @@ public void setMaxLength(ReactEditText view, @Nullable Integer maxLength) {
569569

570570
@ReactProp(name = "autoComplete")
571571
public void setTextContentType(ReactEditText view, @Nullable String autocomplete) {
572+
// Autofill hints were added in Android API 26.
573+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
574+
return;
575+
}
576+
572577
if (autocomplete == null) {
573578
setImportantForAutofill(view, View.IMPORTANT_FOR_AUTOFILL_NO);
574579
} else if ("username".equals(autocomplete)) {

0 commit comments

Comments
 (0)