mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Enable text autocorrect on Android with a flag to disable it (flutter/engine#3866)
See https://github.com/flutter/flutter/issues/11168
This commit is contained in:
parent
c9286a9e4d
commit
59b447a5fe
@ -77,7 +77,9 @@ public class TextInputPlugin implements MethodCallHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private static int inputTypeFromTextInputType(String inputType, boolean obscureText) {
|
||||
private static int inputTypeFromTextInputType(String inputType,
|
||||
boolean obscureText,
|
||||
boolean noAutoCorrect) {
|
||||
if (inputType.equals("TextInputType.datetime"))
|
||||
return InputType.TYPE_CLASS_DATETIME;
|
||||
if (inputType.equals("TextInputType.number"))
|
||||
@ -94,6 +96,8 @@ public class TextInputPlugin implements MethodCallHandler {
|
||||
// Note: both required. Some devices ignore TYPE_TEXT_FLAG_NO_SUGGESTIONS.
|
||||
textType |= InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
|
||||
textType |= InputType.TYPE_TEXT_VARIATION_PASSWORD;
|
||||
} else if (!noAutoCorrect) {
|
||||
textType |= InputType.TYPE_TEXT_FLAG_AUTO_CORRECT;
|
||||
}
|
||||
return textType;
|
||||
}
|
||||
@ -103,8 +107,10 @@ public class TextInputPlugin implements MethodCallHandler {
|
||||
if (mClient == 0)
|
||||
return null;
|
||||
|
||||
outAttrs.inputType = inputTypeFromTextInputType(mConfiguration.getString("inputType"),
|
||||
mConfiguration.optBoolean("obscureText"));
|
||||
outAttrs.inputType = inputTypeFromTextInputType(
|
||||
mConfiguration.getString("inputType"),
|
||||
mConfiguration.optBoolean("obscureText"),
|
||||
mConfiguration.optBoolean("noAutoCorrect"));
|
||||
if (!mConfiguration.isNull("actionLabel"))
|
||||
outAttrs.actionLabel = mConfiguration.getString("actionLabel");
|
||||
outAttrs.imeOptions = EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_FULLSCREEN;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user