From 196d55aa77ea7a092d7c11af72f5f1d35abb616b Mon Sep 17 00:00:00 2001 From: Holly Sun Date: Thu, 8 Dec 2022 14:05:37 -0800 Subject: [PATCH] [QL-v2] Reset input state on scroll and restore state on scrolling back. Bug: 261872461 Test: see video in bug Change-Id: I18e1923bdd4c40e84e46579296b69268d46c9fa1 --- .../android/launcher3/ExtendedEditText.java | 10 ++++++++ .../allapps/LauncherAllAppsContainerView.java | 23 ++++++++++++++----- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/com/android/launcher3/ExtendedEditText.java b/src/com/android/launcher3/ExtendedEditText.java index c59f25d85a..f94a3c5521 100644 --- a/src/com/android/launcher3/ExtendedEditText.java +++ b/src/com/android/launcher3/ExtendedEditText.java @@ -159,4 +159,14 @@ public class ExtendedEditText extends EditText { listener.onFocusChange(this, focused); } } + + /** + * Save the input, suggestion, hint states when it's on focus, and set to unfocused states. + */ + public void saveFocusedStateAndUpdateToUnfocusedState() {} + + /** + * Restore to the previous saved focused state. + */ + public void restoreToFocusedState() {} } diff --git a/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java b/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java index 92e29bbdf5..229d8f81e2 100644 --- a/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java @@ -41,12 +41,23 @@ public class LauncherAllAppsContainerView extends ActivityAllAppsContainerView 0) { + input.saveFocusedStateAndUpdateToUnfocusedState(); + } + + // Scroll up and scroll to top + if (dy < 0 && scrolledOffset == 0) { + // Show keyboard + boolean isImeEnabledOnSwipeUp = Launcher.getLauncher(mActivityContext) + .getSearchConfig().isImeEnabledOnSwipeUp(); + if (isImeEnabledOnSwipeUp || !TextUtils.isEmpty(input.getText())) { + input.showKeyboard(); + } + + // Restore state in input box + input.restoreToFocusedState(); } } }