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

Commit 018fa227 authored by Rahul Banerjee's avatar Rahul Banerjee
Browse files

Enable transparency on Flexiglass Single Shade

Bug: 428779792
Test: Manual (build, push, expand/collapse shade)
Flag: EXEMPT not user facing
Change-Id: I8cde122899677b68b9eef47843304781ea6fc546
parent 31dd0cf5
Loading
Loading
Loading
Loading
+13 −21
Original line number Original line Diff line number Diff line
@@ -50,7 +50,6 @@ import androidx.compose.foundation.layout.windowInsetsBottomHeight
import androidx.compose.foundation.overscroll
import androidx.compose.foundation.overscroll
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.LaunchedEffect
@@ -64,9 +63,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshotFlow
import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.Alignment
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.graphics.BlendMode
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
@@ -314,7 +311,8 @@ fun ContentScope.NotificationScrollingStack(
    val density = LocalDensity.current
    val density = LocalDensity.current
    val screenCornerRadius = LocalScreenCornerRadius.current
    val screenCornerRadius = LocalScreenCornerRadius.current
    val scrimCornerRadius = dimensionResource(R.dimen.notification_scrim_corner_radius)
    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 =
    val scrollState =
        shadeSession.rememberSaveableSession(saver = ScrollState.Saver, key = "ScrollState") {
        shadeSession.rememberSaveableSession(saver = ScrollState.Saver, key = "ScrollState") {
            ScrollState(initial = 0)
            ScrollState(initial = 0)
@@ -609,27 +607,21 @@ fun ContentScope.NotificationScrollingStack(
                    Modifier.clickable(onClick = { onEmptySpaceClick?.invoke() })
                    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(
        Box(
            modifier =
            modifier =
                Modifier.graphicsLayer {
                Modifier.graphicsLayer {
                    alpha =
                    alpha =
                            if (shouldPunchHoleBehindScrim) {
                        (expansionFraction / EXPANSION_FOR_MAX_SCRIM_ALPHA).coerceAtMost(1f)
                        (expansionFraction / EXPANSION_FOR_MAX_SCRIM_ALPHA).coerceAtMost(1f)
                            } else 1f
                    }
                    }
                    .thenIf(shouldShowScrim) { Modifier.background(scrimBackgroundColor) }
                    .thenIf(shouldShowScrim) {
                    .thenIf(shouldFillMaxSize) { Modifier.fillMaxSize() }
                        Modifier.background(surfaceEffect0Color)
                    .thenIf(supportNestedScrolling) { Modifier.padding(bottom = minScrimTop) }
                    }
                    .thenIf(shouldFillMaxSize) {
                        Modifier.fillMaxSize()
                    }
                    .thenIf(supportNestedScrolling) {
                        Modifier.padding(bottom = minScrimTop)
                    }
                    .debugBackground(viewModel, DEBUG_BOX_COLOR)
                    .debugBackground(viewModel, DEBUG_BOX_COLOR)
        ) {
        ) {
            Column(
            Column(
+3 −0
Original line number Original line 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.notifications.ui.composable.Notifications
import com.android.systemui.qs.ui.composable.QuickSettings
import com.android.systemui.qs.ui.composable.QuickSettings
import com.android.systemui.scene.shared.model.Scenes
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 com.android.systemui.shade.ui.composable.ShadeHeader
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.milliseconds


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


    fade(Shade.Elements.BackgroundScrim)

    val qsTranslation = -ShadeHeader.Dimensions.CollapsedHeightForTransitions * 0.66f
    val qsTranslation = -ShadeHeader.Dimensions.CollapsedHeightForTransitions * 0.66f
    translate(QuickSettings.Elements.QuickQuickSettings, y = qsTranslation)
    translate(QuickSettings.Elements.QuickQuickSettings, y = qsTranslation)
    translate(MediaCarousel.Elements.Content, y = qsTranslation)
    translate(MediaCarousel.Elements.Content, y = qsTranslation)
+5 −10
Original line number Original line Diff line number Diff line
@@ -49,7 +49,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
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.graphics.graphicsLayer
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.layout.layoutId
import androidx.compose.ui.layout.layoutId
@@ -252,6 +252,8 @@ private fun ContentScope.SingleShade(
) {
) {
    val cutoutLocation = LocalDisplayCutout.current().location
    val cutoutLocation = LocalDisplayCutout.current().location
    val cutoutInsets = WindowInsets.Companion.displayCutout
    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
    mediaHost.expansion = if (usingCollapsedLandscapeMedia && isLandscape()) COLLAPSED else EXPANDED


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


    Box(
    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 =
                Modifier.fillMaxSize()
                Modifier.fillMaxSize()
                    .element(Shade.Elements.BackgroundScrim)
                    .element(Shade.Elements.BackgroundScrim)
                    .background(colorResource(R.color.shade_scrim_background_dark))
                    .background(shadePanelColor)
        )
        )
        Layout(
        Layout(
            modifier =
            modifier =