Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 80872f32 authored by Holly Jiuyu Sun's avatar Holly Jiuyu Sun Committed by Android (Google) Code Review
Browse files

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

parents 5c1eb613 196d55aa
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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() {}
}
+17 −6
Original line number Diff line number Diff line
@@ -41,13 +41,24 @@ public class LauncherAllAppsContainerView extends ActivityAllAppsContainerView<L
                public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
                    int scrolledOffset = recyclerView.computeVerticalScrollOffset();
                    ExtendedEditText input = mSearchUiManager.getEditText();
                    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 && input != null) {
                        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();
                        }
                    }
                }
            };