From b64b59d025c7b3ce71016544630b20e684e08fa8 Mon Sep 17 00:00:00 2001 From: Sreyas Date: Tue, 9 Jun 2020 21:00:22 -0700 Subject: [PATCH] Fix Task Icon menu behavior. Tapping task icon will now show the scrim for rest of thumbnail and not snap to page that is already snapped to. Pressing task icon from clear all will scroll to the page. Link: https://drive.google.com/file/d/1I90rd6ELPZNIje2_VZ3CamWWeFN8ywhL/view?usp=sharing Bug: 158004853 Change-Id: I9ac8229a603190ea09a74e1cfb70a6bb6e1e65b7 --- .../android/quickstep/views/RecentsView.java | 13 ++++++++++++- .../com/android/quickstep/views/TaskView.java | 17 ++++++++++------- 2 files changed, 22 insertions(+), 8 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 98784efdc1..9b1e27d3e6 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 @@ -607,6 +607,17 @@ public abstract class RecentsView extends PagedView impl } } + /** + * Whether the Clear All button is hidden or fully visible. Used to determine if center + * displayed page is a task or the Clear All button. + * + * @return True = Clear All button not fully visible, center page is a task. False = Clear All + * button fully visible, center page is Clear All button. + */ + public boolean isClearAllHidden() { + return mClearAllButton.getAlpha() != 1f; + } + @Override protected void onPageBeginTransition() { super.onPageBeginTransition(); @@ -616,7 +627,7 @@ public abstract class RecentsView extends PagedView impl @Override protected void onPageEndTransition() { super.onPageEndTransition(); - if (getScrollX() == getScrollForPage(getPageNearestToCenterOfScreen())) { + if (isClearAllHidden()) { LayoutUtils.setViewEnabled(mActionsView, true); } if (getNextPage() > 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 cadf6c4174..e25c85b92b 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 @@ -425,13 +425,16 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { } private boolean showTaskMenu(int action) { - getRecentsView().snapToPage(getRecentsView().indexOfChild(this)); - mMenuView = TaskMenuView.showForTask(this); - mActivity.getStatsLogManager().log(LAUNCHER_TASK_ICON_TAP_OR_LONGPRESS, buildProto()); - UserEventDispatcher.newInstance(getContext()).logActionOnItem(action, Direction.NONE, - LauncherLogProto.ItemType.TASK_ICON); - if (mMenuView != null) { - mMenuView.addOnAttachStateChangeListener(mTaskMenuStateListener); + if (!getRecentsView().isClearAllHidden()) { + getRecentsView().snapToPage(getRecentsView().indexOfChild(this)); + } else { + mMenuView = TaskMenuView.showForTask(this); + mActivity.getStatsLogManager().log(LAUNCHER_TASK_ICON_TAP_OR_LONGPRESS, buildProto()); + UserEventDispatcher.newInstance(getContext()).logActionOnItem(action, Direction.NONE, + LauncherLogProto.ItemType.TASK_ICON); + if (mMenuView != null) { + mMenuView.addOnAttachStateChangeListener(mTaskMenuStateListener); + } } return mMenuView != null; }