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

Commit a44dc9b7 authored by Rahul Banerjee's avatar Rahul Banerjee Committed by Fabián Kozynski
Browse files

Fix QS Background color, match spec

Fixes: 432333670
Test: Manual (build, push, expand/collapse shade, test with
both single and dual shade, light and dark mode)
Flag: com.android.systemui.scene_container

Change-Id: I39d1f28e402f94ebcc5f62e3fa6505fcf0f1219e
parent e8976188
Loading
Loading
Loading
Loading
+2 −11
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.systemui.qs.ui.composable

import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.background
import androidx.compose.foundation.clipScrollableContainer
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.layout.Box
@@ -50,7 +49,6 @@ import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
@@ -88,7 +86,7 @@ import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.scene.ui.composable.Scene
import com.android.systemui.shade.ui.composable.CollapsedShadeHeader
import com.android.systemui.shade.ui.composable.ExpandedShadeHeader
import com.android.systemui.shade.ui.composable.Shade
import com.android.systemui.shade.ui.composable.ShadePanelScrim
import com.android.systemui.shade.ui.viewmodel.ShadeHeaderViewModel
import com.android.systemui.statusbar.notification.stack.ui.view.NotificationScrollView
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationsPlaceholderViewModel
@@ -217,14 +215,7 @@ private fun ContentScope.QuickSettingsScene(
        val isMediaVisible = viewModel.qsContainerViewModel.showMedia
        val mediaInRow = isMediaVisible && isLandscape()

        // This is the background for the whole scene, as the elements don't necessarily provide
        // a background that extends to the edges.
        Spacer(
            modifier =
                Modifier.element(Shade.Elements.BackgroundScrim)
                    .fillMaxSize()
                    .background(colorResource(R.color.shade_scrim_background_dark))
        )
        ShadePanelScrim(viewModel.isTransparencyEnabled)
        Column(
            horizontalAlignment = Alignment.CenterHorizontally,
            modifier =
+57 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.shade.ui.composable

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import com.android.compose.animation.scene.ContentScope
import com.android.systemui.shade.ui.ShadeColors

/** Scrim for QS/Shade, this will fill the max size, so it should be inside a Box like layout. */
@Composable
fun ContentScope.ShadePanelScrim(isTransparencyEnabled: Boolean, modifier: Modifier = Modifier) {
    // This is the background for the whole scene, as the elements don't necessarily provide
    // a background that extends to the edges.
    Spacer(
        modifier =
            modifier
                .element(Shade.Elements.BackgroundScrim)
                .fillMaxSize()
                .background(color = scrimColor(isTransparencyEnabled))
    )
}

@Composable
@ReadOnlyComposable
private fun scrimColor(isTransparencyEnabled: Boolean): Color {
    // Read configuration to invalidate on changes
    LocalConfiguration.current
    return Color(
        ShadeColors.shadePanel(
            context = LocalContext.current,
            blurSupported = isTransparencyEnabled,
            withScrim = true,
        )
    )
}
+1 −8
Original line number Diff line number Diff line
@@ -70,7 +70,6 @@ import com.android.compose.animation.scene.animateContentFloatAsState
import com.android.compose.animation.scene.content.state.TransitionState
import com.android.compose.modifiers.padding
import com.android.compose.modifiers.thenIf
import com.android.compose.theme.LocalAndroidColorScheme
import com.android.internal.jank.InteractionJankMonitor
import com.android.systemui.common.ui.compose.windowinsets.CutoutLocation
import com.android.systemui.common.ui.compose.windowinsets.LocalDisplayCutout
@@ -235,7 +234,6 @@ private fun ContentScope.SingleShade(
) {
    val cutout = LocalDisplayCutout.current
    val cutoutInsets = WindowInsets.Companion.displayCutout
    val shadePanelColor = LocalAndroidColorScheme.current.surfaceEffect1

    var maxNotifScrimTop by remember { mutableIntStateOf(0) }
    val tileSquishiness by
@@ -286,12 +284,7 @@ private fun ContentScope.SingleShade(
        }

    Box(modifier) {
        Box(
            modifier =
                Modifier.fillMaxSize()
                    .element(Shade.Elements.BackgroundScrim)
                    .background(shadePanelColor)
        )
        ShadePanelScrim(viewModel.isTransparencyEnabled)
        Layout(
            modifier =
                Modifier.thenIf(viewModel.isEmptySpaceClickable) {
+2 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import com.android.systemui.testKosmos
import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.mock
import com.android.systemui.util.mockito.whenever
import com.android.systemui.window.domain.interactor.windowRootViewBlurInteractor
import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Test
@@ -81,6 +82,7 @@ class QuickSettingsSceneContentViewModelTest : SysuiTestCase() {
                    shadeModeInteractor = shadeModeInteractor,
                    sceneInteractor = sceneInteractor,
                    mainDispatcher = testDispatcher,
                    windowRootViewBlurInteractor = windowRootViewBlurInteractor,
                )
            underTest.activateIn(testScope)
            disableDualShade()
+19 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.qs.ui.viewmodel
import androidx.compose.runtime.getValue
import androidx.lifecycle.LifecycleOwner
import com.android.app.tracing.coroutines.launchTraced as launch
import com.android.systemui.Flags
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.lifecycle.ExclusiveActivatable
import com.android.systemui.lifecycle.Hydrator
@@ -31,12 +32,14 @@ import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.domain.interactor.ShadeModeInteractor
import com.android.systemui.shade.shared.model.ShadeMode
import com.android.systemui.shade.ui.viewmodel.ShadeHeaderViewModel
import com.android.systemui.window.domain.interactor.WindowRootViewBlurInteractor
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import java.util.concurrent.atomic.AtomicBoolean
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.awaitCancellation
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
@@ -57,12 +60,28 @@ constructor(
    private val shadeModeInteractor: ShadeModeInteractor,
    private val sceneInteractor: SceneInteractor,
    @Main private val mainDispatcher: CoroutineDispatcher,
    windowRootViewBlurInteractor: WindowRootViewBlurInteractor,
) : ExclusiveActivatable() {
    val qsContainerViewModel =
        qsContainerViewModelFactory.create(supportsBrightnessMirroring = true)

    private val hydrator = Hydrator("QuickSettingsSceneContentViewModel.hydrator")

    /**
     * Whether the shade container transparency effect should be enabled (`true`), or whether to
     * render a fully-opaque shade container (`false`).
     */
    val isTransparencyEnabled: Boolean by
        hydrator.hydratedStateOf(
            traceName = "isTransparencyEnabled",
            source =
                if (Flags.notificationShadeBlur()) {
                    windowRootViewBlurInteractor.isBlurCurrentlySupported
                } else {
                    MutableStateFlow(false)
                },
        )

    private val footerActionsControllerInitialized = AtomicBoolean(false)

    fun getFooterActionsViewModel(lifecycleOwner: LifecycleOwner): FooterActionsViewModel {
Loading