mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-23 03:44:13 +08:00
Add prop to configure importantForAutofill. (#22763)
Summary: In API 26, autofill framework was introduced in Android. Read more about Autofill at https://developer.android.com/guide/topics/text/autofill. Now, if in case for some text input if developer wants to disable autofill then he can take help from this `importantForAutoFill` prop and pass `no` to it. Also important of auto fill can be configured with this prop, like: * `auto`: Let the Android System use its heuristics to determine if the view is important for autofill. * `no`: This view isn't important for autofill. * `noExcludeDescendants`: This view and its children aren't important for autofill. * `yes`: This view is important for autofill. * `yesExcludeDescendants`: This view is important for autofill, but its children aren't important for autofill. Default value if `auto`. Read more at: https://developer.android.com/guide/topics/text/autofill-optimize Changelog: ---------- [Android] [Added] - Add prop to configure `importantForAutofill` in `TextInput`. Pull Request resolved: https://github.com/facebook/react-native/pull/22763 Differential Revision: D14121242 Pulled By: cpojer fbshipit-source-id: aa4360480dd19f6dde66f0409d26a41a6a318c94
This commit is contained in:
committed by
Facebook Github Bot
parent
3102ea51b2
commit
9126add6b9
@@ -10,6 +10,7 @@ package com.facebook.react.views.textinput;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.text.Editable;
|
||||
import android.text.InputFilter;
|
||||
@@ -279,6 +280,24 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||
}
|
||||
}
|
||||
|
||||
@ReactProp(name = "importantForAutofill")
|
||||
public void setImportantForAutofill(ReactEditText view, @Nullable String value) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||
return;
|
||||
}
|
||||
int mode = View.IMPORTANT_FOR_AUTOFILL_AUTO;
|
||||
if ("no".equals(value)) {
|
||||
mode = View.IMPORTANT_FOR_AUTOFILL_NO;
|
||||
} else if ("noExcludeDescendants".equals(value)) {
|
||||
mode = View.IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS;
|
||||
} else if ("yes".equals(value)) {
|
||||
mode = View.IMPORTANT_FOR_AUTOFILL_YES;
|
||||
} else if ("yesExcludeDescendants".equals(value)) {
|
||||
mode = View.IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS;
|
||||
}
|
||||
view.setImportantForAutofill(mode);
|
||||
}
|
||||
|
||||
@ReactProp(name = "onSelectionChange", defaultBoolean = false)
|
||||
public void setOnSelectionChange(final ReactEditText view, boolean onSelectionChange) {
|
||||
if (onSelectionChange) {
|
||||
|
||||
Reference in New Issue
Block a user