Skip to content

Commit 7263a77

Browse files
hramosgrabbou
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 3f1d2b0 commit 7263a77

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

Lines changed: 6 additions & 1 deletion
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 |
@@ -559,6 +559,11 @@ public void setMaxLength(ReactEditText view, @Nullable Integer maxLength) {
559559

560560
@ReactProp(name = "autoComplete")
561561
public void setTextContentType(ReactEditText view, @Nullable String autocomplete) {
562+
// Autofill hints were added in Android API 26.
563+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
564+
return;
565+
}
566+
562567
if (autocomplete == null) {
563568
view.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO);
564569
} else if ("username".equals(autocomplete)) {

0 commit comments

Comments
 (0)