diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java index b422cca25a82c..c15094d880e97 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java @@ -19,6 +19,7 @@ package com.android.systemui.recents.views; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.TimeInterpolator; +import android.animation.ValueAnimator; import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; @@ -384,29 +385,29 @@ public class TaskStackAnimationHelper { */ public void startDeleteTaskAnimation(final TaskView deleteTaskView, final ReferenceCountedTrigger postAnimationTrigger) { - Resources res = mStackView.getResources(); - TaskStackLayoutAlgorithm stackLayout = mStackView.getStackAlgorithm(); + TaskStackViewTouchHandler touchHandler = mStackView.getTouchHandler(); + touchHandler.onBeginDrag(deleteTaskView); - int offscreenXOffset = mStackView.getMeasuredWidth() - stackLayout.mTaskRect.left; + postAnimationTrigger.increment(); + postAnimationTrigger.addLastDecrementRunnable(() -> { + touchHandler.onChildDismissed(deleteTaskView); + }); - // Disabling clipping with the stack while the view is animating away, this will get - // restored when the task is next picked up from the view pool - deleteTaskView.setClipViewInStack(false); - - // Compose the new animation and transform and star the animation - AnimationProps taskAnimation = new AnimationProps(DISMISS_TASK_DURATION, - Interpolators.ALPHA_OUT, new AnimatorListenerAdapter() { + final float dismissSize = touchHandler.getScaledDismissSize(); + ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f); + animator.setDuration(400); + animator.addUpdateListener((animation) -> { + float progress = (Float) animation.getAnimatedValue(); + deleteTaskView.setTranslationX(progress * dismissSize); + touchHandler.updateSwipeProgress(deleteTaskView, true, progress); + }); + animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { postAnimationTrigger.decrement(); } }); - postAnimationTrigger.increment(); - - mTmpTransform.fillIn(deleteTaskView); - mTmpTransform.alpha = 0f; - mTmpTransform.rect.offset(offscreenXOffset, 0); - mStackView.updateTaskViewToTransform(deleteTaskView, mTmpTransform, taskAnimation); + animator.start(); } /** @@ -419,7 +420,6 @@ public class TaskStackAnimationHelper { int offscreenXOffset = mStackView.getMeasuredWidth() - stackLayout.mTaskRect.left; int taskViewCount = taskViews.size(); - for (int i = taskViewCount - 1; i >= 0; i--) { TaskView tv = taskViews.get(i); int taskIndexFromFront = taskViewCount - i - 1; diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java index 58ab30160cb3b..85ffd178c5214 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java @@ -419,6 +419,13 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal return mLayoutAlgorithm; } + /** + * Returns the touch handler for this task stack. + */ + public TaskStackViewTouchHandler getTouchHandler() { + return mTouchHandler; + } + /** * Adds a task to the ignored set. */ diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java index 81242fdd4e646..f2a9a5fc8cdee 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java @@ -631,7 +631,7 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback { /** * Returns the scaled size used to calculate the dismiss fraction. */ - private float getScaledDismissSize() { + public float getScaledDismissSize() { return 1.5f * Math.max(mSv.getWidth(), mSv.getHeight()); } }