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

Commit 66112141 authored by Jeff DeCew's avatar Jeff DeCew
Browse files

[flexiglass] Use null bounds to disable the clipping in the NSSL.

Bug: 296118689
Test: atest SystemUITests
Flag: ACONFIG com.android.systemui.scene_container DEVELOPMENT
Change-Id: Ia9b6396d7efbc69114ff02eacfca9b1e4fa36dc3
parent 8e40ecb1
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
@@ -73,6 +74,7 @@ import com.android.systemui.notifications.ui.composable.Notifications.Transition
import com.android.systemui.res.R
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.ui.composable.ShadeHeader
import com.android.systemui.statusbar.notification.stack.shared.model.ShadeScrimBounds
import com.android.systemui.statusbar.notification.stack.shared.model.ShadeScrimRounding
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationsPlaceholderViewModel
import kotlin.math.roundToInt
@@ -187,6 +189,9 @@ fun SceneScope.NotificationScrollingStack(
    // entire height of the scrim is visible on screen.
    val scrimOffset = remember { mutableStateOf(0f) }

    // set the bounds to null when the scrim disappears
    DisposableEffect(Unit) { onDispose { viewModel.onScrimBoundsChanged(null) } }

    val minScrimTop = with(density) { ShadeHeader.Dimensions.CollapsedHeight.toPx() }

    // The minimum offset for the scrim. The scrim is considered fully expanded when it
@@ -261,11 +266,13 @@ fun SceneScope.NotificationScrollingStack(
                            " bounds=$boundsInWindow"
                    }
                    viewModel.onScrimBoundsChanged(
                        ShadeScrimBounds(
                            left = boundsInWindow.left,
                            top = boundsInWindow.top,
                            right = boundsInWindow.right,
                            bottom = boundsInWindow.bottom,
                        )
                    )
                }
    ) {
        // Creates a cutout in the background scrim in the shape of the notifications scrim.
+2 −8
Original line number Diff line number Diff line
@@ -71,10 +71,7 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() {
            val shape by collectLastValue(appearanceViewModel.shadeScrimShape(radius, viewPosition))

            placeholderViewModel.onScrimBoundsChanged(
                left = 0f,
                top = 200f,
                right = 100f,
                bottom = 550f
                ShadeScrimBounds(left = 0f, top = 200f, right = 100f, bottom = 550f)
            )
            assertThat(shape)
                .isEqualTo(
@@ -89,10 +86,7 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() {
            viewPosition.value = ViewPosition(200, 15)
            radius.value = 24
            placeholderViewModel.onScrimBoundsChanged(
                left = 210f,
                top = 200f,
                right = 300f,
                bottom = 550f
                ShadeScrimBounds(left = 210f, top = 200f, right = 300f, bottom = 550f)
            )
            assertThat(shape)
                .isEqualTo(
+3 −7
Original line number Diff line number Diff line
@@ -16,14 +16,10 @@

package com.android.systemui.statusbar.notification.stack.ui.viewmodel

import android.platform.test.annotations.DisableFlags
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
import com.android.systemui.common.shared.model.NotificationContainerBounds
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.keyguard.domain.interactor.keyguardInteractor
import com.android.systemui.kosmos.testScope
import com.android.systemui.statusbar.notification.stack.domain.interactor.notificationStackAppearanceInteractor
import com.android.systemui.statusbar.notification.stack.shared.model.ShadeScrimBounds
@@ -42,11 +38,11 @@ class NotificationsPlaceholderViewModelTest : SysuiTestCase() {
    @Test
    fun onBoundsChanged() =
        kosmos.testScope.runTest {
            underTest.onScrimBoundsChanged(left = 5f, top = 15f, right = 25f, bottom = 35f)
            val bounds = ShadeScrimBounds(left = 5f, top = 15f, right = 25f, bottom = 35f)
            underTest.onScrimBoundsChanged(bounds)
            val stackBounds by
                collectLastValue(kosmos.notificationStackAppearanceInteractor.shadeScrimBounds)
            assertThat(stackBounds)
                .isEqualTo(ShadeScrimBounds(left = 5f, top = 15f, right = 25f, bottom = 35f))
            assertThat(stackBounds).isEqualTo(bounds)
        }

    @Test
+40 −0
Original line number Diff line number Diff line
@@ -113,6 +113,8 @@ import com.android.systemui.statusbar.notification.row.ExpandableView;
import com.android.systemui.statusbar.notification.row.StackScrollerDecorView;
import com.android.systemui.statusbar.notification.shared.NotificationsImprovedHunAnimation;
import com.android.systemui.statusbar.notification.shared.NotificationsLiveDataStoreRefactor;
import com.android.systemui.statusbar.notification.stack.shared.model.ShadeScrimBounds;
import com.android.systemui.statusbar.notification.stack.shared.model.ShadeScrimShape;
import com.android.systemui.statusbar.notification.stack.ui.view.NotificationStackView;
import com.android.systemui.statusbar.phone.HeadsUpAppearanceController;
import com.android.systemui.statusbar.phone.HeadsUpTouchHelper;
@@ -136,6 +138,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.function.BiConsumer;
@@ -512,6 +515,9 @@ public class NotificationStackScrollLayout
    private int mRoundedRectClippingRight;
    private final float[] mBgCornerRadii = new float[8];

    /** Shape used for defining the shade scrim with SceneContainerFlag enabled */
    private ShadeScrimShape mShadeScrimShape = null;

    /**
     * Whether stackY should be animated in case the view is getting shorter than the scroll
     * position and this scrolling will lead to the top scroll inset getting smaller.
@@ -5020,6 +5026,7 @@ public class NotificationStackScrollLayout
            println(pw, "topPadding", getTopPadding());
            println(pw, "bottomPadding", mBottomPadding);
            dumpRoundedRectClipping(pw);
            println(pw, "shadeScrimShape", mShadeScrimShape);
            println(pw, "requestedClipBounds", mRequestedClipBounds);
            println(pw, "isClipped", mIsClipped);
            println(pw, "translationX", getTranslationX());
@@ -5579,11 +5586,43 @@ public class NotificationStackScrollLayout
        mScrollListener = listener;
    }

    /**
     * Set rounded rect clipping bounds on this view.
     */
    @Override
    public void setScrimClippingShape(@Nullable ShadeScrimShape shape) {
        if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return;
        if (Objects.equals(mShadeScrimShape, shape)) return;
        mShadeScrimShape = shape;
        mShouldUseRoundedRectClipping = shape != null;
        mRoundedClipPath.reset();
        if (shape != null) {
            ShadeScrimBounds bounds = shape.getBounds();
            mRoundedRectClippingLeft = (int) bounds.getLeft();
            mRoundedRectClippingTop = (int) bounds.getTop();
            mRoundedRectClippingRight = (int) bounds.getRight();
            mRoundedRectClippingBottom = (int) bounds.getBottom();
            mBgCornerRadii[0] = shape.getTopRadius();
            mBgCornerRadii[1] = shape.getTopRadius();
            mBgCornerRadii[2] = shape.getTopRadius();
            mBgCornerRadii[3] = shape.getTopRadius();
            mBgCornerRadii[4] = shape.getBottomRadius();
            mBgCornerRadii[5] = shape.getBottomRadius();
            mBgCornerRadii[6] = shape.getBottomRadius();
            mBgCornerRadii[7] = shape.getBottomRadius();
            mRoundedClipPath.addRoundRect(
                    bounds.getLeft(), bounds.getTop(), bounds.getRight(), bounds.getBottom(),
                    mBgCornerRadii, Path.Direction.CW);
        }
        invalidate();
    }

    /**
     * Set rounded rect clipping bounds on this view.
     */
    public void setRoundedClippingBounds(int left, int top, int right, int bottom, int topRadius,
                                         int bottomRadius) {
        SceneContainerFlag.assertInLegacyMode();
        if (mRoundedRectClippingLeft == left && mRoundedRectClippingRight == right
                && mRoundedRectClippingBottom == bottom && mRoundedRectClippingTop == top
                && mBgCornerRadii[0] == topRadius && mBgCornerRadii[5] == bottomRadius) {
@@ -5661,6 +5700,7 @@ public class NotificationStackScrollLayout
     * Should we use rounded rect clipping
     */
    private void updateUseRoundedRectClipping() {
        if (SceneContainerFlag.isEnabled()) return;
        // We don't want to clip notifications when QS is expanded, because incoming heads up on
        // the bottom would be clipped otherwise
        boolean qsAllowsClipping = mQsExpansionFraction < 0.5f || mShouldUseSplitNotificationShade;
+6 −2
Original line number Diff line number Diff line
@@ -27,8 +27,12 @@ import kotlinx.coroutines.flow.MutableStateFlow
 */
@SysUISingleton
class NotificationPlaceholderRepository @Inject constructor() {
    /** The bounds of the notification shade scrim / container in the current scene. */
    val shadeScrimBounds = MutableStateFlow(ShadeScrimBounds())
    /**
     * The bounds of the notification shade scrim / container in the current scene.
     *
     * When `null`, clipping should not be applied to notifications.
     */
    val shadeScrimBounds = MutableStateFlow<ShadeScrimBounds?>(null)

    /**
     * The y-coordinate in px of top of the contents of the notification stack. This value can be
Loading