提交 74d6f605 编写于 作者: J Jason Simmons 提交者: GitHub

Enable text autocorrect on Android with a flag to disable it (#3866)

See https://github.com/flutter/flutter/issues/11168
上级 354d90a9
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册