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

Commit 624bcf60 authored by András Kurucz's avatar András Kurucz Committed by Android (Google) Code Review
Browse files

Merge "[Flexiglass] Make NSSL QS clip bounds rounded on top" into main

parents d93ecf61 521f7b85
Loading
Loading
Loading
Loading
+11 −17
Original line number Diff line number Diff line
@@ -41,8 +41,6 @@ import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.layout.boundsInWindow
import androidx.compose.ui.layout.onPlaced
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
@@ -86,6 +84,7 @@ import com.android.systemui.statusbar.notification.stack.ui.viewmodel.Notificati
import com.android.systemui.volume.panel.component.volume.ui.composable.VolumeSlider
import dagger.Lazy
import javax.inject.Inject
import kotlin.math.roundToInt
import kotlinx.coroutines.awaitCancellation
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.Flow
@@ -135,8 +134,6 @@ constructor(
                notificationsPlaceholderViewModelFactory.create()
            }

        val panelCornerRadius =
            with(LocalDensity.current) { OverlayShade.Dimensions.PanelCornerRadius.toPx().toInt() }
        val showBrightnessMirror =
            quickSettingsContainerViewModel.brightnessSliderViewModel.showMirror
        val contentAlphaFromBrightnessMirror by
@@ -151,6 +148,15 @@ constructor(
                alignmentOnWideScreens = Alignment.TopEnd,
                enableTransparency = quickSettingsContainerViewModel.isTransparencyEnabled,
                onScrimClicked = contentViewModel::onScrimClicked,
                onBackgroundPlaced = { bounds, topCornerRadius, bottomCornerRadius ->
                    contentViewModel.onPanelShapeChanged(
                        ShadeScrimShape(
                            bounds = ShadeScrimBounds(bounds),
                            topRadius = topCornerRadius.roundToInt(),
                            bottomRadius = bottomCornerRadius.roundToInt(),
                        )
                    )
                },
                header = {
                    OverlayShadeHeader(
                        viewModel = quickSettingsContainerViewModel.shadeHeaderViewModel,
@@ -161,19 +167,7 @@ constructor(
                    )
                },
            ) {
                QuickSettingsContainer(
                    viewModel = quickSettingsContainerViewModel,
                    modifier =
                        Modifier.onPlaced { coordinates ->
                            val shape =
                                ShadeScrimShape(
                                    bounds = ShadeScrimBounds(coordinates.boundsInWindow()),
                                    topRadius = 0,
                                    bottomRadius = panelCornerRadius,
                                )
                            contentViewModel.onPanelShapeChanged(shape)
                        },
                )
                QuickSettingsContainer(viewModel = quickSettingsContainerViewModel)
            }
            SnoozeableHeadsUpNotificationSpace(
                stackScrollView = notificationStackScrollView.get(),
+26 −2
Original line number Diff line number Diff line
@@ -35,8 +35,12 @@ import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.boundsInWindow
import androidx.compose.ui.layout.onPlaced
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.unit.Dp
import com.android.compose.animation.scene.ContentScope
@@ -50,6 +54,7 @@ import com.android.systemui.res.R
import com.android.systemui.shade.ui.ShadeColors.shadePanel
import com.android.systemui.shade.ui.ShadeColors.shadePanelScrimBehind
import com.android.systemui.shade.ui.composable.OverlayShade.rememberShadeExpansionMotion
import kotlin.math.min

/** Renders a lightweight shade UI container, as an overlay. */
@Composable
@@ -59,10 +64,15 @@ fun ContentScope.OverlayShade(
    enableTransparency: Boolean,
    onScrimClicked: () -> Unit,
    modifier: Modifier = Modifier,
    onBackgroundPlaced: (bounds: Rect, topCornerRadius: Float, bottomCornerRadius: Float) -> Unit =
        { _, _, _ ->
        },
    header: @Composable () -> Unit,
    content: @Composable () -> Unit,
) {
    val isFullWidth = isFullWidthShade()
    val panelSpec = rememberShadeExpansionMotion(isFullWidth)
    val panelCornerRadiusPx = with(LocalDensity.current) { panelSpec.radius.toPx() }
    Box(modifier) {
        Scrim(showBackgroundColor = enableTransparency, onClicked = onScrimClicked)

@@ -72,10 +82,23 @@ fun ContentScope.OverlayShade(
        ) {
            Panel(
                enableTransparency = enableTransparency,
                spec = panelSpec,
                modifier =
                    Modifier.overscroll(verticalOverscrollEffect)
                        .element(panelElement)
                        .panelWidth(isFullWidth),
                        .panelWidth(isFullWidth)
                        .onPlaced { coordinates ->
                            val bounds = coordinates.boundsInWindow()
                            val isTopRounded = panelSpec.isFloating
                            val bottomCornerRadius: Float =
                                if (isTopRounded) {
                                    min(panelCornerRadiusPx, bounds.height / 2)
                                } else {
                                    min(panelCornerRadiusPx, bounds.height)
                                }
                            val topCornerRadius = if (isTopRounded) bottomCornerRadius else 0f
                            onBackgroundPlaced(bounds, topCornerRadius, bottomCornerRadius)
                        },
                header = header.takeIf { isFullWidth },
                content = content,
            )
@@ -107,6 +130,7 @@ private fun ContentScope.Scrim(
@Composable
private fun ContentScope.Panel(
    enableTransparency: Boolean,
    spec: VerticalExpandContainerSpec,
    modifier: Modifier = Modifier,
    header: (@Composable () -> Unit)?,
    content: @Composable () -> Unit,
@@ -117,7 +141,7 @@ private fun ContentScope.Panel(
                .disableSwipesWhenScrolling()
                .verticalExpandContainerBackground(
                    backgroundColor = OverlayShade.Colors.panelBackground(enableTransparency),
                    spec = rememberShadeExpansionMotion(isFullWidthShade()),
                    spec = spec,
                )
    ) {
        Column {
+3 −1
Original line number Diff line number Diff line
@@ -5992,10 +5992,12 @@ public class NotificationStackScrollLayout
        mNegativeRoundedClipPath.reset();
        if (shape != null) {
            ShadeScrimBounds bounds = shape.getBounds();
            float topRadius = shape.getTopRadius();
            float bottomRadius = shape.getBottomRadius();
            mNegativeRoundedClipPath.addRoundRect(
                    bounds.getLeft(), bounds.getTop(), bounds.getRight(), bounds.getBottom(),
                    new float[]{0, 0, 0, 0, bottomRadius, bottomRadius, bottomRadius, bottomRadius},
                    new float[]{topRadius, topRadius, topRadius, topRadius,
                            bottomRadius, bottomRadius, bottomRadius, bottomRadius},
                    Path.Direction.CW);
        }
        invalidate();