Merge "[QL-v2] Reset input state on scroll and restore state on scrolling back." into tm-qpr-dev am: 80872f32da

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/20683467

Change-Id: I7d29b2982b7a69aea1e2104915aecf6af9758671
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Holly Jiuyu Sun
2022-12-14 17:37:44 +00:00
committed by Automerger Merge Worker
2 changed files with 27 additions and 6 deletions
@@ -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() {}
}
@@ -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();
}
}
}