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

Commit 4bb08df3 authored by Alex Chau's avatar Alex Chau
Browse files

Fix launch animation issue for Desktop tile

- See http://go/b320307512_problems

 for details
- Adding the following to DesktopTaskView's launch animation
  - Problem 1: Animate away DesktopTaskView's background according to fullscreenProgress, instead of a jump cut
  - Problem 2: Animate Overview's background to transparent to reveal the wallpaper behind
  - Problem 3: Animate wallpaper's zoom back to 1
- Problem 4: Apply TaskRectTransltion in TaskViewSimualtor for DesktopTaksView as well, which is used to account for TaskView not in center.
- Problem 4: Also applied RecentsView zoom in animation when TaskView is not in center, to make the whole DesktopTaskView container (backgroundView) moves as a whole. This requires calculating a new pivot before applying the zoom.
- Problem 5: When swipe down or quick switch from home into Desktop, run DesktopRecentsTransitionController without animation to put everything in the end state immediately to avoid animating again
- Problem 6: For swipe down animation, we now let createAdjacentPageAnimForTaskLaunch handle the wallpaper zoom and splash alpha, instead of doubling the effort. In case of Desktop, wallpaper depth be aniamted to 0 (no zoom/blur)
- Problem 6: Bring Desktop live tile to front during swipe down to avoid wallpaper blur applying to the desktop
- Problem 7 and 8: Crop out desktop window outside full screen bound. This is done by calulating intersection between full screen Rect and desktop window's Rect
- Problem 8: Make swipe down to use thumbnailBounds instead of bounds of the first snapshotView, this fixes all situations that first snapshotView's height is different from TaskView (e.g. vertical split, DesktopTaskView)
- Problem 9: Desktop remote target's alpha should remain 1

Bug: 320307512
Test: TaplTestsOverviewDesktop, motion fixes are tested manually
Flag: com.android.window.flags.enable_desktop_windowing_mode
Change-Id: Iae6e594424dfc89851b4f7179b0fb5b5ac5e7f46
Signed-off-by: default avatarAlex Chau <alexchau@google.com>
parent c632ae35
Loading
Loading
Loading
Loading
+17 −9
Original line number Diff line number Diff line
@@ -44,11 +44,13 @@ class DesktopRecentsTransitionController(
    /** Launch desktop tasks from recents view */
    fun launchDesktopFromRecents(
        desktopTaskView: DesktopTaskView,
        animated: Boolean,
        callback: Consumer<Boolean>? = null
    ) {
        val animRunner =
            RemoteDesktopLaunchTransitionRunner(
                desktopTaskView,
                animated,
                stateManager,
                depthController,
                callback
@@ -64,6 +66,7 @@ class DesktopRecentsTransitionController(

    private class RemoteDesktopLaunchTransitionRunner(
        private val desktopTaskView: DesktopTaskView,
        private val animated: Boolean,
        private val stateManager: StateManager<*, *>,
        private val depthController: DepthController?,
        private val successCallback: Consumer<Boolean>?
@@ -84,6 +87,7 @@ class DesktopRecentsTransitionController(
            }

            MAIN_EXECUTOR.execute {
                val animator =
                    TaskViewUtils.composeRecentsDesktopLaunchAnimator(
                        desktopTaskView,
                        stateManager,
@@ -94,6 +98,10 @@ class DesktopRecentsTransitionController(
                        errorHandlingFinishCallback.run()
                        successCallback?.accept(true)
                    }
                if (!animated) {
                    animator.setDuration(0)
                }
                animator.start()
            }
        }
    }
+4 −6
Original line number Diff line number Diff line
@@ -22,9 +22,9 @@ import static com.android.launcher3.touch.SingleAxisSwipeDetector.DIRECTION_BOTH
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.Context;
import android.graphics.Rect;
import android.os.VibrationEffect;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.Interpolator;

import com.android.app.animation.Interpolators;
@@ -67,7 +67,7 @@ public abstract class TaskViewTouchController<CONTAINER extends Context & Recent
    protected final CONTAINER mContainer;
    private final SingleAxisSwipeDetector mDetector;
    private final RecentsView mRecentsView;
    private final int[] mTempCords = new int[2];
    private final Rect mTempRect = new Rect();
    private final boolean mIsRtl;

    private AnimatorPlaybackController mCurrentAnimation;
@@ -252,10 +252,8 @@ public abstract class TaskViewTouchController<CONTAINER extends Context & Recent
                    mTaskBeingDragged, maxDuration, currentInterpolator);

            // Since the thumbnail is what is filling the screen, based the end displacement on it.
            View thumbnailView = mTaskBeingDragged.getFirstSnapshotView();
            mTempCords[1] = orientationHandler.getSecondaryDimension(thumbnailView);
            dl.getDescendantCoordRelativeToSelf(thumbnailView, mTempCords);
            mEndDisplacement = secondaryLayerDimension - mTempCords[1];
            mTaskBeingDragged.getThumbnailBounds(mTempRect, /*relativeToDragLayer=*/true);
            mEndDisplacement = secondaryLayerDimension - mTempRect.bottom;
        }
        mEndDisplacement *= verticalFactor;
        mCurrentAnimation = pa.createPlaybackController();
+9 −5
Original line number Diff line number Diff line
@@ -232,9 +232,13 @@ public final class TaskViewUtils {
                        TaskViewSimulator::setTaskRectTranslation, taskRectTranslationPrimary,
                        taskRectTranslationSecondary);

                if (v instanceof DesktopTaskView) {
                    targetHandle.getTransformParams().setTargetAlpha(1f);
                } else {
                    // Fade in the task during the initial 20% of the animation
                out.addFloat(targetHandle.getTransformParams(), TransformParams.TARGET_ALPHA, 0, 1,
                        clampToProgress(LINEAR, 0, 0.2f));
                    out.addFloat(targetHandle.getTransformParams(), TransformParams.TARGET_ALPHA, 0,
                            1, clampToProgress(LINEAR, 0, 0.2f));
                }
            }
        }

