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

Commit 3ed68859 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix launch animation issue for Desktop tile" into main

parents 246837aa 4bb08df3
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