Fix SwipeDetector positive vs negative for HORIZONTAL direction

Previously left was considered positive and right considered negative.
Now left and down are negative, and right and up are positive.

For RTL, left is positive and right is negative.

Change-Id: Ia31e8c687c8c2716fc632b2fe88aa8955b934bce
This commit is contained in:
Tony
2019-03-22 19:15:39 -05:00
parent e06fef45a4
commit 101807d8e7
4 changed files with 120 additions and 30 deletions

View File

@@ -69,6 +69,7 @@ public abstract class AbstractStateChangeTouchController
protected final Launcher mLauncher;
protected final SwipeDetector mDetector;
protected final SwipeDetector.Direction mSwipeDirection;
private boolean mNoIntercept;
protected int mStartContainerType;
@@ -105,6 +106,7 @@ public abstract class AbstractStateChangeTouchController
public AbstractStateChangeTouchController(Launcher l, SwipeDetector.Direction dir) {
mLauncher = l;
mDetector = new SwipeDetector(l, this, dir);
mSwipeDirection = dir;
}
protected long getAtomicDuration() {
@@ -262,7 +264,8 @@ public abstract class AbstractStateChangeTouchController
float deltaProgress = mProgressMultiplier * (displacement - mDisplacementShift);
float progress = deltaProgress + mStartProgress;
updateProgress(progress);
boolean isDragTowardPositive = (displacement - mDisplacementShift) < 0;
boolean isDragTowardPositive = mSwipeDirection.isPositive(
displacement - mDisplacementShift);
if (progress <= 0) {
if (reinitCurrentAnimation(false, isDragTowardPositive)) {
mDisplacementShift = displacement;