@@ -558,7 +562,7 @@ public final class TaskViewUtils {
    /**
     * Start recents to desktop animation
     */
    public static void composeRecentsDesktopLaunchAnimator(
    public static AnimatorSet composeRecentsDesktopLaunchAnimator(
            @NonNull DesktopTaskView launchingTaskView,
            @NonNull StateManager stateManager, @Nullable DepthController depthController,
            @NonNull TransitionInfo transitionInfo,
@@ -588,7 +592,7 @@ public final class TaskViewUtils {
                true /* launcherClosing */, stateManager, launchingTaskView.getRecentsView(),
                depthController);

        animatorSet.start();
        return animatorSet;
    }

    public static void composeRecentsLaunchAnimator(@NonNull AnimatorSet anim, @NonNull View v,
+16 −6
Original line number Diff line number Diff line
@@ -171,7 +171,6 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
            mTaskRect.set(mFullTaskSize);
            mOrientationState.getOrientationHandler()
                    .setSplitTaskSwipeRect(mDp, mTaskRect, mSplitBounds, mStagePosition);
            mTaskRect.offset(mTaskRectTranslationX, mTaskRectTranslationY);
        } else if (mIsDesktopTask) {
            // For desktop, tasks can take up only part of the screen size.
            // Full task size represents the whole screen size, but scaled down to fit in recents.
@@ -185,10 +184,19 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
            mTaskRect.scale(scale);
            // Ensure the task rect is inside the full task rect
            mTaskRect.offset(mFullTaskSize.left, mFullTaskSize.top);

            Rect taskDimension = new Rect(0, 0, (int) fullscreenTaskDimension.x,
                    (int) fullscreenTaskDimension.y);
            mTmpCropRect.set(mThumbnailPosition);
            if (mTmpCropRect.setIntersect(taskDimension, mThumbnailPosition)) {
                mTmpCropRect.offset(-mThumbnailPosition.left, -mThumbnailPosition.top);
            } else {
                mTmpCropRect.setEmpty();
            }
        } else {
            mTaskRect.set(mFullTaskSize);
            mTaskRect.offset(mTaskRectTranslationX, mTaskRectTranslationY);
        }
        mTaskRect.offset(mTaskRectTranslationX, mTaskRectTranslationY);
    }

    /**
@@ -486,10 +494,12 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
                recentsViewPrimaryTranslation.value);
        applyWindowToHomeRotation(mMatrix);

        if (!mIsDesktopTask) {
            // Crop rect is the inverse of thumbnail matrix
            mTempRectF.set(0, 0, taskWidth, taskHeight);
            mInversePositionMatrix.mapRect(mTempRectF);
            mTempRectF.roundOut(mTmpCropRect);
        }

        params.setProgress(1f - fullScreenProgress);
        params.applySurfaceParams(surfaceTransaction == null
+12 −7
Original line number Diff line number Diff line
@@ -242,7 +242,7 @@ class DesktopTaskView @JvmOverloads constructor(context: Context, attrs: Attribu
        }
    }

    override fun launchTaskAnimated(): RunnableList? {
    private fun launchTaskWithDesktopController(animated: Boolean): RunnableList? {
        val recentsView = recentsView ?: return null
        TestLogging.recordEvent(
            TestProtocol.SEQUENCE_MAIN,
@@ -252,17 +252,23 @@ class DesktopTaskView @JvmOverloads constructor(context: Context, attrs: Attribu
        val endCallback = RunnableList()
        val desktopController = recentsView.desktopRecentsController
        checkNotNull(desktopController) { "recentsController is null" }
        desktopController.launchDesktopFromRecents(this) { endCallback.executeAllAndDestroy() }
        Log.d(TAG, "launchTaskAnimated - launchDesktopFromRecents: ${taskIds.contentToString()}")
        desktopController.launchDesktopFromRecents(this, animated) {
            endCallback.executeAllAndDestroy()
        }
        Log.d(
            TAG,
            "launchTaskAnimated - launchTaskWithDesktopController: ${taskIds.contentToString()}, withRemoteTransition: $animated"
        )

        // Callbacks get run from recentsView for case when recents animation already running
        recentsView.addSideTaskLaunchCallback(endCallback)
        return endCallback
    }

    override fun launchTaskAnimated() = launchTaskWithDesktopController(animated = true)

    override fun launchTask(callback: (launched: Boolean) -> Unit, isQuickSwitch: Boolean) {
        launchTasks()
        callback(true)
        launchTaskWithDesktopController(animated = false)?.add { callback(true) } ?: callback(false)
    }

    // Desktop tile can't be in split screen
@@ -272,8 +278,7 @@ class DesktopTaskView @JvmOverloads constructor(context: Context, attrs: Attribu
    override fun setOverlayEnabled(overlayEnabled: Boolean) {}

    override fun onFullscreenProgressChanged(fullscreenProgress: Float) {
        // Don't show background while we are transitioning to/from fullscreen
        backgroundView.visibility = if (fullscreenProgress > 0) INVISIBLE else VISIBLE
        backgroundView.alpha = 1 - fullscreenProgress
    }

    override fun updateCurrentFullscreenParams() {
Loading