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

Commit 500ae6c

Browse files
authored
Revert "Close connection on keyboard close (#41500)" (#49366)
Related issue: flutter/flutter#140508
1 parent cd12316 commit 500ae6c

File tree

4 files changed

+1
-71
lines changed

4 files changed

+1
-71
lines changed

shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,6 @@ public void performPrivateCommand(
367367
"TextInputClient.performPrivateCommand", Arrays.asList(inputClientId, json));
368368
}
369369

370-
/** Instructs Flutter to execute a "onConnectionClosed" action. */
371-
public void onConnectionClosed(int inputClientId) {
372-
Log.v(TAG, "Sending 'onConnectionClosed' message.");
373-
channel.invokeMethod(
374-
"TextInputClient.onConnectionClosed",
375-
Arrays.asList(inputClientId, "TextInputClient.onConnectionClosed"));
376-
}
377-
378370
/**
379371
* Sets the {@link TextInputMethodHandler} which receives all events and requests that are parsed
380372
* from the underlying platform channel.

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

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
import androidx.annotation.NonNull;
1515
import androidx.annotation.RequiresApi;
1616
import androidx.annotation.VisibleForTesting;
17-
import androidx.core.view.ViewCompat;
18-
import androidx.core.view.WindowInsetsCompat;
1917
import java.util.List;
2018

2119
// Loosely based off of
@@ -43,9 +41,7 @@
4341
// a no-op. When onEnd indicates the end of the animation, the deferred call is
4442
// dispatched again, this time avoiding any flicker since the animation is now
4543
// complete.
46-
47-
// This class should have "package private" visibility cause it's called from TextInputPlugin.
48-
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
44+
@VisibleForTesting
4945
@TargetApi(30)
5046
@RequiresApi(30)
5147
@SuppressLint({"NewApi", "Override"})
@@ -56,7 +52,6 @@ class ImeSyncDeferringInsetsCallback {
5652
private WindowInsets lastWindowInsets;
5753
private AnimationCallback animationCallback;
5854
private InsetsListener insetsListener;
59-
private ImeVisibleListener imeVisibleListener;
6055

6156
// True when an animation that matches deferredInsetTypes is active.
6257
//
@@ -94,11 +89,6 @@ void remove() {
9489
view.setOnApplyWindowInsetsListener(null);
9590
}
9691

97-
// Set a listener to be notified when the IME visibility changes.
98-
void setImeVisibleListener(ImeVisibleListener imeVisibleListener) {
99-
this.imeVisibleListener = imeVisibleListener;
100-
}
101-
10292
@VisibleForTesting
10393
View.OnApplyWindowInsetsListener getInsetsListener() {
10494
return insetsListener;
@@ -109,11 +99,6 @@ WindowInsetsAnimation.Callback getAnimationCallback() {
10999
return animationCallback;
110100
}
111101

112-
@VisibleForTesting
113-
ImeVisibleListener getImeVisibleListener() {
114-
return imeVisibleListener;
115-
}
116-
117102
// WindowInsetsAnimation.Callback was introduced in API level 30. The callback
118103
// subclass is separated into an inner class in order to avoid warnings from
119104
// the Android class loader on older platforms.
@@ -131,20 +116,6 @@ public void onPrepare(WindowInsetsAnimation animation) {
131116
}
132117
}
133118

134-
@NonNull
135-
@Override
136-
public WindowInsetsAnimation.Bounds onStart(
137-
@NonNull WindowInsetsAnimation animation, @NonNull WindowInsetsAnimation.Bounds bounds) {
138-
// Observe changes to software keyboard visibility and notify listener when animation start.
139-
// See https://developer.android.com/develop/ui/views/layout/sw-keyboard.
140-
WindowInsetsCompat insets = ViewCompat.getRootWindowInsets(view);
141-
if (insets != null && imeVisibleListener != null) {
142-
boolean imeVisible = insets.isVisible(WindowInsetsCompat.Type.ime());
143-
imeVisibleListener.onImeVisibleChanged(imeVisible);
144-
}
145-
return super.onStart(animation, bounds);
146-
}
147-
148119
@Override
149120
public WindowInsets onProgress(
150121
WindowInsets insets, List<WindowInsetsAnimation> runningAnimations) {
@@ -229,9 +200,4 @@ public WindowInsets onApplyWindowInsets(View view, WindowInsets windowInsets) {
229200
return view.onApplyWindowInsets(windowInsets);
230201
}
231202
}
232-
233-
// Listener for IME visibility changes.
234-
public interface ImeVisibleListener {
235-
void onImeVisibleChanged(boolean visible);
236-
}
237203
}

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,6 @@ public TextInputPlugin(
8181
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
8282
imeSyncCallback = new ImeSyncDeferringInsetsCallback(view);
8383
imeSyncCallback.install();
84-
85-
// When the IME is hidden, we need to notify the framework that close connection.
86-
imeSyncCallback.setImeVisibleListener(
87-
new ImeSyncDeferringInsetsCallback.ImeVisibleListener() {
88-
@Override
89-
public void onImeVisibleChanged(boolean visible) {
90-
if (!visible) {
91-
onConnectionClosed();
92-
}
93-
}
94-
});
9584
}
9685

9786
this.textInputChannel = textInputChannel;
@@ -844,8 +833,4 @@ public void autofill(@NonNull SparseArray<AutofillValue> values) {
844833
textInputChannel.updateEditingStateWithTag(inputTarget.id, editingValues);
845834
}
846835
// -------- End: Autofill -------
847-
848-
public void onConnectionClosed() {
849-
textInputChannel.onConnectionClosed(inputTarget.id);
850-
}
851836
}

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2367,19 +2367,6 @@ public void lastWindowInsets_updatedOnSecondOnProgressCall() {
23672367
assertEquals(0, viewportMetricsCaptor.getValue().viewPaddingBottom);
23682368
}
23692369

2370-
@Test
2371-
@TargetApi(30)
2372-
@Config(sdk = 30)
2373-
public void onConnectionClosed_imeInvisible() {
2374-
View testView = new View(ctx);
2375-
TextInputChannel textInputChannel = spy(new TextInputChannel(mock(DartExecutor.class)));
2376-
TextInputPlugin textInputPlugin =
2377-
new TextInputPlugin(testView, textInputChannel, mock(PlatformViewsController.class));
2378-
ImeSyncDeferringInsetsCallback imeSyncCallback = textInputPlugin.getImeSyncCallback();
2379-
imeSyncCallback.getImeVisibleListener().onImeVisibleChanged(false);
2380-
verify(textInputChannel, times(1)).onConnectionClosed(anyInt());
2381-
}
2382-
23832370
interface EventHandler {
23842371
void sendAppPrivateCommand(View view, String action, Bundle data);
23852372
}

0 commit comments

Comments
 (0)