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

Commit 7ae6f4ac authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Android (Google) Code Review
Browse files

Merge "Merge "Relayout resize veil before showing" into udc-dev am: 20a482cb am: bfdfaa38"

parents df9ddae1 ea33ee6a
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -296,15 +296,15 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
    /**
    /**
     * Fade in the resize veil
     * Fade in the resize veil
     */
     */
    void showResizeVeil() {
    void showResizeVeil(Rect taskBounds) {
        mResizeVeil.showVeil(mTaskSurface);
        mResizeVeil.showVeil(mTaskSurface, taskBounds);
    }
    }


    /**
    /**
     * Set new bounds for the resize veil
     * Set new bounds for the resize veil
     */
     */
    void updateResizeVeil(Rect newBounds) {
    void updateResizeVeil(Rect newBounds) {
        mResizeVeil.relayout(newBounds);
        mResizeVeil.updateResizeVeil(newBounds);
    }
    }


    /**
    /**
+17 −6
Original line number Original line Diff line number Diff line
@@ -104,7 +104,7 @@ public class ResizeVeil {
    /**
    /**
     * Animate veil's alpha to 1, fading it in.
     * Animate veil's alpha to 1, fading it in.
     */
     */
    public void showVeil(SurfaceControl parentSurface) {
    public void showVeil(SurfaceControl parentSurface, Rect taskBounds) {
        // Parent surface can change, ensure it is up to date.
        // Parent surface can change, ensure it is up to date.
        SurfaceControl.Transaction t = mSurfaceControlTransactionSupplier.get();
        SurfaceControl.Transaction t = mSurfaceControlTransactionSupplier.get();
        if (!parentSurface.equals(mParentSurface)) {
        if (!parentSurface.equals(mParentSurface)) {
@@ -115,8 +115,6 @@ public class ResizeVeil {
        int backgroundColorId = getBackgroundColorId();
        int backgroundColorId = getBackgroundColorId();
        mViewHost.getView().setBackgroundColor(mContext.getColor(backgroundColorId));
        mViewHost.getView().setBackgroundColor(mContext.getColor(backgroundColorId));


        t.show(mVeilSurface)
                .apply();
        final ValueAnimator animator = new ValueAnimator();
        final ValueAnimator animator = new ValueAnimator();
        animator.setFloatValues(0f, 1f);
        animator.setFloatValues(0f, 1f);
        animator.setDuration(RESIZE_ALPHA_DURATION);
        animator.setDuration(RESIZE_ALPHA_DURATION);
@@ -124,19 +122,32 @@ public class ResizeVeil {
            t.setAlpha(mVeilSurface, animator.getAnimatedFraction());
            t.setAlpha(mVeilSurface, animator.getAnimatedFraction());
            t.apply();
            t.apply();
        });
        });
        animator.start();

        relayout(taskBounds, t);
        t.show(mVeilSurface)
                .addTransactionCommittedListener(mContext.getMainExecutor(), () -> animator.start())
                .setAlpha(mVeilSurface, 0);
        mViewHost.getView().getViewRootImpl().applyTransactionOnDraw(t);
    }
    }


    /**
    /**
     * Update veil bounds to match bounds changes.
     * Update veil bounds to match bounds changes.
     * @param newBounds bounds to update veil to.
     * @param newBounds bounds to update veil to.
     */
     */
    public void relayout(Rect newBounds) {
    private void relayout(Rect newBounds, SurfaceControl.Transaction t) {
        SurfaceControl.Transaction t = mSurfaceControlTransactionSupplier.get();
        mViewHost.relayout(newBounds.width(), newBounds.height());
        mViewHost.relayout(newBounds.width(), newBounds.height());
        t.setWindowCrop(mVeilSurface, newBounds.width(), newBounds.height());
        t.setWindowCrop(mVeilSurface, newBounds.width(), newBounds.height());
        t.setPosition(mParentSurface, newBounds.left, newBounds.top);
        t.setPosition(mParentSurface, newBounds.left, newBounds.top);
        t.setWindowCrop(mParentSurface, newBounds.width(), newBounds.height());
        t.setWindowCrop(mParentSurface, newBounds.width(), newBounds.height());
    }

    /**
     * Calls relayout to update task and veil bounds.
     * @param newBounds bounds to update veil to.
     */
    public void updateResizeVeil(Rect newBounds) {
        SurfaceControl.Transaction t = mSurfaceControlTransactionSupplier.get();
        relayout(newBounds, t);
        mViewHost.getView().getViewRootImpl().applyTransactionOnDraw(t);
        mViewHost.getView().getViewRootImpl().applyTransactionOnDraw(t);
    }
    }


