diff --git a/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java b/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java index 55386eeba5..8432269407 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java @@ -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; diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java index 5c23ea40be..68efb65142 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java @@ -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; diff --git a/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/editing/TextInputPluginTest.java b/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/editing/TextInputPluginTest.java index cd5eb37786..0342668e21 100644 --- a/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/editing/TextInputPluginTest.java +++ b/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/editing/TextInputPluginTest.java @@ -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));