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

Commit cf49f9bf authored by Beverly Tai's avatar Beverly Tai Committed by Android (Google) Code Review
Browse files

Merge "[flexi] Add LockscreenBehindScrim" into main

parents fc5fffb6 11f40b16
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import com.android.systemui.keyguard.ui.composable.LockscreenContent
import com.android.systemui.keyguard.ui.composable.LockscreenScene
import com.android.systemui.keyguard.ui.composable.LockscreenSceneBlueprintModule
import com.android.systemui.keyguard.ui.composable.blueprint.ComposableLockscreenSceneBlueprint
import com.android.systemui.keyguard.ui.viewmodel.LockscreenBehindScrimViewModel
import com.android.systemui.keyguard.ui.viewmodel.LockscreenContentViewModel
import com.android.systemui.keyguard.ui.viewmodel.LockscreenFrontScrimViewModel
import com.android.systemui.scene.ui.composable.Scene
@@ -63,6 +64,7 @@ interface LockscreenSceneModule {
            viewModelFactory: LockscreenContentViewModel.Factory,
            notificationScrimViewModelFactory: NotificationLockscreenScrimViewModel.Factory,
            lockscreenFrontScrimViewModelFactory: LockscreenFrontScrimViewModel.Factory,
            lockscreenBehindScrimViewModelFactory: LockscreenBehindScrimViewModel.Factory,
            blueprints: Set<@JvmSuppressWildcards ComposableLockscreenSceneBlueprint>,
            clockInteractor: KeyguardClockInteractor,
            interactionJankMonitor: InteractionJankMonitor,
@@ -71,6 +73,7 @@ interface LockscreenSceneModule {
                viewModelFactory,
                notificationScrimViewModelFactory,
                lockscreenFrontScrimViewModelFactory,
                lockscreenBehindScrimViewModelFactory,
                blueprints,
                clockInteractor,
                interactionJankMonitor,
+38 −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.keyguard.ui.composable

import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import com.android.systemui.keyguard.ui.viewmodel.LockscreenBehindScrimViewModel

/** A full-screen scrim that is used to dim the keyguard wallpaper. */
@Composable
fun LockscreenBehindScrim(
    viewModel: LockscreenBehindScrimViewModel,
    modifier: Modifier = Modifier,
) {
    val animatedAlpha: Float by animateFloatAsState(viewModel.alpha)
    Box(modifier.fillMaxSize().graphicsLayer { alpha = animatedAlpha }.background(Color.Black))
}
+11 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.transition.KeyguardTransitionAnimationCallback
import com.android.systemui.keyguard.ui.composable.blueprint.ComposableLockscreenSceneBlueprint
import com.android.systemui.keyguard.ui.viewmodel.LockscreenBehindScrimViewModel
import com.android.systemui.keyguard.ui.viewmodel.LockscreenContentViewModel
import com.android.systemui.keyguard.ui.viewmodel.LockscreenFrontScrimViewModel
import com.android.systemui.lifecycle.rememberViewModel
@@ -48,6 +49,7 @@ class LockscreenContent(
    private val viewModelFactory: LockscreenContentViewModel.Factory,
    private val notificationScrimViewModelFactory: NotificationLockscreenScrimViewModel.Factory,
    private val lockscreenFrontScrimViewModelFactory: LockscreenFrontScrimViewModel.Factory,
    private val lockscreenBehindScrimViewModelFactory: LockscreenBehindScrimViewModel.Factory,
    private val blueprints: Set<@JvmSuppressWildcards ComposableLockscreenSceneBlueprint>,
    private val clockInteractor: KeyguardClockInteractor,
    private val interactionJankMonitor: InteractionJankMonitor,
@@ -74,9 +76,14 @@ class LockscreenContent(
            rememberViewModel("LockscreenContent-frontScrimViewModel") {
                lockscreenFrontScrimViewModelFactory.create()
            }
        val lockscreenBehindScrimViewModel =
            rememberViewModel("LockscreenContent-behindScrimViewModel") {
                lockscreenBehindScrimViewModelFactory.create()
            }

        // Ensure clock events are connected. This is a no-op if they are already registered.
        clockInteractor.clockEventController.registerListeners()

        if (!viewModel.isContentVisible) {
            // If the content isn't supposed to be visible, show a large empty box as it's needed
            // for scene transition animations (can't just skip rendering everything or shared
@@ -93,6 +100,10 @@ class LockscreenContent(

        val blueprint = blueprintByBlueprintId[viewModel.blueprintId] ?: return
        with(blueprint) {
            LockscreenBehindScrim(
                lockscreenBehindScrimViewModel,
                Modifier.element(LockscreenElementKeys.BehindScrim),
            )
            Content(
                viewModel,
                modifier.sysuiResTag("keyguard_root_view").element(LockscreenElementKeys.Root),
+2 −0
Original line number Diff line number Diff line
@@ -2,10 +2,12 @@ package com.android.systemui.scene.ui.composable.transitions

import androidx.compose.animation.core.tween
import com.android.compose.animation.scene.TransitionBuilder
import com.android.systemui.plugins.keyguard.ui.composable.elements.LockscreenElementKeys
import com.android.systemui.scene.shared.model.Scenes

fun TransitionBuilder.lockscreenToGoneTransition() {
    spec = tween(durationMillis = 500)

    fade(Scenes.Lockscreen.rootElementKey)
    fade(LockscreenElementKeys.BehindScrim)
}
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import com.android.compose.animation.scene.ElementKey
object LockscreenElementKeys {
    /** Root element of the entire lockcsreen */
    val Root = ElementKey("LockscreenRoot")
    val BehindScrim = ElementKey("LockscreenBehindScrim")

    object Region {
        /** The upper region includes everything above the lock icon */
Loading