summaryrefslogtreecommitdiffstats
path: root/quickstep/src
diff options
context:
space:
mode:
authorTony <twickham@google.com>2018-04-27 12:33:24 -0500
committerTony <twickham@google.com>2018-05-01 13:45:27 -0500
commit31fbd4c08ba9257ea2f85732c4d00b127d65875c (patch)
tree6ddf8621e78f8fb5e77e8372812d879f380c84fd /quickstep/src
parent3aa3eb51e2403a5f18ba1b16c574127405252a07 (diff)
downloadandroid_packages_apps_Trebuchet-31fbd4c08ba9257ea2f85732c4d00b127d65875c.tar.gz
android_packages_apps_Trebuchet-31fbd4c08ba9257ea2f85732c4d00b127d65875c.tar.bz2
android_packages_apps_Trebuchet-31fbd4c08ba9257ea2f85732c4d00b127d65875c.zip
Fix some state issues with user-controlled animations
Previously, user-controlled animations weren't properly being canceled when a non-user-controlled animation started, e.g. when hitting home. Thus, we could end in the wrong or inconsistent state because the user-controlled animation's end runnable was still used. Now we add a cleanup callback for when we reset the user-controlled animation for one that isn't user-controlled. Also fixed a couple typos. Tests (easier with animation durations extended): - Swipe up and hit home before reaching overview -> land on home - Go to overview, swipe down slightly (before threshold to go to workspace) and let go -> return to overview without flash (recents was resetting) - Swipe up, press home while swiping -> goes home, stops responding to drag - Start dismissing task and hit home before it finishes (or while dragging) -> goes home, stops responding to drag Bug: 78249220 Change-Id: If11d8999e3fadba38c987b25af67cd2304cd859b
Diffstat (limited to 'quickstep/src')
-rw-r--r--quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java22
-rw-r--r--quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java2
-rw-r--r--quickstep/src/com/android/launcher3/uioverrides/TaskViewTouchController.java21
-rw-r--r--quickstep/src/com/android/launcher3/uioverrides/UiFactory.java16
4 files changed, 46 insertions, 15 deletions
diff --git a/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java
index 2e95c04e3..2a603d763 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java
@@ -187,10 +187,7 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr
builder = new AnimatorSetBuilder();
}
- if (mPendingAnimation != null) {
- mPendingAnimation.finish(false, Touch.SWIPE);
- mPendingAnimation = null;
- }
+ cancelPendingAnim();
RecentsView recentsView = mLauncher.getOverviewPanel();
TaskView taskView = (TaskView) recentsView.getChildAt(recentsView.getNextPage());
@@ -199,10 +196,16 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr
mPendingAnimation = recentsView.createTaskLauncherAnimation(taskView, maxAccuracy);
mPendingAnimation.anim.setInterpolator(Interpolators.ZOOM_IN);
- mCurrentAnimation = AnimatorPlaybackController.wrap(mPendingAnimation.anim, maxAccuracy);
+ Runnable onCancelRunnable = () -> {
+ cancelPendingAnim();
+ clearState();
+ };
+ mCurrentAnimation = AnimatorPlaybackController.wrap(mPendingAnimation.anim, maxAccuracy,
+ onCancelRunnable);
+ mLauncher.getStateManager().setCurrentUserControlledAnimation(mCurrentAnimation);
} else {
mCurrentAnimation = mLauncher.getStateManager()
- .createAnimationToNewWorkspace(mToState, builder, maxAccuracy);
+ .createAnimationToNewWorkspace(mToState, builder, maxAccuracy, this::clearState);
}
if (totalShift == 0) {
@@ -212,6 +215,13 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr
return 1 / totalShift;
}
+ private void cancelPendingAnim() {
+ if (mPendingAnimation != null) {
+ mPendingAnimation.finish(false, Touch.SWIPE);
+ mPendingAnimation = null;
+ }
+ }
+
@Override
protected void updateSwipeCompleteAnimation(ValueAnimator animator, long expectedDuration,
LauncherState targetState, float velocity, boolean isFling) {
diff --git a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
index 49d493145..2579bc293 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
@@ -63,7 +63,7 @@ public class RecentsViewStateController implements StateHandler {
@Override
public void setStateWithAnimation(final LauncherState toState,
AnimatorSetBuilder builder, AnimationConfig config) {
- PropertySetter setter = config.getProperSetter(builder);
+ PropertySetter setter = config.getPropertySetter(builder);
float[] scaleTranslationYFactor = toState.getOverviewScaleAndTranslationYFactor(mLauncher);
setter.setFloat(mRecentsView, ADJACENT_SCALE, scaleTranslationYFactor[0],
builder.getInterpolator(ANIM_OVERVIEW_TRANSLATION, LINEAR));
diff --git a/quickstep/src/com/android/launcher3/uioverrides/TaskViewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/TaskViewTouchController.java
index 63a79847f..dc3f79cc5 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/TaskViewTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/TaskViewTouchController.java
@@ -87,12 +87,14 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
protected abstract boolean isRecentsInteractive();
+ protected void onUserControlledAnimationCreated(AnimatorPlaybackController animController) {
+ }
+
@Override
public void onAnimationCancel(Animator animation) {
if (mCurrentAnimation != null && animation == mCurrentAnimation.getTarget()) {
Log.e(TAG, "Who dare cancel the animation when I am in control", new Exception());
- mDetector.finishedScrolling();
- mCurrentAnimation = null;
+ clearState();
}
}
@@ -194,8 +196,12 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
mEndDisplacement = dl.getHeight() - mTempCords[1];
}
+ if (mCurrentAnimation != null) {
+ mCurrentAnimation.setOnCancelRunnable(null);
+ }
mCurrentAnimation = AnimatorPlaybackController
- .wrap(mPendingAnimation.anim, maxDuration);
+ .wrap(mPendingAnimation.anim, maxDuration, this::clearState);
+ onUserControlledAnimationCreated(mCurrentAnimation);
mCurrentAnimation.getTarget().addListener(this);
mCurrentAnimation.dispatchOnStart();
mProgressMultiplier = 1 / mEndDisplacement;
@@ -271,8 +277,17 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
mPendingAnimation.finish(wasSuccess, logAction);
mPendingAnimation = null;
}
+ clearState();
+ }
+
+ private void clearState() {
mDetector.finishedScrolling();
+ mDetector.setDetectableScrollConditions(0, false);
mTaskBeingDragged = null;
mCurrentAnimation = null;
+ if (mPendingAnimation != null) {
+ mPendingAnimation.finish(false, Touch.SWIPE);
+ mPendingAnimation = null;
+ }
}
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
index 01e2bf330..cb83a0d92 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
@@ -29,6 +29,7 @@ import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherStateManager.StateHandler;
+import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.util.TouchController;
import com.android.quickstep.OverviewInteractionState;
import com.android.quickstep.RecentsModel;
@@ -44,19 +45,19 @@ public class UiFactory {
return new TouchController[] {
launcher.getDragController(),
new OverviewToAllAppsTouchController(launcher),
- new LauncherTaskViewcontroller(launcher)};
+ new LauncherTaskViewController(launcher)};
}
if (launcher.getDeviceProfile().isVerticalBarLayout()) {
return new TouchController[] {
launcher.getDragController(),
new OverviewToAllAppsTouchController(launcher),
new LandscapeEdgeSwipeController(launcher),
- new LauncherTaskViewcontroller(launcher)};
+ new LauncherTaskViewController(launcher)};
} else {
return new TouchController[] {
launcher.getDragController(),
new PortraitStatesTouchController(launcher),
- new LauncherTaskViewcontroller(launcher)};
+ new LauncherTaskViewController(launcher)};
}
}
@@ -114,9 +115,9 @@ public class UiFactory {
}
}
- private static class LauncherTaskViewcontroller extends TaskViewTouchController<Launcher> {
+ private static class LauncherTaskViewController extends TaskViewTouchController<Launcher> {
- public LauncherTaskViewcontroller(Launcher activity) {
+ public LauncherTaskViewController(Launcher activity) {
super(activity);
}
@@ -124,5 +125,10 @@ public class UiFactory {
protected boolean isRecentsInteractive() {
return mActivity.isInState(OVERVIEW);
}
+
+ @Override
+ protected void onUserControlledAnimationCreated(AnimatorPlaybackController animController) {
+ mActivity.getStateManager().setCurrentUserControlledAnimation(animController);
+ }
}
}