Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8ad575e1 authored by Tracy Zhou's avatar Tracy Zhou
Browse files

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
parent 9a472fbd
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -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.
         */
+19 −7
Original line number Diff line number Diff line
@@ -2294,13 +2294,13 @@ public abstract class RecentsView<T extends StatefulActivity> 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);
            }
        });
    }

@@ -2428,7 +2428,19 @@ public abstract class RecentsView<T extends StatefulActivity> 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) {