[QL-v2] Reset input state on scroll and restore state on scrolling back.

Bug: 261872461
Test: see video in bug
Change-Id: I18e1923bdd4c40e84e46579296b69268d46c9fa1
This commit is contained in:
Holly Sun
2022-12-08 14:05:37 -08:00
parent 9a6a2c8a2d
commit 196d55aa77
2 changed files with 27 additions and 6 deletions
@@ -41,12 +41,23 @@ public class LauncherAllAppsContainerView extends ActivityAllAppsContainerView<L
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
int scrolledOffset = recyclerView.computeVerticalScrollOffset();
ExtendedEditText input = mSearchUiManager.getEditText();
// Scroll up and scroll to top
if (dy < 0 && scrolledOffset == 0 && input != null) {
boolean isImeEnabledOnSwipeUp = Launcher.getLauncher(mActivityContext)
.getSearchConfig().isImeEnabledOnSwipeUp();
if (isImeEnabledOnSwipeUp || !TextUtils.isEmpty(input.getText())) {
input.showKeyboard();
if (input != null) {
// Save the input box state on scroll down
if (dy > 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();
}
}
}