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

Commit 79ec120b authored by Tony Wickham's avatar Tony Wickham Committed by Android (Google) Code Review
Browse files

Merge "Fix TaskViewTouchController crash in seascape"

parents d0269cd0 e3386502
Loading
Loading
Loading
Loading
+16 −9
Original line number Diff line number Diff line
@@ -18,8 +18,6 @@ package com.android.launcher3.uioverrides.touchcontrollers;
import static com.android.launcher3.AbstractFloatingView.TYPE_ACCESSIBLE;
import static com.android.launcher3.LauncherAnimUtils.SUCCESS_TRANSITION_PROGRESS;
import static com.android.launcher3.touch.SingleAxisSwipeDetector.DIRECTION_BOTH;
import static com.android.launcher3.touch.SingleAxisSwipeDetector.DIRECTION_NEGATIVE;
import static com.android.launcher3.touch.SingleAxisSwipeDetector.DIRECTION_POSITIVE;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -59,6 +57,8 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>

    private AnimatorPlaybackController mCurrentAnimation;
    private boolean mCurrentAnimationIsGoingUp;
    private boolean mAllowGoingUp;
    private boolean mAllowGoingDown;

    private boolean mNoIntercept;

@@ -74,7 +74,7 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
        mRecentsView = activity.getOverviewPanel();
        mIsRtl = Utilities.isRtl(activity.getResources());
        SingleAxisSwipeDetector.Direction dir =
            mRecentsView.getPagedOrientationHandler().getOppositeSwipeDirection();
                mRecentsView.getPagedOrientationHandler().getUpDownSwipeDirection();
        mDetector = new SingleAxisSwipeDetector(activity, this, dir);
    }

@@ -148,15 +148,24 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
                            break;
                        }
                        mTaskBeingDragged = view;
                        int upDirection = mRecentsView.getPagedOrientationHandler()
                                .getUpDirection(mIsRtl);
                        if (!SysUINavigationMode.getMode(mActivity).hasGestures) {
                            // Don't allow swipe down to open if we don't support swipe up
                            // to enter overview.
                            directionsToDetectScroll = DIRECTION_POSITIVE;
                            directionsToDetectScroll = upDirection;
                            mAllowGoingUp = true;
                            mAllowGoingDown = false;
                        } else {
                            // The task can be dragged up to dismiss it,
                            // and down to open if it's the current page.
                            directionsToDetectScroll = i == mRecentsView.getCurrentPage()
                                    ? DIRECTION_BOTH : DIRECTION_POSITIVE;
                            mAllowGoingUp = true;
                            if (i == mRecentsView.getCurrentPage()) {
                                mAllowGoingDown = true;
                                directionsToDetectScroll = DIRECTION_BOTH;
                            } else {
                                directionsToDetectScroll = upDirection;
                            }
                        }
                        break;
                    }
