diff options
author | Hyunyoung Song <hyunyoungs@google.com> | 2022-06-04 05:10:48 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2022-06-04 05:10:48 +0000 |
commit | d4a79eb99b9e98f901e1b4e244d7bfcc2b9d1c09 (patch) | |
tree | 61bba2c4119f953b2ad2964c863d6139ac9f6eac | |
parent | c012085c6c6e1bef19d23bcfb8b0883a8d258dd6 (diff) | |
parent | d7a02ec7ae1b4e0309910e494319925c47c2059f (diff) | |
download | Launcher3-d4a79eb99b9e98f901e1b4e244d7bfcc2b9d1c09.tar.gz |
Merge "Fix IME hiding animation being delayed after unlocking the device" into tm-dev
-rw-r--r-- | src/com/android/launcher3/ExtendedEditText.java | 1 | ||||
-rw-r--r-- | src/com/android/launcher3/util/UiThreadHelper.java | 29 |
2 files changed, 29 insertions, 1 deletions
diff --git a/src/com/android/launcher3/ExtendedEditText.java b/src/com/android/launcher3/ExtendedEditText.java index 3b5b454bc1..4629ca7a2b 100644 --- a/src/com/android/launcher3/ExtendedEditText.java +++ b/src/com/android/launcher3/ExtendedEditText.java @@ -104,6 +104,7 @@ public class ExtendedEditText extends EditText { public void hideKeyboard() { hideKeyboardAsync(ActivityContext.lookupContext(getContext()), getWindowToken()); + clearFocus(); } private boolean showSoftInput() { diff --git a/src/com/android/launcher3/util/UiThreadHelper.java b/src/com/android/launcher3/util/UiThreadHelper.java index a1f31fe459..8df3f8a129 100644 --- a/src/com/android/launcher3/util/UiThreadHelper.java +++ b/src/com/android/launcher3/util/UiThreadHelper.java @@ -25,9 +25,13 @@ import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; +import android.util.Log; import android.view.View; +import android.view.WindowInsets; +import android.view.WindowInsetsController; import android.view.inputmethod.InputMethodManager; +import com.android.launcher3.Utilities; import com.android.launcher3.views.ActivityContext; /** @@ -48,6 +52,29 @@ public class UiThreadHelper { public static void hideKeyboardAsync(ActivityContext activityContext, IBinder token) { View root = activityContext.getDragLayer(); + if (Utilities.ATLEAST_R) { + Preconditions.assertUIThread(); + // Hide keyboard with WindowInsetsController if could. In case + // hideSoftInputFromWindow may get ignored by input connection being finished + // when the screen is off. + // + // In addition, inside IMF, the keyboards are closed asynchronously that launcher no + // longer need to post to the message queue. + final WindowInsetsController wic = root.getWindowInsetsController(); + WindowInsets insets = root.getRootWindowInsets(); + boolean isImeShown = insets != null && insets.isVisible(WindowInsets.Type.ime()); + if (wic != null && isImeShown) { + // this method cannot be called cross threads + wic.hide(WindowInsets.Type.ime()); + activityContext.getStatsLogManager().logger() + .log(LAUNCHER_ALLAPPS_KEYBOARD_CLOSED); + return; + } else { + // print which stack trace failed. + Log.e("Launcher", "hideKeyboard ignored.", new Exception()); + // Then attempt to use the old logic. + } + } // Since the launcher context cannot be accessed directly from callback, adding secondary // message to log keyboard close event asynchronously. Bundle mHideKeyboardLoggerMsg = new Bundle(); @@ -55,7 +82,7 @@ public class UiThreadHelper { STATS_LOGGER_KEY, Message.obtain( HANDLER.get(root.getContext()), - () -> ActivityContext.lookupContext(root.getContext()) + () -> activityContext .getStatsLogManager() .logger() .log(LAUNCHER_ALLAPPS_KEYBOARD_CLOSED) |