From 29aef52be370b7235a4d9442d4b023e42a732c5b Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Mon, 11 Jun 2018 16:05:31 -0700 Subject: [PATCH] Fix some issues with haptic - Don't have double haptic on quick scrub - Correctly check interpolated progress to determine final state, so that it always aligns with the haptic (i.e. passing the haptic means letting go will go to the new state) Bug: 109709720 Change-Id: I702bb76a4c15f932f923e81a14cc49f6a9126cb8 --- .../launcher3/uioverrides/TaskViewTouchController.java | 6 +++--- .../android/quickstep/WindowTransformSwipeHandler.java | 2 +- .../launcher3/anim/AnimatorPlaybackController.java | 8 +++++++- .../touch/AbstractStateChangeTouchController.java | 4 +++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/TaskViewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/TaskViewTouchController.java index a40573500f..705eabab90 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/TaskViewTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/TaskViewTouchController.java @@ -241,16 +241,16 @@ public abstract class TaskViewTouchController if (blockedFling) { fling = false; } + float progress = mCurrentAnimation.getProgressFraction(); + float interpolatedProgress = mCurrentAnimation.getInterpolator().getInterpolation(progress); if (fling) { logAction = Touch.FLING; boolean goingUp = velocity < 0; goingToEnd = goingUp == mCurrentAnimationIsGoingUp; } else { logAction = Touch.SWIPE; - goingToEnd = mCurrentAnimation.getProgressFraction() > SUCCESS_TRANSITION_PROGRESS; + goingToEnd = interpolatedProgress > SUCCESS_TRANSITION_PROGRESS; } - - float progress = mCurrentAnimation.getProgressFraction(); long animationDuration = SwipeDetector.calculateDuration( velocity, goingToEnd ? (1 - progress) : progress); if (blockedFling && !goingToEnd) { diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java index c9f94bdb5d..532699e2e0 100644 --- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java @@ -575,7 +575,7 @@ public class WindowTransformSwipeHandler { final boolean passed = mCurrentShift.value >= MIN_PROGRESS_FOR_OVERVIEW; if (passed != mPassedOverviewThreshold) { mPassedOverviewThreshold = passed; - if (mRecentsView != null) { + if (mInteractionType == INTERACTION_NORMAL && mRecentsView != null) { mRecentsView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); } diff --git a/src/com/android/launcher3/anim/AnimatorPlaybackController.java b/src/com/android/launcher3/anim/AnimatorPlaybackController.java index 50fb0a51a8..164728ae67 100644 --- a/src/com/android/launcher3/anim/AnimatorPlaybackController.java +++ b/src/com/android/launcher3/anim/AnimatorPlaybackController.java @@ -15,6 +15,8 @@ */ package com.android.launcher3.anim; +import static com.android.launcher3.anim.Interpolators.LINEAR; + import android.animation.Animator; import android.animation.Animator.AnimatorListener; import android.animation.AnimatorListenerAdapter; @@ -72,7 +74,7 @@ public abstract class AnimatorPlaybackController implements ValueAnimator.Animat mOnCancelRunnable = onCancelRunnable; mAnimationPlayer = ValueAnimator.ofFloat(0, 1); - mAnimationPlayer.setInterpolator(Interpolators.LINEAR); + mAnimationPlayer.setInterpolator(LINEAR); mAnimationPlayer.addListener(new OnAnimationEndDispatcher()); mAnimationPlayer.addUpdateListener(this); @@ -107,6 +109,10 @@ public abstract class AnimatorPlaybackController implements ValueAnimator.Animat return mDuration; } + public TimeInterpolator getInterpolator() { + return mAnim.getInterpolator() != null ? mAnim.getInterpolator() : LINEAR; + } + /** * Starts playing the animation forward from current position. */ diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java index ff3b425908..b1fef0240c 100644 --- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java +++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java @@ -354,6 +354,8 @@ public abstract class AbstractStateChangeTouchController final LauncherState targetState; final float progress = mCurrentAnimation.getProgressFraction(); + final float interpolatedProgress = mCurrentAnimation.getInterpolator() + .getInterpolation(progress); if (fling) { targetState = Float.compare(Math.signum(velocity), Math.signum(mProgressMultiplier)) == 0 @@ -362,7 +364,7 @@ public abstract class AbstractStateChangeTouchController } else { float successProgress = mToState == ALL_APPS ? MIN_PROGRESS_TO_ALL_APPS : SUCCESS_TRANSITION_PROGRESS; - targetState = (progress > successProgress) ? mToState : mFromState; + targetState = (interpolatedProgress > successProgress) ? mToState : mFromState; } final float endProgress;