@@ -189,9 +198,7 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
            // No need to init
            return;
        }
        int scrollDirections = mDetector.getScrollDirections();
        if (goingUp && ((scrollDirections & DIRECTION_POSITIVE) == 0)
                || !goingUp && ((scrollDirections & DIRECTION_NEGATIVE) == 0)) {
        if ((goingUp && !mAllowGoingUp) || (!goingUp && !mAllowGoingDown)) {
            // Trying to re-init in an unsupported direction.
            return;
        }
+25 −15
Original line number Diff line number Diff line
@@ -74,11 +74,6 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
        out.screenCenter = insets.top + view.getPaddingTop() + out.scroll + out.halfPageSize;
    }

    @Override
    public boolean isGoingUp(float displacement, boolean isRtl) {
        return isRtl ? displacement < 0 : displacement > 0;
    }

    @Override
    public boolean isLayoutNaturalToLauncher() {
        return false;
@@ -214,11 +209,6 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
        return view.getHeight() - view.getPaddingBottom() - insets.bottom;
    }

    @Override
    public SingleAxisSwipeDetector.Direction getOppositeSwipeDirection() {
        return HORIZONTAL;
    }

    @Override
    public int getPrimaryTranslationDirectionFactor() {
        return -1;
@@ -228,11 +218,6 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
        return 1;
    }

    @Override
    public int getTaskDragDisplacementFactor(boolean isRtl) {
        return isRtl ? 1 : -1;
    }

    @Override
    public float getTaskMenuX(float x, View thumbnailView) {
        return thumbnailView.getMeasuredWidth() + x;
@@ -261,6 +246,31 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
        lp.weight = 1;
    }

    /* ---------- The following are only used by TaskViewTouchHandler. ---------- */

    @Override
    public SingleAxisSwipeDetector.Direction getUpDownSwipeDirection() {
        return HORIZONTAL;
    }

    @Override
    public int getUpDirection(boolean isRtl) {
        return isRtl ? SingleAxisSwipeDetector.DIRECTION_NEGATIVE
                : SingleAxisSwipeDetector.DIRECTION_POSITIVE;
    }

    @Override
    public boolean isGoingUp(float displacement, boolean isRtl) {
        return isRtl ? displacement < 0 : displacement > 0;
    }

    @Override
    public int getTaskDragDisplacementFactor(boolean isRtl) {
        return isRtl ? 1 : -1;
    }

    /* -------------------- */

    @Override
    public ChildBounds getChildBounds(View child, int childStart, int pageCenter,
        boolean layoutChild) {
+10 −3
Original line number Diff line number Diff line
@@ -75,10 +75,8 @@ public interface PagedOrientationHandler {
    int getCenterForPage(View view, Rect insets);
    int getScrollOffsetStart(View view, Rect insets);
    int getScrollOffsetEnd(View view, Rect insets);
    SingleAxisSwipeDetector.Direction getOppositeSwipeDirection();
    int getPrimaryTranslationDirectionFactor();
    int getSecondaryTranslationDirectionFactor();
    int getTaskDragDisplacementFactor(boolean isRtl);
    ChildBounds getChildBounds(View child, int childStart, int pageCenter, boolean layoutChild);
    void setMaxScroll(AccessibilityEvent event, int maxScroll);
    boolean getRecentsRtlSetting(Resources resources);
@@ -92,7 +90,6 @@ public interface PagedOrientationHandler {
    void delegateScrollBy(PagedView pagedView, int unboundedScroll, int x, int y);
    void scrollerStartScroll(OverScroller scroller, int newPosition);
    void getCurveProperties(PagedView view, Rect insets, CurveProperties out);
    boolean isGoingUp(float displacement, boolean isRtl);
    boolean isLayoutNaturalToLauncher();
    float getTaskMenuX(float x, View thumbnailView);
    float getTaskMenuY(float y, View thumbnailView);
@@ -101,6 +98,16 @@ public interface PagedOrientationHandler {
    void setLayoutParamsForTaskMenuOptionItem(LinearLayout.LayoutParams lp);
    int getDistanceToBottomOfRect(DeviceProfile dp, Rect rect);

    // The following are only used by TaskViewTouchHandler.
    /** @return Either VERTICAL or HORIZONTAL. */
    SingleAxisSwipeDetector.Direction getUpDownSwipeDirection();
    /** @return Given {@link #getUpDownSwipeDirection()}, whether POSITIVE or NEGATIVE is up. */
    int getUpDirection(boolean isRtl);
    /** @return Whether the displacement is going towards the top of the screen. */
    boolean isGoingUp(float displacement, boolean isRtl);
    /** @return Either 1 or -1, a factor to multiply by so the animation goes the correct way. */
    int getTaskDragDisplacementFactor(boolean isRtl);

    /**
     * Maps the velocity from the coordinate plane of the foreground app to that
     * of Launcher's (which now will always be portrait)
+27 −17
Original line number Diff line number Diff line
@@ -72,12 +72,6 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler {
        out.screenCenter = insets.left + view.getPaddingLeft() + out.scroll + out.halfPageSize;
    }

    @Override
    public boolean isGoingUp(float displacement, boolean isRtl) {
        // Ignore rtl since it only affects X value displacement, Y displacement doesn't change
        return displacement < 0;
    }

    @Override
    public boolean isLayoutNaturalToLauncher() {
        return true;
@@ -211,11 +205,6 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler {
        return view.getWidth() - view.getPaddingRight() - insets.right;
    }

    @Override
    public SingleAxisSwipeDetector.Direction getOppositeSwipeDirection() {
        return VERTICAL;
    }

    @Override
    public int getPrimaryTranslationDirectionFactor() {
        return 1;
@@ -225,12 +214,6 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler {
        return -1;
    }

    @Override
    public int getTaskDragDisplacementFactor(boolean isRtl) {
        // Ignore rtl since it only affects X value displacement, Y displacement doesn't change
        return 1;
    }

    @Override
    public float getTaskMenuX(float x, View thumbnailView) {
        return x;
@@ -257,6 +240,33 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler {
        // no-op, defaults are fine
    }

    /* ---------- The following are only used by TaskViewTouchHandler. ---------- */

    @Override
    public SingleAxisSwipeDetector.Direction getUpDownSwipeDirection() {
        return VERTICAL;
    }

    @Override
    public int getUpDirection(boolean isRtl) {
        // Ignore rtl since it only affects X value displacement, Y displacement doesn't change
        return SingleAxisSwipeDetector.DIRECTION_POSITIVE;
    }

    @Override
    public boolean isGoingUp(float displacement, boolean isRtl) {
        // Ignore rtl since it only affects X value displacement, Y displacement doesn't change
        return displacement < 0;
    }

    @Override
    public int getTaskDragDisplacementFactor(boolean isRtl) {
        // Ignore rtl since it only affects X value displacement, Y displacement doesn't change
        return 1;
    }

    /* -------------------- */

    @Override
    public ChildBounds getChildBounds(View child, int childStart, int pageCenter,
        boolean layoutChild) {
+27 −10
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.launcher3.touch;

import static com.android.launcher3.touch.SingleAxisSwipeDetector.HORIZONTAL;

import android.content.res.Resources;
import android.graphics.PointF;
import android.graphics.Rect;
@@ -32,11 +34,6 @@ public class SeascapePagedViewHandler extends LandscapePagedViewHandler {
        return -1;
    }

    @Override
    public int getTaskDragDisplacementFactor(boolean isRtl) {
        return isRtl ? -1 : 1;
    }

    @Override
    public boolean getRecentsRtlSetting(Resources resources) {
        return Utilities.isRtl(resources);
@@ -52,11 +49,6 @@ public class SeascapePagedViewHandler extends LandscapePagedViewHandler {
        return Surface.ROTATION_270;
    }

    @Override
    public boolean isGoingUp(float displacement, boolean isRtl) {
        return isRtl ? displacement > 0 : displacement < 0;
    }

    @Override
    public void adjustFloatingIconStartVelocity(PointF velocity) {
        float oldX = velocity.x;
@@ -78,4 +70,29 @@ public class SeascapePagedViewHandler extends LandscapePagedViewHandler {
    public int getDistanceToBottomOfRect(DeviceProfile dp, Rect rect) {
        return dp.widthPx - rect.right;
    }

    /* ---------- The following are only used by TaskViewTouchHandler. ---------- */

    @Override
    public SingleAxisSwipeDetector.Direction getUpDownSwipeDirection() {
        return HORIZONTAL;
    }

    @Override
    public int getUpDirection(boolean isRtl) {
        return isRtl ? SingleAxisSwipeDetector.DIRECTION_POSITIVE
                : SingleAxisSwipeDetector.DIRECTION_NEGATIVE;
    }

    @Override
    public boolean isGoingUp(float displacement, boolean isRtl) {
        return isRtl ? displacement > 0 : displacement < 0;
    }

    @Override
    public int getTaskDragDisplacementFactor(boolean isRtl) {
        return isRtl ? -1 : 1;
    }

    /* -------------------- */
}
Loading