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

Commit 499103ae authored by Maryam Dehaini's avatar Maryam Dehaini
Browse files

Set Freeform corner radius to match spec

Bug: 369592605
Test: manual testing
Flag: EXEMPT bugfix
Change-Id: I2304efe2bb5c65803167ce94e9ef30eeaa6ce62d
parent f723deaa
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -661,4 +661,7 @@
    <dimen name="desktop_windowing_education_promo_height">352dp</dimen>
    <!-- The corner radius of the desktop windowing education promo. -->
    <dimen name="desktop_windowing_education_promo_corner_radius">28dp</dimen>

    <!-- The corner radius of freeform tasks in desktop windowing. -->
    <dimen name="desktop_windowing_freeform_rounded_corner_radius">16dp</dimen>
</resources>
+4 −3
Original line number Diff line number Diff line
@@ -81,7 +81,6 @@ import android.window.TaskSnapshot;
import android.window.WindowContainerTransaction;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.policy.ScreenDecorationsUtils;
import com.android.launcher3.icons.BaseIconFactory;
import com.android.launcher3.icons.IconProvider;
import com.android.window.flags.Flags;
@@ -1008,8 +1007,10 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
        relayoutParams.mWindowDecorConfig = windowDecorConfig;

        if (DesktopModeStatus.useRoundedCorners()) {
            relayoutParams.mCornerRadius =
                    (int) ScreenDecorationsUtils.getWindowCornerRadius(context);
            relayoutParams.mCornerRadius = taskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM
                    ? loadDimensionPixelSize(context.getResources(),
                    R.dimen.desktop_windowing_freeform_rounded_corner_radius)
                    : INVALID_CORNER_RADIUS;
        }
    }

+18 −11
Original line number Diff line number Diff line
@@ -106,6 +106,11 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
     */
    static final int INPUT_SINK_Z_ORDER = -2;

    /**
     * Invalid corner radius that signifies that corner radius should not be set.
     */
    static final int INVALID_CORNER_RADIUS = -1;

    /**
     * System-wide context. Only used to create context with overridden configurations.
     */
@@ -449,19 +454,21 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
            startT.show(mTaskSurface);
        }

        if (mTaskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM) {
            if (!DesktopModeStatus.isVeiledResizeEnabled()) {
        if (mTaskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM
                && !DesktopModeStatus.isVeiledResizeEnabled()) {
            // When fluid resize is enabled, add a background to freeform tasks
            int backgroundColorInt = mTaskInfo.taskDescription.getBackgroundColor();
            mTmpColor[0] = (float) Color.red(backgroundColorInt) / 255.f;
            mTmpColor[1] = (float) Color.green(backgroundColorInt) / 255.f;
            mTmpColor[2] = (float) Color.blue(backgroundColorInt) / 255.f;
            startT.setColor(mTaskSurface, mTmpColor);
        } else if (!DesktopModeStatus.isVeiledResizeEnabled()) {
            startT.unsetColor(mTaskSurface);
        }

        if (params.mCornerRadius != INVALID_CORNER_RADIUS) {
            startT.setCornerRadius(mTaskSurface, params.mCornerRadius);
            finishT.setCornerRadius(mTaskSurface, params.mCornerRadius);
        } else if (!DesktopModeStatus.isVeiledResizeEnabled()) {
            startT.unsetColor(mTaskSurface);
        }
    }

+26 −1
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import static android.view.WindowInsetsController.APPEARANCE_TRANSPARENT_CAPTION
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession;
import static com.android.wm.shell.MockSurfaceControlHelper.createMockSurfaceControlTransaction;
import static com.android.wm.shell.windowdecor.DesktopModeWindowDecoration.CLOSE_MAXIMIZE_MENU_DELAY_MS;
import static com.android.wm.shell.windowdecor.WindowDecoration.INVALID_CORNER_RADIUS;

import static com.google.common.truth.Truth.assertThat;

@@ -312,8 +313,9 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
    }

    @Test
    public void updateRelayoutParams_noSysPropFlagsSet_roundedCornersAreEnabled() {
    public void updateRelayoutParams_noSysPropFlagsSet_roundedCornersSetForFreeform() {
        final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true);
        taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM);
        fillRoundedCornersResources(/* fillValue= */ 30);
        RelayoutParams relayoutParams = new RelayoutParams();

@@ -333,6 +335,29 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
        assertThat(relayoutParams.mCornerRadius).isGreaterThan(0);
    }

    @Test
    public void updateRelayoutParams_noSysPropFlagsSet_roundedCornersNotSetForFullscreen() {
        final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true);
        taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN);
        fillRoundedCornersResources(/* fillValue= */ 30);
        RelayoutParams relayoutParams = new RelayoutParams();

        DesktopModeWindowDecoration.updateRelayoutParams(
                relayoutParams,
                mTestableContext,
                taskInfo,
                /* applyStartTransactionOnDraw= */ true,
                /* shouldSetTaskPositionAndCrop */ false,
                /* isStatusBarVisible */ true,
                /* isKeyguardVisibleAndOccluded */ false,
                /* inFullImmersiveMode */ false,
                new InsetsState(),
                /* hasGlobalFocus= */ true,
                mExclusionRegion);

        assertThat(relayoutParams.mCornerRadius).isEqualTo(INVALID_CORNER_RADIUS);
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_APP_HEADER_WITH_TASK_DENSITY)
    public void updateRelayoutParams_appHeader_usesTaskDensity() {