Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 62ed56b

Browse files
remove setKeyboardManager
1 parent f5197ab commit 62ed56b

File tree

6 files changed

+20
-17
lines changed

6 files changed

+20
-17
lines changed

shell/platform/android/io/flutter/embedding/android/FlutterView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ public InputConnection onCreateInputConnection(@NonNull EditorInfo outAttrs) {
705705
return super.onCreateInputConnection(outAttrs);
706706
}
707707

708-
return textInputPlugin.createInputConnection(this, outAttrs);
708+
return textInputPlugin.createInputConnection(this, keyboardManager, outAttrs);
709709
}
710710

711711
/**
@@ -979,7 +979,7 @@ public void attachToFlutterEngine(@NonNull FlutterEngine flutterEngine) {
979979
keyboardManager =
980980
new KeyboardManager(
981981
this,
982-
mTextInputPlugin,
982+
textInputPlugin,
983983
new Responder[] {new KeyChannelResponder(flutterEngine.getKeyEventChannel())});
984984
androidTouchProcessor =
985985
new AndroidTouchProcessor(this.flutterEngine.getRenderer(), /*trackMotionEvents=*/ false);

shell/platform/android/io/flutter/embedding/android/KeyboardManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public boolean handleEvent(@NonNull KeyEvent keyEvent) {
166166
onUnhandled(keyEvent);
167167
}
168168

169-
return !isRedispatchedEvent;
169+
return true;
170170
}
171171

