From 8ad575e1e65c8a73b37abcd89062c22a27f0ad37 Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Sat, 1 Aug 2020 16:08:48 -0700 Subject: [PATCH] Handle overview actions in Live Tile mode - Switch to screenshot and finish recents animation when an overview action is selected Fixes: 162564471 Test: Manual Change-Id: I3db20619435d079bb39ce4cb37b46ea775416336 --- .../android/quickstep/TaskOverlayFactory.java | 21 +++++++++++++++ .../android/quickstep/views/RecentsView.java | 26 ++++++++++++++----- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskOverlayFactory.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskOverlayFactory.java index 36579ec736..3a47024592 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskOverlayFactory.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskOverlayFactory.java @@ -18,6 +18,7 @@ package com.android.quickstep; import static android.view.Surface.ROTATION_0; +import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.quickstep.views.OverviewActionsView.DISABLED_NO_THUMBNAIL; import static com.android.quickstep.views.OverviewActionsView.DISABLED_ROTATED; @@ -41,6 +42,7 @@ import com.android.launcher3.popup.SystemShortcut; import com.android.launcher3.util.ResourceBasedOverride; import com.android.quickstep.util.RecentsOrientedState; import com.android.quickstep.views.OverviewActionsView; +import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.TaskThumbnailView; import com.android.quickstep.views.TaskView; import com.android.systemui.shared.recents.model.Task; @@ -155,6 +157,7 @@ public class TaskOverlayFactory implements ResourceBasedOverride { getActionsView().setCallbacks(new OverlayUICallbacks() { @Override public void onShare() { + endLiveTileMode(isAllowedByPolicy); if (isAllowedByPolicy) { mImageApi.startShareActivity(); } else { @@ -165,12 +168,30 @@ public class TaskOverlayFactory implements ResourceBasedOverride { @SuppressLint("NewApi") @Override public void onScreenshot() { + endLiveTileMode(isAllowedByPolicy); saveScreenshot(task); } }); } } + /** + * End rendering live tile in Overview. + * + * @param showScreenshot if it's true, we take a screenshot and switch to it. + */ + public void endLiveTileMode(boolean showScreenshot) { + if (ENABLE_QUICKSTEP_LIVE_TILE.get()) { + RecentsView recentsView = mThumbnailView.getTaskView().getRecentsView(); + if (showScreenshot) { + recentsView.switchToScreenshot( + () -> recentsView.finishRecentsAnimation(true /* toRecents */, null)); + } else { + recentsView.finishRecentsAnimation(true /* toRecents */, null); + } + } + } + /** * Called to save screenshot of the task thumbnail. */ 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 52677607ab..a9b5bf3ea9 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 @@ -2294,13 +2294,13 @@ public abstract class RecentsView extends PagedView mRecentsAnimationController.finish(toRecents, () -> { if (onFinishComplete != null) { onFinishComplete.run(); - // After we finish the recents animation, the current task id should be correctly - // reset so that when the task is launched from Overview later, it goes through the - // flow of starting a new task instead of finishing recents animation to app. A - // typical example of this is (1) user swipes up from app to Overview (2) user - // taps on QSB (3) user goes back to Overview and launch the most recent task. - setCurrentTask(-1); } + // After we finish the recents animation, the current task id should be correctly + // reset so that when the task is launched from Overview later, it goes through the + // flow of starting a new task instead of finishing recents animation to app. A + // typical example of this is (1) user swipes up from app to Overview (2) user + // taps on QSB (3) user goes back to Overview and launch the most recent task. + setCurrentTask(-1); }); } @@ -2428,7 +2428,19 @@ public abstract class RecentsView extends PagedView } } - /** If it's in the live tile mode, switch the running task into screenshot mode. */ + /** + * Switch the current running task view to static snapshot mode, + * capturing the snapshot at the same time. + */ + public void switchToScreenshot(Runnable onFinishRunnable) { + switchToScreenshot(mRunningTaskId == -1 ? null + : mRecentsAnimationController.screenshotTask(mRunningTaskId), onFinishRunnable); + } + + /** + * Switch the current running task view to static snapshot mode, using the + * provided thumbnail data as the snapshot. + */ public void switchToScreenshot(ThumbnailData thumbnailData, Runnable onFinishRunnable) { TaskView taskView = getRunningTaskView(); if (taskView != null) {