From d5d6db78d243c7fe49e715120f99784041bfa976 Mon Sep 17 00:00:00 2001 From: Ming-Shin Lu Date: Tue, 4 Jan 2022 20:55:14 +0800 Subject: Fix Keyboard not hiding when dismissing remote input from shade In RemoteInputView will invoke hideSoftInputFromWindow when the editor view is invisble. However, the timing will be after the editor view lost focus, so that in hideSoftInputFromWindow will ignore the request since the editor view has been detached. As the notification shade is still focused, fix it by calling getWindowController().hide(ime()) when the IME is visible. Fix: 209925343 Test: manul as steps: 1) Make/install EditTextVariations 2) Launch EditTextVariations app, select "Direct-Reply" from menu. 3) after direct-reply notificaion popup, scroll down the notification panel. 4) Tap "Direct Reply Test" button on the notification to show IME. 5) Swipe out direct-reply notification to remove 6) Expect IME will be hidden Change-Id: I6739d3bd6ad7dbaa4c0d430c57d1167644cf8584 --- .../com/android/systemui/statusbar/policy/RemoteInputView.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java index 46fa20d094a0..48949f92413d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java @@ -51,6 +51,7 @@ import android.view.ViewAnimationUtils; import android.view.ViewGroup; import android.view.WindowInsets; import android.view.WindowInsetsAnimation; +import android.view.WindowInsetsController; import android.view.accessibility.AccessibilityEvent; import android.view.inputmethod.CompletionInfo; import android.view.inputmethod.EditorInfo; @@ -665,8 +666,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene } // Hide soft-keyboard when the input view became invisible // (i.e. The notification shade collapsed by pressing the home key) - if (visibility != VISIBLE && !mEditText.isVisibleToUser() - && !mController.isRemoteInputActive()) { + if (visibility != VISIBLE && !mController.isRemoteInputActive()) { mEditText.hideIme(); } } @@ -779,8 +779,9 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene } private void hideIme() { - if (mInputMethodManager != null) { - mInputMethodManager.hideSoftInputFromWindow(getWindowToken(), 0); + final WindowInsetsController insetsController = getWindowInsetsController(); + if (insetsController != null) { + insetsController.hide(WindowInsets.Type.ime()); } } -- cgit v1.2.3-59-g8ed1b