From c343cb865884dc6a5033708fd3036b1a4e2e6053 Mon Sep 17 00:00:00 2001 From: Becky Qiu Date: Tue, 10 Mar 2020 11:20:41 -0700 Subject: [PATCH] [Overview Actions] Resizes the select mode UI and adds animations. Demo video: https://drive.google.com/a/google.com/file/d/1m0CasV2tQEGNelcjwvFRUlTeyBd7WhM6/view?usp=sharing Spec: https://docs.google.com/presentation/d/1gXWNdCRXvXuEhgDmE0TX2KYqCxIQBXVtWKdl4pKrno8/edit#slide=id.g6f30ae9caf_14_4 Test:local Bug:139828243 Change-Id: Iaecad62365c687f78494edd235b2e11433fe6907 --- .../android/quickstep/views/RecentsView.java | 8 +++-- .../com/android/quickstep/views/TaskView.java | 32 +++++++++++++++++-- quickstep/res/values/dimens.xml | 2 ++ .../android/quickstep/util/LayoutUtils.java | 4 ++- 4 files changed, 41 insertions(+), 5 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java index e3b3102562..bb0a5b7d1c 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java @@ -710,11 +710,15 @@ public abstract class RecentsView extends PagedView impl int currentIndex = indexOfChild(taskView); TaskView previousTask = getTaskViewAt(currentIndex - 1); TaskView nextTask = getTaskViewAt(currentIndex + 1); + float alpha = isTaskOverlayModal ? 0.0f : 1.0f; if (previousTask != null) { - previousTask.setVisibility(isTaskOverlayModal ? View.INVISIBLE : View.VISIBLE); + previousTask.animate().alpha(alpha) + .translationX(isTaskOverlayModal ? previousTask.getWidth() / 2 : 0); } if (nextTask != null) { - nextTask.setVisibility(isTaskOverlayModal ? View.INVISIBLE : View.VISIBLE); + nextTask.animate().alpha(alpha) + .translationX(isTaskOverlayModal ? -nextTask.getWidth() / 2 : 0); + } } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java index 7010f9ab8a..e393a2c473 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java @@ -180,6 +180,7 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { private float mStableAlpha = 1; private boolean mShowScreenshot; + private boolean mRunningModalAnimation = false; // The current background requests to load the task thumbnail and icon private TaskThumbnailCache.ThumbnailLoadRequest mThumbnailLoadRequest; @@ -262,17 +263,40 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { /** Updates UI based on whether the task is modal. */ public void updateUiForModalTask() { boolean isOverlayModal = isTaskOverlayModal(); + mRunningModalAnimation = true; if (getRecentsView() != null) { getRecentsView().updateUiForModalTask(this, isOverlayModal); } - // Hide footers when overlay is modal. + + // Hides footers and icon when overlay is modal. if (isOverlayModal) { for (FooterWrapper footer : mFooters) { if (footer != null) { footer.animateHide(); } } + mIconView.animate().alpha(0.0f); + } else { + mIconView.animate().alpha(1.0f); } + + // Sets animations for modal UI. We will remove the margins to zoom in the snapshot. + float topMargin = + getResources().getDimension(R.dimen.task_thumbnail_top_margin_with_actions); + float bottomMargin = + getResources().getDimension(R.dimen.task_thumbnail_bottom_margin_with_actions); + float newHeight = mSnapshotView.getHeight() + topMargin + bottomMargin; + float scale = isOverlayModal ? newHeight / mSnapshotView.getHeight() : 1.0f; + float centerDifference = (bottomMargin - topMargin) / 2; + float translationY = isOverlayModal ? centerDifference : 0; + this.animate().scaleX(scale).scaleY(scale).translationY(translationY) + .withEndAction(new Runnable() { + @Override + public void run() { + setCurveScale(scale); + mRunningModalAnimation = false; + } + }); } public TaskMenuView getMenuView() { @@ -579,11 +603,15 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { @Override public void onPageScroll(ScrollState scrollState) { + // Don't do anything if it's modal. + if (mRunningModalAnimation || isTaskOverlayModal()) { + return; + } + float curveInterpolation = CURVE_INTERPOLATOR.getInterpolation(scrollState.linearInterpolation); float curveScaleForCurveInterpolation = getCurveScaleForCurveInterpolation( curveInterpolation); - mSnapshotView.setDimAlpha(curveInterpolation * MAX_PAGE_SCRIM_ALPHA); setCurveScale(curveScaleForCurveInterpolation); diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index dcc85d52cc..7f1a8bf3d8 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -17,6 +17,8 @@ 24dp + 60dp + 76dp 12dp 48dp diff --git a/quickstep/src/com/android/quickstep/util/LayoutUtils.java b/quickstep/src/com/android/quickstep/util/LayoutUtils.java index 1f1a99937e..f71bcfbdd4 100644 --- a/quickstep/src/com/android/quickstep/util/LayoutUtils.java +++ b/quickstep/src/com/android/quickstep/util/LayoutUtils.java @@ -122,7 +122,9 @@ public class LayoutUtils { paddingHorz = res.getDimension(paddingResId); } - float topIconMargin = res.getDimension(R.dimen.task_thumbnail_top_margin); + float topIconMargin = overviewActionsEnabled + ? res.getDimension(R.dimen.task_thumbnail_top_margin_with_actions) + : res.getDimension(R.dimen.task_thumbnail_top_margin); float bottomMargin = thumbnailBottomMargin(context); float paddingVert = overviewActionsEnabled && removeShelfFromOverview(context)