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

Commit 883a79db authored by Liam, Lee Pong Lam's avatar Liam, Lee Pong Lam
Browse files

[Launcher3] Hide keyboard when fastscroller scrolling down and keyboard

shown

Implement keyboard hiding logic: Hide keyboard when scrolling down (y > mLastY) unless already requested (mRequestedHideKeyboard). Track hide request state to prevent redundant calls.

result video: https://photos.app.goo.gl/e4dYUUiUN3BujNUz9

Bug: 333967597
Flag: EXEMPT bugfix
Test: Manual
Change-Id: I42b9d05dd5368b021577f12541248d434ee22495
parent 59fd8cbf
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -109,6 +109,13 @@ public class RecyclerViewFastScroller extends View {

    private float mLastTouchY;
    private boolean mIsDragging;
    /**
     * Tracks whether a keyboard hide request has been sent due to downward scrolling.
     * <p>
     * Set to true when scrolling down and reset when scrolling up to prevents redundant hide
     * requests during continuous downward scrolls.
     */
    private boolean mRequestedHideKeyboard;
    private boolean mIsThumbDetached;
    private final boolean mCanThumbDetach;
    private boolean mIgnoreDragGesture;
@@ -241,6 +248,7 @@ public class RecyclerViewFastScroller extends View {
    public boolean handleTouchEvent(MotionEvent ev, Point offset) {
        int x = (int) ev.getX() - offset.x;
        int y = (int) ev.getY() - offset.y;
        ActivityContext activityContext = ActivityContext.lookupContext(getContext());

        switch (ev.getAction()) {
            case MotionEvent.ACTION_DOWN:
@@ -248,6 +256,7 @@ public class RecyclerViewFastScroller extends View {
                mDownX = x;
                mDownY = mLastY = y;
                mDownTimeStampMillis = ev.getDownTime();
                mRequestedHideKeyboard = false;

                if ((Math.abs(mDy) < mDeltaThreshold &&
                        mRv.getScrollState() != SCROLL_STATE_IDLE)) {
@@ -260,6 +269,15 @@ public class RecyclerViewFastScroller extends View {
                }
                break;
            case MotionEvent.ACTION_MOVE:
                if (y > mLastY) {
                    if (!mRequestedHideKeyboard) {
                        activityContext.hideKeyboard();
                    }
                    mRequestedHideKeyboard = true;
                } else {
                    mRequestedHideKeyboard = false;
                }

                mLastY = y;
                int absDeltaY = Math.abs(y - mDownY);
                int absDeltaX = Math.abs(x - mDownX);
@@ -294,7 +312,6 @@ public class RecyclerViewFastScroller extends View {
    }

    private void calcTouchOffsetAndPrepToFastScroll(int downY, int lastY) {
        ActivityContext.lookupContext(getContext()).hideKeyboard();
        mIsDragging = true;
        if (mCanThumbDetach) {
            mIsThumbDetached = true;