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

Commit cdb72146 authored by Tracy Zhou's avatar Tracy Zhou Committed by Winson Chung
Browse files

Handle app switch in Overview

- Transfer screenshot from WM to launcher when recents animation gets cancelled due to stack order change
- Transform two live windows when app open animation happens from recents

Fixes: 139258979
Fixes: 139259253
Test: switch task in overview

Change-Id: I80bafb8d45b9250fda937223254e365596a7f538
parent 35d9ac92
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -148,8 +148,10 @@ final class AppToOverviewAnimationProvider<T extends BaseDraggingActivity> imple
        valueAnimator.setDuration(RECENTS_LAUNCH_DURATION);
        valueAnimator.setInterpolator(TOUCH_RESPONSE_INTERPOLATOR);
        valueAnimator.addUpdateListener((v) -> {
            params.setProgress((float) v.getAnimatedValue());
            clipHelper.applyTransform(targetSet, params);
            params.setProgress((float) v.getAnimatedValue())
                    .setTargetSet(targetSet)
                    .setLauncherOnTop(true);
            clipHelper.applyTransform(params);
        });

        if (targetSet.isAnimatingHome()) {
+12 −7
Original line number Diff line number Diff line
@@ -367,9 +367,12 @@ public abstract class BaseSwipeUpHandler<T extends BaseDraggingActivity, Q exten
        float offsetX = mRecentsView == null ? 0 : mRecentsView.getScrollOffset();
        float offsetScale = getTaskCurveScaleForOffsetX(offsetX,
                mClipAnimationHelper.getTargetRect().width());
        mTransformParams.setProgress(shift).setOffsetX(offsetX).setOffsetScale(offsetScale);
        mClipAnimationHelper.applyTransform(mRecentsAnimationWrapper.targetSet,
                mTransformParams);
        mTransformParams.setProgress(shift)
                .setOffsetX(offsetX)
                .setOffsetScale(offsetScale)
                .setTargetSet(mRecentsAnimationWrapper.targetSet)
                .setLauncherOnTop(true);
        mClipAnimationHelper.applyTransform(mTransformParams);
    }

    private float getTaskCurveScaleForOffsetX(float offsetX, float taskWidth) {
@@ -386,8 +389,11 @@ public abstract class BaseSwipeUpHandler<T extends BaseDraggingActivity, Q exten
    protected RectFSpringAnim createWindowAnimationToHome(float startProgress,
            HomeAnimationFactory homeAnimationFactory) {
        final RemoteAnimationTargetSet targetSet = mRecentsAnimationWrapper.targetSet;
        final RectF startRect = new RectF(mClipAnimationHelper.applyTransform(targetSet,
                mTransformParams.setProgress(startProgress), false /* launcherOnTop */));
        final RectF startRect = new RectF(
                mClipAnimationHelper.applyTransform(
                        mTransformParams.setProgress(startProgress)
                                .setTargetSet(targetSet)
                                .setLauncherOnTop(false)));
        final RectF targetRect = homeAnimationFactory.getWindowTargetRect();

        final View floatingView = homeAnimationFactory.getFloatingView();
@@ -434,8 +440,7 @@ public abstract class BaseSwipeUpHandler<T extends BaseDraggingActivity, Q exten
                    mTransformParams.setCornerRadius(endRadius * progress + startRadius
                            * (1f - progress));
                }
                mClipAnimationHelper.applyTransform(targetSet, mTransformParams,
                        false /* launcherOnTop */);
                mClipAnimationHelper.applyTransform(mTransformParams);

                if (isFloatingIconView) {
                    ((FloatingIconView) floatingView).update(currentRect, 1f, progress,
+21 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ import com.android.quickstep.views.LauncherRecentsView;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskView;
import com.android.systemui.plugins.shared.LauncherOverlayManager;
import com.android.systemui.shared.recents.model.ThumbnailData;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;

import java.util.function.BiPredicate;
@@ -491,4 +492,24 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe
            om.hideOverlay(150);
        }
    }

    @Override
    public void switchToScreenshot(ThumbnailData thumbnailData, Runnable runnable) {
        Launcher launcher = getCreatedActivity();
        RecentsView recentsView = launcher.getOverviewPanel();
        if (recentsView == null) {
            if (runnable != null) {
                runnable.run();
            }
            return;
        }
        TaskView taskView = recentsView.getRunningTaskView();
        if (taskView != null) {
            taskView.setShowScreenshot(true);
            taskView.getThumbnail().setThumbnail(taskView.getTask(), thumbnailData);
            ViewUtils.postDraw(taskView, runnable);
        } else if (runnable != null) {
            runnable.run();
        }
    }
}
 No newline at end of file
+23 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import com.android.launcher3.util.Preconditions;
import com.android.quickstep.util.RecentsAnimationListenerSet;
import com.android.quickstep.util.SwipeAnimationTargetSet;
import com.android.quickstep.util.SwipeAnimationTargetSet.SwipeAnimationListener;
import com.android.systemui.shared.recents.model.ThumbnailData;

