Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Fix enableSuggestions set to false not honored #46037

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,11 @@ private static int inputTypeFromTextInputType(
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 (!enableSuggestions) {
// Note: both required. Some devices ignore TYPE_TEXT_FLAG_NO_SUGGESTIONS.
textType |= InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
textType |= InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
}
}

if (textCapitalization == TextInputChannel.TextCapitalization.CHARACTERS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,42 @@ public void showTextInput_textInputTypeNone() {
assertEquals(testImm.isSoftInputVisible(), false);
}

@Test
public void inputConnection_textInputTypeMultilineAndSuggestionsDisabled() {
// Regression test for https://github.com/flutter/flutter/issues/71679.
View testView = new View(ctx);
DartExecutor dartExecutor = mock(DartExecutor.class);
TextInputChannel textInputChannel = new TextInputChannel(dartExecutor);
TextInputPlugin textInputPlugin =
new TextInputPlugin(testView, textInputChannel, mock(PlatformViewsController.class));
textInputPlugin.setTextInputClient(
0,
new TextInputChannel.Configuration(
false,
false,
false, // Disable suggestions.
true,
false,
TextInputChannel.TextCapitalization.NONE,
new TextInputChannel.InputType(TextInputChannel.TextInputType.MULTILINE, false, false),
null,
null,
null,
null,
null));

EditorInfo editorInfo = new EditorInfo();
InputConnection connection =
textInputPlugin.createInputConnection(testView, mock(KeyboardManager.class), editorInfo);

assertEquals(
editorInfo.inputType,
InputType.TYPE_CLASS_TEXT
| InputType.TYPE_TEXT_FLAG_MULTI_LINE
| InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
| InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
}

// -------- Start: Autofill Tests -------
@Test
public void autofill_enabledByDefault() {
Expand Down