@@ -54,12 +54,6 @@ public class TextInputPlugin implements ListenableEditingState.EditingStateWatch
54
54
// Initialize the "last seen" text editing values to a non-null value.
55
55
private TextEditState mLastKnownFrameworkTextEditingState ;
56
56
57
- // When true following calls to createInputConnection will return the cached lastInputConnection
58
- // if the input
59
- // target is a platform view. See the comments on lockPlatformViewInputConnection for more
60
- // details.
61
- private boolean isInputConnectionLocked ;
62
-
63
57
@ SuppressLint ("NewApi" )
64
58
public TextInputPlugin (
65
59
@ NonNull View view ,
@@ -105,7 +99,7 @@ public void show() {
105
99
106
100
@ Override
107
101
public void hide () {
108
- if (inputTarget .type == InputTarget .Type .PHYSICAL_DISPLAY_PLATFORM_VIEW ) {
102
+ if (inputTarget .type == InputTarget .Type .PLATFORM_VIEW ) {
109
103
notifyViewExited ();
110
104
} else {
111
105
hideTextInput (mView );
@@ -136,8 +130,8 @@ public void setClient(
136
130
}
137
131
138
132
@ Override
139
- public void setPlatformViewClient (int platformViewId , boolean usesVirtualDisplay ) {
140
- setPlatformViewTextInputClient (platformViewId , usesVirtualDisplay );
133
+ public void setPlatformViewClient (int platformViewId ) {
134
+ setPlatformViewTextInputClient (platformViewId );
141
135
}
142
136
143
137
@ Override
@@ -182,36 +176,6 @@ ImeSyncDeferringInsetsCallback getImeSyncCallback() {
182
176
return imeSyncCallback ;
183
177
}
184
178
185
- /**
186
- * Use the current platform view input connection until unlockPlatformViewInputConnection is
187
- * called.
188
- *
189
- * <p>The current input connection instance is cached and any following call to @{link
190
- * createInputConnection} returns the cached connection until unlockPlatformViewInputConnection is
191
- * called.
192
- *
193
- * <p>This is a no-op if the current input target isn't a platform view.
194
- *
195
- * <p>This is used to preserve an input connection when moving a platform view from one virtual
196
- * display to another.
197
- */
198
- public void lockPlatformViewInputConnection () {
199
- if (inputTarget .type == InputTarget .Type .VIRTUAL_DISPLAY_PLATFORM_VIEW ) {
200
- isInputConnectionLocked = true ;
201
- }
202
- }
203
-
204
- /**
205
- * Unlocks the input connection.
206
- *
207
- * <p>See also: @{link lockPlatformViewInputConnection}.
208
- */
209
- public void unlockPlatformViewInputConnection () {
210
- if (inputTarget .type == InputTarget .Type .VIRTUAL_DISPLAY_PLATFORM_VIEW ) {
211
- isInputConnectionLocked = false ;
212
- }
213
- }
214
-
215
179
/**
216
180
* Detaches the text input plugin from the platform views controller.
217
181
*
@@ -295,21 +259,10 @@ public InputConnection createInputConnection(
295
259
return null ;
296
260
}
297
261
298
- if (inputTarget .type == InputTarget .Type .PHYSICAL_DISPLAY_PLATFORM_VIEW ) {
262
+ if (inputTarget .type == InputTarget .Type .PLATFORM_VIEW ) {
299
263
return null ;
300
264
}
301
265
302
- if (inputTarget .type == InputTarget .Type .VIRTUAL_DISPLAY_PLATFORM_VIEW ) {
303
- if (isInputConnectionLocked ) {
304
- return lastInputConnection ;
305
- }
306
- lastInputConnection =
307
- platformViewsController
308
- .getPlatformViewById (inputTarget .id )
309
- .onCreateInputConnection (outAttrs );
310
- return lastInputConnection ;
311
- }
312
-
313
266
outAttrs .inputType =
314
267
inputTypeFromTextInputType (
315
268
configuration .inputType ,
@@ -364,9 +317,7 @@ public InputConnection getLastInputConnection() {
364
317
* input connection.
365
318
*/
366
319
public void clearPlatformViewClient (int platformViewId ) {
367
- if ((inputTarget .type == InputTarget .Type .VIRTUAL_DISPLAY_PLATFORM_VIEW
368
- || inputTarget .type == InputTarget .Type .PHYSICAL_DISPLAY_PLATFORM_VIEW )
369
- && inputTarget .id == platformViewId ) {
320
+ if (inputTarget .type == InputTarget .Type .PLATFORM_VIEW && inputTarget .id == platformViewId ) {
370
321
inputTarget = new InputTarget (InputTarget .Type .NO_TARGET , 0 );
371
322
notifyViewExited ();
372
323
mImm .hideSoftInputFromWindow (mView .getApplicationWindowToken (), 0 );
@@ -427,26 +378,13 @@ void setTextInputClient(int client, TextInputChannel.Configuration configuration
427
378
// setTextInputClient will be followed by a call to setTextInputEditingState.
428
379
// Do a restartInput at that time.
429
380
mRestartInputPending = true ;
430
- unlockPlatformViewInputConnection ();
431
381
lastClientRect = null ;
432
382
mEditable .addEditingStateListener (this );
433
383
}
434
384
435
- private void setPlatformViewTextInputClient (int platformViewId , boolean usesVirtualDisplay ) {
436
- if (usesVirtualDisplay ) {
437
- // We need to make sure that the Flutter view is focused so that no imm operations get short
438
- // circuited.
439
- // Not asking for focus here specifically manifested in a bug on API 28 devices where the
440
- // platform view's request to show a keyboard was ignored.
441
- mView .requestFocus ();
442
- inputTarget = new InputTarget (InputTarget .Type .VIRTUAL_DISPLAY_PLATFORM_VIEW , platformViewId );
443
- mImm .restartInput (mView );
444
- mRestartInputPending = false ;
445
- } else {
446
- inputTarget =
447
- new InputTarget (InputTarget .Type .PHYSICAL_DISPLAY_PLATFORM_VIEW , platformViewId );
448
- lastInputConnection = null ;
449
- }
385
+ private void setPlatformViewTextInputClient (int platformViewId ) {
386
+ inputTarget = new InputTarget (InputTarget .Type .PLATFORM_VIEW , platformViewId );
387
+ lastInputConnection = null ;
450
388
}
451
389
452
390
private static boolean composingChanged (
@@ -537,29 +475,11 @@ public void inspect(double x, double y) {
537
475
538
476
@ VisibleForTesting
539
477
void clearTextInputClient () {
540
- if (inputTarget .type == InputTarget .Type .VIRTUAL_DISPLAY_PLATFORM_VIEW ) {
541
- // This only applies to platform views that use a virtual display.
542
- // Focus changes in the framework tree have no guarantees on the order focus nodes are
543
- // notified. A node that lost focus may be notified before or after a node that gained focus.
544
- // When moving the focus from a Flutter text field to an AndroidView, it is possible that the
545
- // Flutter text field's focus node will be notified that it lost focus after the AndroidView
546
- // was notified that it gained focus. When this happens the text field will send a
547
- // clearTextInput command which we ignore.
548
- // By doing this we prevent the framework from clearing a platform view input client (the only
549
- // way to do so is to set a new framework text client). I don't see an obvious use case for
550
- // "clearing" a platform view's text input client, and it may be error prone as we don't know
551
- // how the platform view manages the input connection and we probably shouldn't interfere.
552
- // If we ever want to allow the framework to clear a platform view text client we should
553
- // probably consider changing the focus manager such that focus nodes that lost focus are
554
- // notified before focus nodes that gained focus as part of the same focus event.
555
- return ;
556
- }
557
478
mEditable .removeEditingStateListener (this );
558
479
notifyViewExited ();
559
480
configuration = null ;
560
481
updateAutofillConfigurationIfNeeded (null );
561
482
inputTarget = new InputTarget (InputTarget .Type .NO_TARGET , 0 );
562
- unlockPlatformViewInputConnection ();
563
483
lastClientRect = null ;
564
484
}
565
485
@@ -569,12 +489,9 @@ enum Type {
569
489
// InputConnection is managed by the TextInputPlugin, and events are forwarded to the Flutter
570
490
// framework.
571
491
FRAMEWORK_CLIENT ,
572
- // InputConnection is managed by a platform view that is presented on a virtual display.
573
- VIRTUAL_DISPLAY_PLATFORM_VIEW ,
574
- // InputConnection is managed by a platform view that is embedded in the activity's view
575
- // hierarchy. This view hierarchy is displayed in a physical display within the aplication
576
- // display area.
577
- PHYSICAL_DISPLAY_PLATFORM_VIEW ,
492
+ // InputConnection is managed by a platform view that is embeded in the Android view
493
+ // hierarchy.
494
+ PLATFORM_VIEW ,
578
495
}
579
496
580
497
public InputTarget (@ NonNull Type type , int id ) {
0 commit comments