+1 −1
Original line number Original line Diff line number Diff line
@@ -77,7 +77,7 @@ public class VeiledResizeTaskPositioner implements DragPositioningCallback {
                mDesktopWindowDecoration.mTaskInfo.configuration.windowConfiguration.getBounds());
                mDesktopWindowDecoration.mTaskInfo.configuration.windowConfiguration.getBounds());
        mRepositionStartPoint.set(x, y);
        mRepositionStartPoint.set(x, y);
        if (isResizing()) {
        if (isResizing()) {
            mDesktopWindowDecoration.showResizeVeil();
            mDesktopWindowDecoration.showResizeVeil(mTaskBoundsAtDragStart);
            if (!mDesktopWindowDecoration.mTaskInfo.isFocused) {
            if (!mDesktopWindowDecoration.mTaskInfo.isFocused) {
                WindowContainerTransaction wct = new WindowContainerTransaction();
                WindowContainerTransaction wct = new WindowContainerTransaction();
                wct.reorder(mDesktopWindowDecoration.mTaskInfo.token, true);
                wct.reorder(mDesktopWindowDecoration.mTaskInfo.token, true);
+3 −3
Original line number Original line Diff line number Diff line
@@ -123,7 +123,7 @@ class VeiledResizeTaskPositionerTest : ShellTestCase() {
            STARTING_BOUNDS.left.toFloat(),
            STARTING_BOUNDS.left.toFloat(),
            STARTING_BOUNDS.top.toFloat()
            STARTING_BOUNDS.top.toFloat()
        )
        )
        verify(mockDesktopWindowDecoration).showResizeVeil()
        verify(mockDesktopWindowDecoration).showResizeVeil(STARTING_BOUNDS)


        taskPositioner.onDragPositioningEnd(
        taskPositioner.onDragPositioningEnd(
            STARTING_BOUNDS.left.toFloat(),
            STARTING_BOUNDS.left.toFloat(),
@@ -180,7 +180,7 @@ class VeiledResizeTaskPositionerTest : ShellTestCase() {
            STARTING_BOUNDS.right.toFloat(),
            STARTING_BOUNDS.right.toFloat(),
            STARTING_BOUNDS.top.toFloat()
            STARTING_BOUNDS.top.toFloat()
        )
        )
        verify(mockDesktopWindowDecoration).showResizeVeil()
        verify(mockDesktopWindowDecoration).showResizeVeil(STARTING_BOUNDS)


        taskPositioner.onDragPositioningMove(
        taskPositioner.onDragPositioningMove(
            STARTING_BOUNDS.right.toFloat() + 10,
            STARTING_BOUNDS.right.toFloat() + 10,
@@ -224,7 +224,7 @@ class VeiledResizeTaskPositionerTest : ShellTestCase() {
            STARTING_BOUNDS.left.toFloat(),
            STARTING_BOUNDS.left.toFloat(),
            STARTING_BOUNDS.top.toFloat()
            STARTING_BOUNDS.top.toFloat()
        )
        )
        verify(mockDesktopWindowDecoration).showResizeVeil()
        verify(mockDesktopWindowDecoration).showResizeVeil(STARTING_BOUNDS)


        taskPositioner.onDragPositioningMove(
        taskPositioner.onDragPositioningMove(
            STARTING_BOUNDS.left.toFloat(),
            STARTING_BOUNDS.left.toFloat(),