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

Commit c99a557c authored by Lucas Silva's avatar Lucas Silva
Browse files

Implement scrimmed GH background

Fixes: 396523247
Flag: com.android.systemui.glanceable_hub_v2
Test: flashed & verified scrim appears correctly
Change-Id: Ieeee47a9c0e0b4c622665ef6fb081e97bc1dc9e2
parent 1be4df13
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -282,6 +282,7 @@ fun ContentScope.CommunalScene(
            CommunalBackgroundType.ANIMATED -> AnimatedLinearGradient()
            CommunalBackgroundType.NONE -> BackgroundTopScrim()
            CommunalBackgroundType.BLUR -> Background()
            CommunalBackgroundType.SCRIM -> Scrimmed()
        }

        with(content) {
@@ -304,6 +305,11 @@ private fun BoxScope.DefaultBackground(colors: CommunalColors) {
    Box(modifier = Modifier.matchParentSize().background(Color(backgroundColor.toArgb())))
}

@Composable
private fun BoxScope.Scrimmed() {
    Box(modifier = Modifier.matchParentSize().alpha(0.34f).background(Color.Black))
}

/** Experimental hub background, static linear gradient */
@Composable
private fun BoxScope.StaticLinearGradient() {
+5 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.communal.data.repository

import com.android.systemui.Flags.glanceableHubBlurredBackground
import com.android.systemui.Flags.glanceableHubV2
import com.android.systemui.communal.shared.model.CommunalBackgroundType
import dagger.Binds
import dagger.Module
@@ -35,6 +36,10 @@ interface CommunalSettingsRepositoryModule {
                return CommunalBackgroundType.BLUR
            }

            if (glanceableHubV2()) {
                return CommunalBackgroundType.SCRIM
            }

            return CommunalBackgroundType.ANIMATED
        }
    }
+7 −6
Original line number Diff line number Diff line
@@ -17,10 +17,11 @@
package com.android.systemui.communal.shared.model

/** Models the types of background that can be shown on the hub. */
enum class CommunalBackgroundType(val value: Int) {
    STATIC(0),
    STATIC_GRADIENT(1),
    ANIMATED(2),
    NONE(3),
    BLUR(4),
enum class CommunalBackgroundType(val value: Int, val opaque: Boolean) {
    STATIC(value = 0, opaque = true),
    STATIC_GRADIENT(value = 1, opaque = true),
    ANIMATED(value = 2, opaque = true),
    NONE(value = 3, opaque = false),
    BLUR(value = 4, opaque = false),
    SCRIM(value = 5, opaque = false),
}
+14 −8
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.communal.ui.viewmodel
import android.graphics.Color
import com.android.systemui.communal.domain.interactor.CommunalInteractor
import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor
import com.android.systemui.communal.domain.interactor.CommunalSettingsInteractor
import com.android.systemui.communal.shared.model.CommunalScenes
import com.android.systemui.communal.util.CommunalColors
import com.android.systemui.dagger.SysUISingleton
@@ -40,6 +41,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
@@ -60,6 +62,7 @@ constructor(
    glanceableHubToDreamTransitionViewModel: GlanceableHubToDreamingTransitionViewModel,
    communalInteractor: CommunalInteractor,
    private val communalSceneInteractor: CommunalSceneInteractor,
    communalSettingsInteractor: CommunalSettingsInteractor,
    keyguardTransitionInteractor: KeyguardTransitionInteractor,
) {
    /**
@@ -146,13 +149,16 @@ constructor(
            }

    val recentsBackgroundColor: Flow<Color?> =
        combine(showCommunalFromOccluded, communalColors.backgroundColor) {
        combine(
                showCommunalFromOccluded,
            backgroundColor ->
            if (showCommunalFromOccluded) {
                communalColors.backgroundColor,
                communalSettingsInteractor.communalBackground,
            ) { showCommunalFromOccluded, backgroundColor, backgroundType ->
                if (showCommunalFromOccluded && backgroundType.opaque) {
                    backgroundColor
                } else {
                    null
                }
            }
            .distinctUntilChanged()
}
+2 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.communal.ui.viewmodel

import com.android.systemui.communal.domain.interactor.communalInteractor
import com.android.systemui.communal.domain.interactor.communalSceneInteractor
import com.android.systemui.communal.domain.interactor.communalSettingsInteractor
import com.android.systemui.communal.util.communalColors
import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor
import com.android.systemui.keyguard.ui.viewmodel.dreamingToGlanceableHubTransitionViewModel
@@ -41,5 +42,6 @@ val Kosmos.communalTransitionViewModel by
            communalSceneInteractor = communalSceneInteractor,
            keyguardTransitionInteractor = keyguardTransitionInteractor,
            communalColors = communalColors,
            communalSettingsInteractor = communalSettingsInteractor,
        )
    }