Merge "Do not switch to screenshot and finish recents animation for menu options that already do so" into sc-dev am: e54f789de9

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/15176734

Change-Id: I7b570013c9600d32a76c72f2a0ba8847ea04a069
diff --git a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
index c1c85de..2bcc229 100644
--- a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
+++ b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
@@ -88,6 +88,7 @@
             SystemShortcut screenshotShortcut = TaskShortcutFactory.SCREENSHOT
                     .getShortcut(activity, taskView);
             if (screenshotShortcut != null) {
+                screenshotShortcut.setHasFinishRecentsInAction(true);
                 shortcuts.add(screenshotShortcut);
             }
 
@@ -96,6 +97,7 @@
                 SystemShortcut modalShortcut = TaskShortcutFactory.MODAL
                         .getShortcut(activity, taskView);
                 if (modalShortcut != null) {
+                    modalShortcut.setHasFinishRecentsInAction(true);
                     shortcuts.add(modalShortcut);
                 }
             }
diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuView.java b/quickstep/src/com/android/quickstep/views/TaskMenuView.java
index d663635..b5ab400 100644
--- a/quickstep/src/com/android/quickstep/views/TaskMenuView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskMenuView.java
@@ -220,7 +220,7 @@
         menuOptionView.setEnabled(menuOption.isEnabled());
         menuOptionView.setAlpha(menuOption.isEnabled() ? 1 : 0.5f);
         menuOptionView.setOnClickListener(view -> {
-            if (LIVE_TILE.get()) {
+            if (LIVE_TILE.get() && !menuOption.hasFinishRecentsInAction()) {
                 RecentsView recentsView = mTaskView.getRecentsView();
                 recentsView.switchToScreenshot(null,
                         () -> recentsView.finishRecentsAnimation(true /* toRecents */,
diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java
index e5424cf..d3f4909 100644
--- a/src/com/android/launcher3/popup/SystemShortcut.java
+++ b/src/com/android/launcher3/popup/SystemShortcut.java
@@ -50,6 +50,8 @@
      */
     private boolean isEnabled = true;
 
+    private boolean mHasFinishRecentsInAction = false;
+
     public SystemShortcut(int iconResId, int labelResId, T target, ItemInfo itemInfo) {
         mIconResId = iconResId;
         mLabelResId = labelResId;
@@ -100,6 +102,14 @@
         return mAccessibilityActionId == action;
     }
 
+    public void setHasFinishRecentsInAction(boolean hasFinishRecentsInAction) {
+        mHasFinishRecentsInAction = hasFinishRecentsInAction;
+    }
+
+    public boolean hasFinishRecentsInAction() {
+        return mHasFinishRecentsInAction;
+    }
+
     public interface Factory<T extends BaseDraggingActivity> {
 
         @Nullable SystemShortcut<T> getShortcut(T activity, ItemInfo itemInfo);