mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 03:08:19 +00:00
Swipe interaction changes on home screen
> Increasing the distance to travel for the first swipe > Adding support for custom interpolators when building an animation > When quickly swiping twice from home, finished the first animation Change-Id: Ibc3c8667e9b927376fd99f08f0ca027f2398914b
This commit is contained in:
@@ -19,6 +19,7 @@ import static com.android.launcher3.anim.Interpolators.scrollInterpolatorForVelo
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
@@ -140,10 +141,14 @@ public abstract class AbstractStateChangeTouchController extends AnimatorListene
|
||||
@Override
|
||||
public boolean onDrag(float displacement, float velocity) {
|
||||
float deltaProgress = mProgressMultiplier * displacement;
|
||||
mCurrentAnimation.setPlayFraction(deltaProgress + mStartProgress);
|
||||
updateProgress(deltaProgress + mStartProgress);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void updateProgress(float fraction) {
|
||||
mCurrentAnimation.setPlayFraction(fraction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDragEnd(float velocity, boolean fling) {
|
||||
final int logAction;
|
||||
@@ -173,7 +178,7 @@ public abstract class AbstractStateChangeTouchController extends AnimatorListene
|
||||
startProgress = 1;
|
||||
} else {
|
||||
startProgress = Utilities.boundToRange(
|
||||
progress + velocity * SINGLE_FRAME_MS / getShiftRange(), 0f, 1f);
|
||||
progress + velocity * SINGLE_FRAME_MS * mProgressMultiplier, 0f, 1f);
|
||||
duration = SwipeDetector.calculateDuration(velocity,
|
||||
endProgress - Math.max(progress, 0));
|
||||
}
|
||||
@@ -184,7 +189,7 @@ public abstract class AbstractStateChangeTouchController extends AnimatorListene
|
||||
startProgress = 0;
|
||||
} else {
|
||||
startProgress = Utilities.boundToRange(
|
||||
progress + velocity * SINGLE_FRAME_MS / getShiftRange(), 0f, 1f);
|
||||
progress + velocity * SINGLE_FRAME_MS * mProgressMultiplier, 0f, 1f);
|
||||
duration = SwipeDetector.calculateDuration(velocity,
|
||||
Math.min(progress, 1) - endProgress);
|
||||
}
|
||||
@@ -193,10 +198,16 @@ public abstract class AbstractStateChangeTouchController extends AnimatorListene
|
||||
mCurrentAnimation.setEndAction(() -> onSwipeInteractionCompleted(targetState, logAction));
|
||||
ValueAnimator anim = mCurrentAnimation.getAnimationPlayer();
|
||||
anim.setFloatValues(startProgress, endProgress);
|
||||
anim.setDuration(duration).setInterpolator(scrollInterpolatorForVelocity(velocity));
|
||||
updateSwipeCompleteAnimation(anim, duration, targetState, velocity, fling);
|
||||
anim.start();
|
||||
}
|
||||
|
||||
protected void updateSwipeCompleteAnimation(ValueAnimator animator, long expectedDuration,
|
||||
LauncherState targetState, float velocity, boolean isFling) {
|
||||
animator.setDuration(expectedDuration)
|
||||
.setInterpolator(scrollInterpolatorForVelocity(velocity));
|
||||
}
|
||||
|
||||
protected int getDirectionForLog() {
|
||||
return mToState.ordinal > mFromState.ordinal ? Direction.UP : Direction.DOWN;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user