172172
public void destroy() {

shell/platform/android/io/flutter/plugin/editing/InputConnectionAdaptor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class InputConnectionAdaptor extends BaseInputConnection
4747
private InputMethodManager mImm;
4848
private final Layout mLayout;
4949
private FlutterTextUtils flutterTextUtils;
50-
private final KeyboardManager mKeyboardManager;
50+
private final KeyboardManager keyboardManager;
5151

5252
@SuppressWarnings("deprecation")
5353
public InputConnectionAdaptor(
@@ -65,7 +65,7 @@ public InputConnectionAdaptor(
6565
mEditable = editable;
6666
mEditable.addEditingStateListener(this);
6767
mEditorInfo = editorInfo;
68-
mKeyboardManager = keyboardManager;
68+
this.keyboardManager = keyboardManager;
6969
this.flutterTextUtils = new FlutterTextUtils(flutterJNI);
7070
// We create a dummy Layout with max width so that the selection
7171
// shifting acts as if all text were in one line.
@@ -290,7 +290,7 @@ private static int clampIndexToEditable(int index, Editable editable) {
290290
// occur, and need a chance to be handled by the framework.
291291
@Override
292292
public boolean sendKeyEvent(KeyEvent event) {
293-
return mKeyboardManager.handleEvent(event);
293+
return keyboardManager.handleEvent(event);
294294
}
295295

296296
public boolean handleKeyEvent(KeyEvent event) {

shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public class TextInputPlugin implements ListenableEditingState.EditingStateWatch
4949
@NonNull private PlatformViewsController platformViewsController;
5050
@Nullable private Rect lastClientRect;
5151
private ImeSyncDeferringInsetsCallback imeSyncCallback;
52-
private KeyboardManager keyboardManager;
5352

5453
// Initialize the "last seen" text editing values to a non-null value.
5554
private TextEditState mLastKnownFrameworkTextEditingState;
@@ -176,9 +175,6 @@ ImeSyncDeferringInsetsCallback getImeSyncCallback() {
176175
return imeSyncCallback;
177176
}
178177

179-
public void setKeyboardManager(KeyboardManager keyboardManager) {
180-
this.keyboardManager = keyboardManager;
181-
}
182178
/**
183179
* Use the current platform view input connection until unlockPlatformViewInputConnection is
184180
* called.
@@ -281,7 +277,8 @@ private static int inputTypeFromTextInputType(
281277
return textType;
282278
}
283279

284-
public InputConnection createInputConnection(View view, EditorInfo outAttrs) {
280+
public InputConnection createInputConnection(
281+
View view, KeyboardManager keyboardManager, EditorInfo outAttrs) {
285282
if (inputTarget.type == InputTarget.Type.NO_TARGET) {
286283
lastInputConnection = null;
287284
return null;

shell/platform/android/io/flutter/view/FlutterView.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ public void onPostResume() {
231231
mKeyboardManager =
232232
new KeyboardManager(
233233
this, mTextInputPlugin, new Responder[] {new KeyChannelResponder(keyEventChannel)});
234-
mTextInputPlugin.setKeyboardManager(mKeyboardManager);
235234

236235
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
237236
mMouseCursorPlugin = new MouseCursorPlugin(this, new MouseCursorChannel(dartExecutor));
@@ -446,7 +445,7 @@ public void destroy() {
446445

447446
@Override
448447
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
449-
return mTextInputPlugin.createInputConnection(this, outAttrs);
448+
return mTextInputPlugin.createInputConnection(this, mKeyboardManager, outAttrs);
450449
}
451450

452451
@Override

shell/platform/android/test/io/flutter/plugin/editing/TextInputPluginTest.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ public void inputConnectionAdaptor_RepeatFilter() throws NullPointerException {
210210
.updateEditingState(anyInt(), any(), anyInt(), anyInt(), anyInt(), anyInt());
211211

212212
InputConnectionAdaptor inputConnectionAdaptor =
213-
(InputConnectionAdaptor) textInputPlugin.createInputConnection(testView, outAttrs);
213+
(InputConnectionAdaptor)
214+
textInputPlugin.createInputConnection(testView, mock(KeyboardManager.class), outAttrs);
214215

215216
inputConnectionAdaptor.beginBatchEdit();
216217
verify(textInputChannel, times(0))
@@ -376,7 +377,9 @@ public void setTextInputEditingState_restartsIMEOnlyWhenFrameworkChangesComposin
376377
textInputPlugin.setTextInputEditingState(
377378
testView, new TextInputChannel.TextEditState("", 0, 0, -1, -1));
378379
assertEquals(1, testImm.getRestartCount(testView));
379-
InputConnection connection = textInputPlugin.createInputConnection(testView, new EditorInfo());
380+
InputConnection connection =
381+
textInputPlugin.createInputConnection(
382+
testView, mock(KeyboardManager.class), new EditorInfo());
380383
connection.setComposingText("POWERRRRR", 1);
381384

382385
textInputPlugin.setTextInputEditingState(
@@ -521,7 +524,9 @@ public void inputConnection_createsActionFromEnter() throws JSONException {
521524
assertEquals("flutter/textinput", channelCaptor.getValue());
522525
verifyMethodCall(bufferCaptor.getValue(), "TextInputClient.requestExistingInputState", null);
523526
InputConnectionAdaptor connection =
524-
(InputConnectionAdaptor) textInputPlugin.createInputConnection(testView, new EditorInfo());
527+
(InputConnectionAdaptor)
528+
textInputPlugin.createInputConnection(
529+
testView, mock(KeyboardManager.class), new EditorInfo());
525530

526531
connection.handleKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER));
527532
verify(dartExecutor, times(2))
@@ -586,7 +591,9 @@ public void inputConnection_finishComposingTextUpdatesIMM() throws JSONException
586591
// There's a pending restart since we initialized the text input client. Flush that now.
587592
textInputPlugin.setTextInputEditingState(
588593
testView, new TextInputChannel.TextEditState("text", 0, 0, -1, -1));
589-
InputConnection connection = textInputPlugin.createInputConnection(testView, new EditorInfo());
594+
InputConnection connection =
595+
textInputPlugin.createInputConnection(
596+
testView, mock(KeyboardManager.class), new EditorInfo());
590597

591598
connection.requestCursorUpdates(
592599
InputConnection.CURSOR_UPDATE_MONITOR | InputConnection.CURSOR_UPDATE_IMMEDIATE);

0 commit comments

Comments
 (0)