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

Commit e9127422 authored by Jon Miranda's avatar Jon Miranda Committed by Android (Google) Code Review
Browse files

Merge "Prevent x-axis window movement during the initial swipe up to show...

Merge "Prevent x-axis window movement during the initial swipe up to show transient taskbar" into tm-qpr-dev
parents c9c45ed7 08be3775
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -289,6 +289,8 @@
    <dimen name="transient_taskbar_key_shadow_distance">10dp</dimen>
    <dimen name="transient_taskbar_stashed_size">32dp</dimen>
    <dimen name="transient_taskbar_icon_spacing">10dp</dimen>
    <!-- An additional touch slop to prevent x-axis movement during the swipe up to show taskbar -->
    <dimen name="transient_taskbar_clamped_offset_bound">16dp</dimen>
    <!-- Taskbar swipe up thresholds -->
    <dimen name="taskbar_app_window_threshold">150dp</dimen>
    <dimen name="taskbar_home_overview_threshold">225dp</dimen>
+15 −0
Original line number Diff line number Diff line
@@ -755,6 +755,21 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
        }
    }

    /**
     * Sets whether or not we should clamp the scroll offset.
     * This is used to avoid x-axis movement when swiping up transient taskbar.
     * @param clampScrollOffset When true, we clamp the scroll to 0 before the clamp threshold is
     *                          met.
     */
    public void setClampScrollOffset(boolean clampScrollOffset) {
        if (mRecentsView == null) {
            mStateCallback.runOnceAtState(STATE_LAUNCHER_PRESENT,
                    () -> mRecentsView.setClampScrollOffset(clampScrollOffset));
            return;
        }
        mRecentsView.setClampScrollOffset(clampScrollOffset);
    }

    public void setIsLikelyToStartNewTask(boolean isLikelyToStartNewTask) {
        setIsLikelyToStartNewTask(
                isLikelyToStartNewTask,
+6 −0
Original line number Diff line number Diff line
@@ -378,6 +378,9 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
        mInteractionHandler.onGestureStarted(isLikelyToStartNewTask);

        mInteractionHandler.setTaskbarAlreadyOpen(mTaskbarAlreadyOpen);
        if (mIsTransientTaskbar && !mTaskbarAlreadyOpen && !isLikelyToStartNewTask) {
            mInteractionHandler.setClampScrollOffset(true);
        }
    }

    private void startTouchTrackingForWindowAnimation(long touchTimeMs) {
@@ -473,6 +476,9 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
    @UiThread
    private void onInteractionGestureFinished() {
        Preconditions.assertUIThread();
        if (mInteractionHandler != null) {
            mInteractionHandler.setClampScrollOffset(false);
        }
        removeListener();
        mInteractionHandler = null;
        cleanupAfterGesture();
+31 −0
Original line number Diff line number Diff line
@@ -498,6 +498,9 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
    private boolean mOverviewFullscreenEnabled;
    private boolean mOverviewSelectEnabled;

    private boolean mShouldClampScrollOffset;
    private int mClampedScrollOffsetBound;

    private float mAdjacentPageHorizontalOffset = 0;
    protected float mTaskViewsSecondaryTranslation = 0;
    protected float mTaskViewsPrimarySplitTranslation = 0;
@@ -752,6 +755,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
        mSplitPlaceholderInset = getResources().getDimensionPixelSize(
                R.dimen.split_placeholder_inset);
        mSquaredTouchSlop = squaredTouchSlop(context);
        mClampedScrollOffsetBound = getResources().getDimensionPixelSize(
                R.dimen.transient_taskbar_clamped_offset_bound);

        mEmptyIcon = context.getDrawable(R.drawable.ic_empty_recents);
        mEmptyIcon.setCallback(this);
@@ -5054,10 +5059,36 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
        return getScrollOffset(getRunningTaskIndex());
    }

    /**
     * Sets whether or not we should clamp the scroll offset.
     * This is used to avoid x-axis movement when swiping up transient taskbar.
     * Should only be set at the beginning and end of the gesture, otherwise a jump may occur.
     * @param clampScrollOffset When true, we clamp the scroll to 0 before the clamp threshold is
     *                          met.
     */
    public void setClampScrollOffset(boolean clampScrollOffset) {
        mShouldClampScrollOffset = clampScrollOffset;
    }

    /**
     * Returns how many pixels the page is offset on the currently laid out dominant axis.
     */
    public int getScrollOffset(int pageIndex) {
        int unboundedOffset = getUnclampedScrollOffset(pageIndex);
        if (!mShouldClampScrollOffset) {
            return unboundedOffset;
        }
        if (Math.abs(unboundedOffset) < mClampedScrollOffsetBound) {
            return 0;
        }
        return unboundedOffset
                - Math.round(Math.signum(unboundedOffset) * mClampedScrollOffsetBound);
    }

    /**
     * Returns how many pixels the page is offset on the currently laid out dominant axis.
     */
    private int getUnclampedScrollOffset(int pageIndex) {
        if (pageIndex == -1) {
            return 0;
        }
+1 −0
Original line number Diff line number Diff line
@@ -368,6 +368,7 @@
    <dimen name="transient_taskbar_shadow_blur">0dp</dimen>
    <dimen name="transient_taskbar_key_shadow_distance">0dp</dimen>
    <dimen name="transient_taskbar_stashed_size">0dp</dimen>
    <dimen name="transient_taskbar_clamped_offset_bound">0dp</dimen>
    <!-- Note that this applies to both sides of all icons, so visible space is double this. -->
    <dimen name="transient_taskbar_icon_spacing">0dp</dimen>
    <!-- Note that this applies to both sides of all icons, so visible space is double this. -->