diff options
| author | 2017-01-13 00:28:19 +0000 | |
|---|---|---|
| committer | 2017-01-13 00:28:19 +0000 | |
| commit | bc6bdb3ef8c0bea4b6fec37e2f4e472e15723beb (patch) | |
| tree | 473f272ac1310203191cf007bfbbfcfcbfb92df4 | |
| parent | 907585c0043e6940838c4bb502d26d3d419e5592 (diff) | |
| parent | 5df7667edbabdf8bf43bc08ef7df2859fd620314 (diff) | |
2D Recents: Use a different task dismiss animation
am: 5df7667edb
Change-Id: Ib6186c663057d7a3c8d44ec13254f6c8b76ce3de
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java | 146 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java | 6 |
2 files changed, 94 insertions, 58 deletions
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 34c0c64b3d13..ed86d4cf55be 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java @@ -390,68 +390,26 @@ public class TaskStackAnimationHelper { /** * Starts the delete animation for the specified {@link TaskView}. */ - public void startDeleteTaskAnimation(final TaskView deleteTaskView, + public void startDeleteTaskAnimation(final TaskView deleteTaskView, boolean gridLayout, final ReferenceCountedTrigger postAnimationTrigger) { - TaskStackViewTouchHandler touchHandler = mStackView.getTouchHandler(); - touchHandler.onBeginManualDrag(deleteTaskView); - - postAnimationTrigger.increment(); - postAnimationTrigger.addLastDecrementRunnable(() -> { - touchHandler.onChildDismissed(deleteTaskView); - }); - - 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(); - } - }); - animator.start(); + if (gridLayout) { + startTaskGridDeleteTaskAnimation(deleteTaskView, postAnimationTrigger); + } else { + startTaskStackDeleteTaskAnimation(deleteTaskView, postAnimationTrigger); + } } /** * Starts the delete animation for all the {@link TaskView}s. */ - public void startDeleteAllTasksAnimation(final List<TaskView> taskViews, - final ReferenceCountedTrigger postAnimationTrigger) { - TaskStackLayoutAlgorithm stackLayout = mStackView.getStackAlgorithm(); - - int offscreenXOffset = mStackView.getMeasuredWidth() - stackLayout.getTaskRect().left; - - int taskViewCount = taskViews.size(); - for (int i = taskViewCount - 1; i >= 0; i--) { - TaskView tv = taskViews.get(i); - int taskIndexFromFront = taskViewCount - i - 1; - int startDelay = taskIndexFromFront * DOUBLE_FRAME_OFFSET_MS; - - // Disabling clipping with the stack while the view is animating away - tv.setClipViewInStack(false); - - // Compose the new animation and transform and star the animation - AnimationProps taskAnimation = new AnimationProps(startDelay, - DISMISS_ALL_TASKS_DURATION, DISMISS_ALL_TRANSLATION_INTERPOLATOR, - new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - postAnimationTrigger.decrement(); - - // Re-enable clipping with the stack (we will reuse this view) - tv.setClipViewInStack(true); - } - }); - postAnimationTrigger.increment(); - - mTmpTransform.fillIn(tv); - mTmpTransform.rect.offset(offscreenXOffset, 0); - mStackView.updateTaskViewToTransform(tv, mTmpTransform, taskAnimation); + public void startDeleteAllTasksAnimation(final List<TaskView> taskViews, boolean gridLayout, + final ReferenceCountedTrigger postAnimationTrigger) { + if (gridLayout) { + for (int i = 0; i < taskViews.size(); i++) { + startTaskGridDeleteTaskAnimation(taskViews.get(i), postAnimationTrigger); + } + } else { + startTaskStackDeleteAllTasksAnimation(taskViews, postAnimationTrigger); } } @@ -651,4 +609,80 @@ public class TaskStackAnimationHelper { private int calculateStaggeredAnimDuration(int i) { return Math.max(100, 100 + ((i - 1) * 50)); } + + private void startTaskGridDeleteTaskAnimation(final TaskView deleteTaskView, + final ReferenceCountedTrigger postAnimationTrigger) { + postAnimationTrigger.increment(); + postAnimationTrigger.addLastDecrementRunnable(() -> { + mStackView.getTouchHandler().onChildDismissed(deleteTaskView); + }); + deleteTaskView.animate().setDuration(300).scaleX(0).scaleY(0).alpha(0).setListener( + new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + postAnimationTrigger.decrement(); + }}).start(); + } + + private void startTaskStackDeleteTaskAnimation(final TaskView deleteTaskView, + final ReferenceCountedTrigger postAnimationTrigger) { + TaskStackViewTouchHandler touchHandler = mStackView.getTouchHandler(); + touchHandler.onBeginManualDrag(deleteTaskView); + + postAnimationTrigger.increment(); + postAnimationTrigger.addLastDecrementRunnable(() -> { + touchHandler.onChildDismissed(deleteTaskView); + }); + + 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(); + } + }); + animator.start(); + } + + private void startTaskStackDeleteAllTasksAnimation(final List<TaskView> taskViews, + final ReferenceCountedTrigger postAnimationTrigger) { + TaskStackLayoutAlgorithm stackLayout = mStackView.getStackAlgorithm(); + + int offscreenXOffset = mStackView.getMeasuredWidth() - stackLayout.getTaskRect().left; + + int taskViewCount = taskViews.size(); + for (int i = taskViewCount - 1; i >= 0; i--) { + TaskView tv = taskViews.get(i); + int taskIndexFromFront = taskViewCount - i - 1; + int startDelay = taskIndexFromFront * DOUBLE_FRAME_OFFSET_MS; + + // Disabling clipping with the stack while the view is animating away + tv.setClipViewInStack(false); + + // Compose the new animation and transform and star the animation + AnimationProps taskAnimation = new AnimationProps(startDelay, + DISMISS_ALL_TASKS_DURATION, DISMISS_ALL_TRANSLATION_INTERPOLATOR, + new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + postAnimationTrigger.decrement(); + + // Re-enable clipping with the stack (we will reuse this view) + tv.setClipViewInStack(true); + } + }); + postAnimationTrigger.increment(); + + mTmpTransform.fillIn(tv); + mTmpTransform.rect.offset(offscreenXOffset, 0); + mStackView.updateTaskViewToTransform(tv, mTmpTransform, taskAnimation); + } + } } 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 1de21c69ec80..0bfdb2b31d25 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java @@ -1754,13 +1754,15 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal public final void onBusEvent(DismissTaskViewEvent event) { // For visible children, defer removing the task until after the animation - mAnimationHelper.startDeleteTaskAnimation(event.taskView, event.getAnimationTrigger()); + mAnimationHelper.startDeleteTaskAnimation( + event.taskView, useGridLayout(), event.getAnimationTrigger()); } public final void onBusEvent(final DismissAllTaskViewsEvent event) { // Keep track of the tasks which will have their data removed ArrayList<Task> tasks = new ArrayList<>(mStack.getStackTasks()); - mAnimationHelper.startDeleteAllTasksAnimation(getTaskViews(), event.getAnimationTrigger()); + mAnimationHelper.startDeleteAllTasksAnimation( + getTaskViews(), useGridLayout(), event.getAnimationTrigger()); event.addPostAnimationCallback(new Runnable() { @Override public void run() { |