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

Commit 6811fe8a authored by Jon Miranda's avatar Jon Miranda
Browse files

Fix window x-axis movement after gesture ends.

Previously we setClamp to false right after the gesture ends.
So when the page settle animation gets the page offset, it would
get the unclamped version which would cause the window to move
in the x-axis movement even if the window didn't actually move
during the gesture.

Now we ensure that we setClamp to false after the page transition
ends so that the scroll offset is consistent all the way until
the end of the animation.

Bug: 258851206
Test: 1. swipe a bit diagonally to bring up taskbar with
         no x-axis window movement
      2. release
      3. there should be no x-axis movement on window

Change-Id: Ic9949d11f2e8bc7ccbd737555a3d5551f09456da
parent b0ed7dae
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -1204,7 +1204,6 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
        final GestureEndTarget endTarget = calculateEndTarget(velocity, endVelocity,
                isFling, isCancel);

        setClampScrollOffset(false);
        // Set the state, but don't notify until the animation completes
        mGestureState.setEndTarget(endTarget, false /* isAtomic */);
        mAnimationFactory.setEndTarget(endTarget);
@@ -1282,13 +1281,16 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,

        // Let RecentsView handle the scrolling to the task, which we launch in startNewTask()
        // or resumeLastTask().
        Runnable onPageTransitionEnd = () -> {
            mGestureState.setState(STATE_RECENTS_SCROLLING_FINISHED);
            setClampScrollOffset(false);
        };
        if (mRecentsView != null) {
            ActiveGestureLog.INSTANCE.trackEvent(ActiveGestureErrorDetector.GestureEvent
                    .SET_ON_PAGE_TRANSITION_END_CALLBACK);
            mRecentsView.setOnPageTransitionEndCallback(
                    () -> mGestureState.setState(STATE_RECENTS_SCROLLING_FINISHED));
            mRecentsView.setOnPageTransitionEndCallback(onPageTransitionEnd);
        } else {
            mGestureState.setState(STATE_RECENTS_SCROLLING_FINISHED);
            onPageTransitionEnd.run();
        }

        animateToProgress(startShift, endShift, duration, interpolator, endTarget, velocity);
+5 −5
Original line number Diff line number Diff line
@@ -5072,15 +5072,15 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
     * Returns how many pixels the page is offset on the currently laid out dominant axis.
     */
    public int getScrollOffset(int pageIndex) {
        int unboundedOffset = getUnclampedScrollOffset(pageIndex);
        int unclampedOffset = getUnclampedScrollOffset(pageIndex);
        if (!mShouldClampScrollOffset) {
            return unboundedOffset;
            return unclampedOffset;
        }
        if (Math.abs(unboundedOffset) < mClampedScrollOffsetBound) {
        if (Math.abs(unclampedOffset) < mClampedScrollOffsetBound) {
            return 0;
        }
        return unboundedOffset
                - Math.round(Math.signum(unboundedOffset) * mClampedScrollOffsetBound);
        return unclampedOffset
                - Math.round(Math.signum(unclampedOffset) * mClampedScrollOffsetBound);
    }

    /**