Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -376,16 +376,11 @@ public void sendTextInputAppPrivateCommand(@NonNull String action, @NonNull Bund
mImm.sendAppPrivateCommand(mView, action, data);
}

private boolean canShowTextInput() {
if (configuration == null || configuration.inputType == null) {
return true;
}
return configuration.inputType.type != TextInputChannel.TextInputType.NONE;
}

@VisibleForTesting
void showTextInput(View view) {
if (canShowTextInput()) {
if (configuration == null
|| configuration.inputType == null
|| configuration.inputType.type != TextInputChannel.TextInputType.NONE) {
view.requestFocus();
mImm.showSoftInput(view, 0);
} else {
Expand All @@ -409,11 +404,7 @@ void setTextInputClient(int client, TextInputChannel.Configuration configuration
// Call notifyViewExited on the previous field.
notifyViewExited();
this.configuration = configuration;
if (canShowTextInput()) {
inputTarget = new InputTarget(InputTarget.Type.FRAMEWORK_CLIENT, client);
} else {
inputTarget = new InputTarget(InputTarget.Type.NO_TARGET, client);
}
inputTarget = new InputTarget(InputTarget.Type.FRAMEWORK_CLIENT, client);

mEditable.removeEditingStateListener(this);
mEditable =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.flutter.plugin.editing;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.mockito.AdditionalMatchers.aryEq;
Expand Down Expand Up @@ -1176,8 +1177,8 @@ public void destroy_clearTextInputMethodHandler() {

@SuppressWarnings("deprecation")
// DartExecutor.send is deprecated.
@Test
public void inputConnection_createsActionFromEnter() throws JSONException {
private void verifyInputConnection(TextInputChannel.TextInputType textInputType)
throws JSONException {
TestImm testImm = Shadow.extract(ctx.getSystemService(Context.INPUT_METHOD_SERVICE));
FlutterJNI mockFlutterJni = mock(FlutterJNI.class);
View testView = new View(ctx);
Expand All @@ -1194,7 +1195,7 @@ public void inputConnection_createsActionFromEnter() throws JSONException {
true,
false,
TextInputChannel.TextCapitalization.NONE,
new TextInputChannel.InputType(TextInputChannel.TextInputType.TEXT, false, false),
new TextInputChannel.InputType(textInputType, false, false),
null,
null,
null,
Expand Down Expand Up @@ -1232,6 +1233,16 @@ public void inputConnection_createsActionFromEnter() throws JSONException {
new String[] {"0", "TextInputAction.done"});
}

@Test
public void inputConnection_createsActionFromEnter() throws JSONException {
verifyInputConnection(TextInputChannel.TextInputType.TEXT);
}

@Test
public void inputConnection_respondsToKeyEvents_textInputTypeNone() throws JSONException {
verifyInputConnection(TextInputChannel.TextInputType.NONE);
}

@SuppressWarnings("deprecation") // InputMethodSubtype
@Test
public void inputConnection_finishComposingTextUpdatesIMM() throws JSONException {
Expand Down Expand Up @@ -1310,7 +1321,7 @@ public void inputConnection_textInputTypeNone() {
InputConnection connection =
textInputPlugin.createInputConnection(
testView, mock(KeyboardManager.class), new EditorInfo());
assertEquals(connection, null);
assertNotNull(connection);
}

@Test
Expand Down