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

Commit 8714560b authored by Rahul Banerjee's avatar Rahul Banerjee Committed by Android (Google) Code Review
Browse files

Merge "Enable transparency on Flexiglass Single Shade" into main

parents cae17f5a 018fa227
Loading
Loading
Loading
Loading
+13 −21
Original line number Diff line number Diff line
@@ -50,7 +50,6 @@ import androidx.compose.foundation.layout.windowInsetsBottomHeight
import androidx.compose.foundation.overscroll
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
@@ -64,9 +63,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.graphics.BlendMode
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
@@ -314,7 +311,8 @@ fun ContentScope.NotificationScrollingStack(
    val density = LocalDensity.current
    val screenCornerRadius = LocalScreenCornerRadius.current
    val scrimCornerRadius = dimensionResource(R.dimen.notification_scrim_corner_radius)
    val scrimBackgroundColor = MaterialTheme.colorScheme.surface
    // TODO(b/428779792): update color to match BC25 spec
    val surfaceEffect0Color = Color.Gray.copy(alpha = 0.5f)
    val scrollState =
        shadeSession.rememberSaveableSession(saver = ScrollState.Saver, key = "ScrollState") {
            ScrollState(initial = 0)
@@ -609,27 +607,21 @@ fun ContentScope.NotificationScrollingStack(
                    Modifier.clickable(onClick = { onEmptySpaceClick?.invoke() })
                }
    ) {
        // Creates a cutout in the background scrim in the shape of the notifications scrim.
        // Only visible when notif scrim alpha < 1, during shade expansion.
        if (shouldPunchHoleBehindScrim) {
            Spacer(
                modifier =
                    Modifier.fillMaxSize().drawBehind {
                        drawRect(Color.Black, blendMode = BlendMode.DstOut)
                    }
            )
        }
        Box(
            modifier =
                Modifier.graphicsLayer {
                    alpha =
                            if (shouldPunchHoleBehindScrim) {
                        (expansionFraction / EXPANSION_FOR_MAX_SCRIM_ALPHA).coerceAtMost(1f)
                            } else 1f
                    }
                    .thenIf(shouldShowScrim) { Modifier.background(scrimBackgroundColor) }
                    .thenIf(shouldFillMaxSize) { Modifier.fillMaxSize() }
                    .thenIf(supportNestedScrolling) { Modifier.padding(bottom = minScrimTop) }
                    .thenIf(shouldShowScrim) {
                        Modifier.background(surfaceEffect0Color)
                    }
                    .thenIf(shouldFillMaxSize) {
                        Modifier.fillMaxSize()
                    }
                    .thenIf(supportNestedScrolling) {
                        Modifier.padding(bottom = minScrimTop)
                    }
                    .debugBackground(viewModel, DEBUG_BOX_COLOR)
        ) {
            Column(
+3 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import com.android.systemui.media.controls.ui.composable.MediaCarousel
import com.android.systemui.notifications.ui.composable.Notifications
import com.android.systemui.qs.ui.composable.QuickSettings
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.ui.composable.Shade
import com.android.systemui.shade.ui.composable.ShadeHeader
import kotlin.time.Duration.Companion.milliseconds

@@ -42,6 +43,8 @@ fun TransitionBuilder.toShadeTransition(durationScale: Double = 1.0) {
        fade(QuickSettings.Elements.FooterActions)
    }

    fade(Shade.Elements.BackgroundScrim)

    val qsTranslation = -ShadeHeader.Dimensions.CollapsedHeightForTransitions * 0.66f
    translate(QuickSettings.Elements.QuickQuickSettings, y = qsTranslation)
    translate(MediaCarousel.Elements.Content, y = qsTranslation)
+5 −10
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.CompositingStrategy
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.layout.layoutId
@@ -252,6 +252,8 @@ private fun ContentScope.SingleShade(
) {
    val cutoutLocation = LocalDisplayCutout.current().location
    val cutoutInsets = WindowInsets.Companion.displayCutout
    // TODO(b/428779792): update color to match BC25 spec
    val shadePanelColor = Color.Gray.copy(alpha = 0.32f)
    mediaHost.expansion = if (usingCollapsedLandscapeMedia && isLandscape()) COLLAPSED else EXPANDED

    var maxNotifScrimTop by remember { mutableIntStateOf(0) }
@@ -303,19 +305,12 @@ private fun ContentScope.SingleShade(
            )
        }

    Box(
        modifier =
            modifier.thenIf(shouldPunchHoleBehindScrim) {
                // Render the scene to an offscreen buffer so that BlendMode.DstOut only clears this
                // scene (and not the one under it) during a scene transition.
                Modifier.graphicsLayer(compositingStrategy = CompositingStrategy.Offscreen)
            }
    ) {
    Box() {
        Box(
            modifier =
                Modifier.fillMaxSize()
                    .element(Shade.Elements.BackgroundScrim)
                    .background(colorResource(R.color.shade_scrim_background_dark))
                    .background(shadePanelColor)
        )
        Layout(
            modifier =