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
This commit is contained in:
parent
3f1d2b0f96
commit
7263a77b44
|
@ -71,7 +71,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
|||
private static final int FOCUS_TEXT_INPUT = 1;
|
||||
private static final int BLUR_TEXT_INPUT = 2;
|
||||
|
||||
private static final int INPUT_TYPE_KEYBOARD_NUMBER_PAD = InputType.TYPE_CLASS_NUMBER;
|
||||
private static final int INPUT_TYPE_KEYBOARD_NUMBER_PAD = InputType.TYPE_CLASS_NUMBER;
|
||||
private static final int INPUT_TYPE_KEYBOARD_DECIMAL_PAD = INPUT_TYPE_KEYBOARD_NUMBER_PAD |
|
||||
InputType.TYPE_NUMBER_FLAG_DECIMAL;
|
||||
private static final int INPUT_TYPE_KEYBOARD_NUMBERED = INPUT_TYPE_KEYBOARD_DECIMAL_PAD |
|
||||
|
@ -559,6 +559,11 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
|||
|
||||
@ReactProp(name = "autoComplete")
|
||||
public void setTextContentType(ReactEditText view, @Nullable String autocomplete) {
|
||||
// Autofill hints were added in Android API 26.
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (autocomplete == null) {
|
||||
view.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO);
|
||||
} else if ("username".equals(autocomplete)) {
|
||||
|
|
Loading…
Reference in New Issue