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

Commit 6904a08f authored by Ats Jenk's avatar Ats Jenk Committed by Android (Google) Code Review
Browse files

Merge "Use desktop corner radius for initial task snapshot" into main

parents cea36ba2 68d69532
Loading
Loading
Loading
Loading
+13 −8
Original line number Diff line number Diff line
@@ -159,19 +159,22 @@ public class BubbleTransitions {
        private final WindowContainerTransaction mPendingWct;
        private final boolean mReleasedOnLeft;
        private final float mTaskScale;
        private final float mCornerRadius;
        private final PointF mDragPosition;

        /**
         * @param releasedOnLeft true if the bubble was released in the left drop target
         * @param taskScale      the scale of the task when it was dragged to bubble
         * @param cornerRadius   the corner radius of the task when it was dragged to bubble
         * @param dragPosition   the position of the task when it was dragged to bubble
         * @param wct            pending operations to be applied when finishing the drag
         */
        public DragData(boolean releasedOnLeft, float taskScale, @Nullable PointF dragPosition,
                @Nullable WindowContainerTransaction wct) {
        public DragData(boolean releasedOnLeft, float taskScale, float cornerRadius,
                @Nullable PointF dragPosition, @Nullable WindowContainerTransaction wct) {
            mPendingWct = wct;
            mReleasedOnLeft = releasedOnLeft;
            mTaskScale = taskScale;
            mCornerRadius = cornerRadius;
            mDragPosition = dragPosition != null ? dragPosition : new PointF(0, 0);
        }

@@ -197,6 +200,13 @@ public class BubbleTransitions {
            return mTaskScale;
        }

        /**
         * @return the corner radius of the task when it was dragged to bubble
         */
        public float getCornerRadius() {
            return mCornerRadius;
        }

        /**
         * @return position of the task when it was dragged to bubble
         */
@@ -362,6 +372,7 @@ public class BubbleTransitions {
                        (int) mDragData.getDragPosition().y);
                startTransaction.setScale(mSnapshot, mDragData.getTaskScale(),
                        mDragData.getTaskScale());
                startTransaction.setCornerRadius(mSnapshot, mDragData.getCornerRadius());
            }

            // Now update state (and talk to launcher) in parallel with snapshot stuff
@@ -377,12 +388,6 @@ public class BubbleTransitions {
            startTransaction.setPosition(mSnapshot, left, top);
            startTransaction.setLayer(mSnapshot, Integer.MAX_VALUE);

            BubbleBarExpandedView bbev = mBubble.getBubbleBarExpandedView();
            if (bbev != null) {
                // Corners get reset during the animation. Add them back
                startTransaction.setCornerRadius(mSnapshot, bbev.getRestingCornerRadius());
            }

            startTransaction.apply();

            mTaskViewTransitions.onExternalDone(transition);
+4 −2
Original line number Diff line number Diff line
@@ -327,8 +327,9 @@ sealed class DragToDesktopTransitionHandler(
        val taskInfo = state.draggedTaskChange?.taskInfo ?: error("Expected non-null taskInfo")
        val dragPosition = PointF(state.dragAnimator.position)
        val scale = state.dragAnimator.scale
        val cornerRadius = state.dragAnimator.cornerRadius
        state.dragAnimator.cancelAnimator()
        requestBubble(wct, taskInfo, onLeft, scale, dragPosition)
        requestBubble(wct, taskInfo, onLeft, scale, cornerRadius, dragPosition)
    }

    private fun requestBubble(
@@ -336,13 +337,14 @@ sealed class DragToDesktopTransitionHandler(
        taskInfo: RunningTaskInfo,
        onLeft: Boolean,
        taskScale: Float = 1f,
        cornerRadius: Float = 0f,
        dragPosition: PointF = PointF(0f, 0f),
    ) {
        val controller =
            bubbleController.orElseThrow { IllegalStateException("BubbleController not set") }
        controller.expandStackAndSelectBubble(
            taskInfo,
            BubbleTransitions.DragData(onLeft, taskScale, dragPosition, wct),
            BubbleTransitions.DragData(onLeft, taskScale, cornerRadius, dragPosition, wct),
        )
    }

+2 −2
Original line number Diff line number Diff line
@@ -42,8 +42,6 @@ class MoveToDesktopAnimator @JvmOverloads constructor(
            .setDuration(ANIMATION_DURATION.toLong())
            .apply {
                val t = SurfaceControl.Transaction()
                val cornerRadius = context.resources
                    .getDimensionPixelSize(R.dimen.desktop_mode_dragged_task_radius).toFloat()
                addUpdateListener {
                    setTaskPosition(mostRecentInput.x, mostRecentInput.y)
                    t.setScale(taskSurface, scale, scale)
@@ -57,6 +55,8 @@ class MoveToDesktopAnimator @JvmOverloads constructor(

    val taskId get() = taskInfo.taskId
    val position: PointF = PointF(0.0f, 0.0f)
    val cornerRadius: Float = context.resources
        .getDimensionPixelSize(R.dimen.desktop_mode_dragged_task_radius).toFloat()

    /**
     * Whether motion events from the drag gesture should affect the dragged surface or not. Used
+4 −2
Original line number Diff line number Diff line
@@ -221,8 +221,8 @@ public class BubbleTransitionsTest extends ShellTestCase {

        PointF dragPosition = new PointF(10f, 20f);
        BubbleTransitions.DragData dragData = new BubbleTransitions.DragData(
                /* releasedOnLeft= */ false, /* taskScale= */ 0.5f, dragPosition,
                pendingWct);
                /* releasedOnLeft= */ false, /* taskScale= */ 0.5f, /* cornerRadius= */ 10f,
                dragPosition, pendingWct);

        final BubbleTransitions.BubbleTransition bt = mBubbleTransitions.startConvertToBubble(
                mBubble, taskInfo, mExpandedViewManager, mTaskViewFactory, mBubblePositioner,
@@ -253,6 +253,8 @@ public class BubbleTransitionsTest extends ShellTestCase {
        verify(startT).setPosition(snapshot, dragPosition.x, dragPosition.y);
        // Snapshot has the scale of the dragged task
        verify(startT).setScale(snapshot, dragData.getTaskScale(), dragData.getTaskScale());
        // Snapshot has dragged task corner radius
        verify(startT).setCornerRadius(snapshot, dragData.getCornerRadius());
    }

    @Test