import java.io.PrintWriter;

@@ -37,6 +38,7 @@ public class SwipeSharedState implements SwipeAnimationListener {

    private RecentsAnimationListenerSet mRecentsAnimationListener;
    private SwipeAnimationTargetSet mLastAnimationTarget;
    private Runnable mRecentsAnimationCanceledCallback;

    private boolean mLastAnimationCancelled = false;
    private boolean mLastAnimationRunning = false;
@@ -67,11 +69,30 @@ public class SwipeSharedState implements SwipeAnimationListener {
    }

    @Override
    public final void onRecentsAnimationCanceled() {
    public final void onRecentsAnimationCanceled(ThumbnailData thumbnailData) {
        if (thumbnailData != null) {
            mOverviewComponentObserver.getActivityControlHelper().switchToScreenshot(thumbnailData,
                    () -> {
                        if (mRecentsAnimationCanceledCallback != null) {
                            mRecentsAnimationCanceledCallback.run();
                        }
                        clearAnimationState();
                    });
        } else {
            clearAnimationState();
        }
    }

    public void setRecentsAnimationCanceledCallback(Runnable callback) {
        mRecentsAnimationCanceledCallback = callback;
    }

    private void clearAnimationState() {
        clearAnimationTarget();

        mLastAnimationCancelled = true;
        mLastAnimationRunning = false;
        mRecentsAnimationCanceledCallback = null;
    }

    private void clearListenerState(boolean finishAnimation) {
@@ -127,7 +148,7 @@ public class SwipeSharedState implements SwipeAnimationListener {
        if (mLastAnimationTarget != null) {
            listener.onRecentsAnimationStart(mLastAnimationTarget);
        } else if (mLastAnimationCancelled) {
            listener.onRecentsAnimationCanceled();
            listener.onRecentsAnimationCanceled(null);
        }
    }

+37 −4
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package com.android.quickstep;

import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.TOUCH_RESPONSE_INTERPOLATOR;
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_OPENING;

import android.animation.Animator;
@@ -38,6 +39,11 @@ import com.android.quickstep.views.TaskView;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat;
import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Utility class for helpful methods related to {@link TaskView} objects and their tasks.
@@ -115,12 +121,13 @@ public final class TaskViewUtils {
            RemoteAnimationTargetCompat[] wallpaperTargets, final ClipAnimationHelper inOutHelper) {
        SyncRtSurfaceTransactionApplierCompat applier =
                new SyncRtSurfaceTransactionApplierCompat(v);
        ClipAnimationHelper.TransformParams params = new ClipAnimationHelper.TransformParams()
                .setSyncTransactionApplier(applier);

        final RemoteAnimationTargetSet targetSet =
                new RemoteAnimationTargetSet(appTargets, wallpaperTargets, MODE_OPENING);
        targetSet.addDependentTransactionApplier(applier);
        ClipAnimationHelper.TransformParams params = new ClipAnimationHelper.TransformParams()
                .setSyncTransactionApplier(applier)
                .setTargetSet(targetSet)
                .setLauncherOnTop(true);

        final RecentsView recentsView = v.getRecentsView();
        final ValueAnimator appAnimator = ValueAnimator.ofFloat(0, 1);
@@ -152,7 +159,33 @@ public final class TaskViewUtils {
            public void onUpdate(float percent) {
                // TODO: Take into account the current fullscreen progress for animating the insets
                params.setProgress(1 - percent);
                RectF taskBounds = inOutHelper.applyTransform(targetSet, params);
                RectF taskBounds;
                if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
                    List<SurfaceParams> surfaceParamsList = new ArrayList<>();
                    // Append the surface transform params for the app that's being opened.
                    Collections.addAll(surfaceParamsList, inOutHelper.getSurfaceParams(params));

                    ClipAnimationHelper liveTileClipAnimationHelper =
                            v.getRecentsView().getClipAnimationHelper();
                    if (liveTileClipAnimationHelper != null) {
                        // Append the surface transform params for the live tile app.
                        ClipAnimationHelper.TransformParams liveTileParams =
                                v.getRecentsView().getLiveTileParams(true /* mightNeedToRefill */);
                        if (liveTileParams != null) {
                            Collections.addAll(surfaceParamsList,
                                    liveTileClipAnimationHelper.getSurfaceParams(liveTileParams));
                        }
                    }
                    // Apply surface transform using the surface params list.
                    ClipAnimationHelper.applySurfaceParams(params.syncTransactionApplier,
                            surfaceParamsList.toArray(new SurfaceParams[surfaceParamsList.size()]));
                    // Get the task bounds for the app that's being opened after surface transform
                    // update.
                    taskBounds = inOutHelper.updateCurrentRect(params);
                } else {
                    taskBounds = inOutHelper.applyTransform(params);
                }

                int taskIndex = recentsView.indexOfChild(v);
                int centerTaskIndex = recentsView.getCurrentPage();
                boolean parallaxCenterAndAdjacentTask = taskIndex != centerTaskIndex;
Loading