Skip to content

Commit

Permalink
Do not use autofill methods on Android APIs older than Oreo (26)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hramos authored and facebook-github-bot committed Mar 15, 2019
1 parent 7d84d0d commit d4aa1e7
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -569,6 +569,11 @@ public void setMaxLength(ReactEditText view, @Nullable Integer maxLength) {

@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) {
setImportantForAutofill(view, View.IMPORTANT_FOR_AUTOFILL_NO);
} else if ("username".equals(autocomplete)) {
Expand Down

0 comments on commit d4aa1e7

Please sign in to comment.