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

Commit 41d403b

Browse files
review
1 parent 6c1dde0 commit 41d403b

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

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

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,12 @@
5656
public class KeyboardManager {
5757
private static final String TAG = "KeyboardManager";
5858

59-
KeyboardManager(
60-
View view, @NonNull TextInputPlugin textInputPlugin, Responder[] primaryResponders) {
61-
this.view = view;
62-
this.textInputPlugin = textInputPlugin;
63-
this.primaryResponders = primaryResponders;
64-
}
65-
6659
/**
67-
* Constructor for {@link KeyboardManager} that uses a {@link KeyChannelResponder} as its only
68-
* {@link Responder}.
60+
* Constructor for {@link KeyboardManager} that takes a list of {@link Responder}s.
6961
*
7062
* <p>The view is used as the destination to send the synthesized key to. This means that the the
71-
* next thing in the focus chain will get the event when the {@link KeyChannelResponder} returns
72-
* false from onKeyDown/onKeyUp.
63+
* next thing in the focus chain will get the event when the {@link Responder}s return false from
64+
* onKeyDown/onKeyUp.
7365
*
7466
* <p>It is possible that that in the middle of the async round trip, the focus chain could
7567
* change, and instead of the native widget that was "next" when the event was fired getting the
@@ -82,9 +74,16 @@ public class KeyboardManager {
8274
* @param textInputPlugin a plugin, which, if set, is given key events before the framework is,
8375
* and if it has a valid input connection and is accepting text, then it will handle the event
8476
* and the framework will not receive it.
85-
* @param keyEventChannel the event channel to listen to for new key events.
77+
* @param responders the {@link Responder}s new {@link KeyEvent}s will be first dispatched to.
8678
*/
8779
public KeyboardManager(
80+
View view, @NonNull TextInputPlugin textInputPlugin, Responder[] responders) {
81+
this.view = view;
82+
this.textInputPlugin = textInputPlugin;
83+
this.responders = responders;
84+
}
85+
86+
KeyboardManager(
8887
View view, @NonNull TextInputPlugin textInputPlugin, KeyEventChannel keyEventChannel) {
8988
this(
9089
view,
@@ -148,15 +147,15 @@ public void onKeyEventHandled(Boolean canHandleEvent) {
148147
}
149148

150149
@NonNull final KeyEvent keyEvent;
151-
int unrepliedCount = primaryResponders.length;
150+
int unrepliedCount = responders.length;
152151
boolean isEventHandled = false;
153152

154153
public OnKeyEventHandledCallback buildCallback() {
155154
return new Callback();
156155
}
157156
}
158157

159-
@NonNull protected final Responder[] primaryResponders;
158+
@NonNull protected final Responder[] responders;
160159
@NonNull private final HashSet<KeyEvent> redispatchedEvents = new HashSet<>();
161160
@NonNull private final TextInputPlugin textInputPlugin;
162161
private final View view;
@@ -167,9 +166,9 @@ public boolean handleEvent(@NonNull KeyEvent keyEvent) {
167166
return false;
168167
}
169168

170-
if (primaryResponders.length > 0) {
169+
if (responders.length > 0) {
171170
final PerEventCallbackBuilder callbackBuilder = new PerEventCallbackBuilder(keyEvent);
172-
for (final Responder primaryResponder : primaryResponders) {
171+
for (final Responder primaryResponder : responders) {
173172
primaryResponder.handleEvent(keyEvent, callbackBuilder.buildCallback());
174173
}
175174
} else {

0 commit comments

Comments
 (0)