NO_SUGGESTIONS keyboard flag in Android (flutter/engine#13099)
Add the enableSuggestions parameter to control Android's keyboard suggestions
This commit is contained in:
committed by
GitHub
parent
e2d13fcde6
commit
c1d8b3c16d
@@ -271,6 +271,7 @@ public class TextInputChannel {
|
||||
return new Configuration(
|
||||
json.optBoolean("obscureText"),
|
||||
json.optBoolean("autocorrect", true),
|
||||
json.optBoolean("enableSuggestions"),
|
||||
TextCapitalization.fromValue(json.getString("textCapitalization")),
|
||||
InputType.fromJson(json.getJSONObject("inputType")),
|
||||
inputAction,
|
||||
@@ -307,6 +308,7 @@ public class TextInputChannel {
|
||||
|
||||
public final boolean obscureText;
|
||||
public final boolean autocorrect;
|
||||
public final boolean enableSuggestions;
|
||||
@NonNull
|
||||
public final TextCapitalization textCapitalization;
|
||||
@NonNull
|
||||
@@ -319,6 +321,7 @@ public class TextInputChannel {
|
||||
public Configuration(
|
||||
boolean obscureText,
|
||||
boolean autocorrect,
|
||||
boolean enableSuggestions,
|
||||
@NonNull TextCapitalization textCapitalization,
|
||||
@NonNull InputType inputType,
|
||||
@Nullable Integer inputAction,
|
||||
@@ -326,6 +329,7 @@ public class TextInputChannel {
|
||||
) {
|
||||
this.obscureText = obscureText;
|
||||
this.autocorrect = autocorrect;
|
||||
this.enableSuggestions = enableSuggestions;
|
||||
this.textCapitalization = textCapitalization;
|
||||
this.inputType = inputType;
|
||||
this.inputAction = inputAction;
|
||||
|
||||
@@ -138,6 +138,7 @@ public class TextInputPlugin {
|
||||
TextInputChannel.InputType type,
|
||||
boolean obscureText,
|
||||
boolean autocorrect,
|
||||
boolean enableSuggestions,
|
||||
TextInputChannel.TextCapitalization textCapitalization
|
||||
) {
|
||||
if (type.type == TextInputChannel.TextInputType.DATETIME) {
|
||||
@@ -172,6 +173,7 @@ public class TextInputPlugin {
|
||||
textType |= InputType.TYPE_TEXT_VARIATION_PASSWORD;
|
||||
} else {
|
||||
if (autocorrect) textType |= InputType.TYPE_TEXT_FLAG_AUTO_CORRECT;
|
||||
if (!enableSuggestions) textType |= InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
|
||||
}
|
||||
|
||||
if (textCapitalization == TextInputChannel.TextCapitalization.CHARACTERS) {
|
||||
@@ -203,6 +205,7 @@ public class TextInputPlugin {
|
||||
configuration.inputType,
|
||||
configuration.obscureText,
|
||||
configuration.autocorrect,
|
||||
configuration.enableSuggestions,
|
||||
configuration.textCapitalization
|
||||
);
|
||||
outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_FULLSCREEN;
|
||||
|
||||
@@ -36,7 +36,7 @@ public class TextInputPluginTest {
|
||||
testImm.setCurrentInputMethodSubtype(inputMethodSubtype);
|
||||
View testView = new View(RuntimeEnvironment.application);
|
||||
TextInputPlugin textInputPlugin = new TextInputPlugin(testView, mock(DartExecutor.class), mock(PlatformViewsController.class));
|
||||
textInputPlugin.setTextInputClient(0, new TextInputChannel.Configuration(false, false, TextInputChannel.TextCapitalization.NONE, null, null, null));
|
||||
textInputPlugin.setTextInputClient(0, new TextInputChannel.Configuration(false, false, true, TextInputChannel.TextCapitalization.NONE, null, null, null));
|
||||
// There's a pending restart since we initialized the text input client. Flush that now.
|
||||
textInputPlugin.setTextInputEditingState(testView, new TextInputChannel.TextEditState("", 0, 0));
|
||||
|
||||
@@ -61,7 +61,7 @@ public class TextInputPluginTest {
|
||||
testImm.setCurrentInputMethodSubtype(inputMethodSubtype);
|
||||
View testView = new View(RuntimeEnvironment.application);
|
||||
TextInputPlugin textInputPlugin = new TextInputPlugin(testView, mock(DartExecutor.class), mock(PlatformViewsController.class));
|
||||
textInputPlugin.setTextInputClient(0, new TextInputChannel.Configuration(false, false, TextInputChannel.TextCapitalization.NONE, null, null, null));
|
||||
textInputPlugin.setTextInputClient(0, new TextInputChannel.Configuration(false, false, true, TextInputChannel.TextCapitalization.NONE, null, null, null));
|
||||
// There's a pending restart since we initialized the text input client. Flush that now.
|
||||
textInputPlugin.setTextInputEditingState(testView, new TextInputChannel.TextEditState("", 0, 0));
|
||||
|
||||
@@ -83,7 +83,7 @@ public class TextInputPluginTest {
|
||||
testImm.setCurrentInputMethodSubtype(inputMethodSubtype);
|
||||
View testView = new View(RuntimeEnvironment.application);
|
||||
TextInputPlugin textInputPlugin = new TextInputPlugin(testView, mock(DartExecutor.class), mock(PlatformViewsController.class));
|
||||
textInputPlugin.setTextInputClient(0, new TextInputChannel.Configuration(false, false, TextInputChannel.TextCapitalization.NONE, null, null, null));
|
||||
textInputPlugin.setTextInputClient(0, new TextInputChannel.Configuration(false, false, true, TextInputChannel.TextCapitalization.NONE, null, null, null));
|
||||
// There's a pending restart since we initialized the text input client. Flush that now.
|
||||
textInputPlugin.setTextInputEditingState(testView, new TextInputChannel.TextEditState("", 0, 0));
|
||||
|
||||
@@ -102,7 +102,7 @@ public class TextInputPluginTest {
|
||||
|
||||
View testView = new View(RuntimeEnvironment.application);
|
||||
TextInputPlugin textInputPlugin = new TextInputPlugin(testView, mock(DartExecutor.class), mock(PlatformViewsController.class));
|
||||
textInputPlugin.setTextInputClient(0, new TextInputChannel.Configuration(false, false, TextInputChannel.TextCapitalization.NONE, null, null, null));
|
||||
textInputPlugin.setTextInputClient(0, new TextInputChannel.Configuration(false, false, true, TextInputChannel.TextCapitalization.NONE, null, null, null));
|
||||
// There's a pending restart since we initialized the text input client. Flush that now.
|
||||
textInputPlugin.setTextInputEditingState(testView, new TextInputChannel.TextEditState("", 0, 0));
|
||||
assertEquals(1, testImm.getRestartCount(testView));
|
||||
|
||||
Reference in New Issue
Block a user