1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.keyguard.ui.viewmodel 18 19 import com.android.systemui.Flags 20 import com.android.systemui.dagger.SysUISingleton 21 import com.android.systemui.keyguard.domain.interactor.FromPrimaryBouncerTransitionInteractor 22 import com.android.systemui.keyguard.shared.model.Edge 23 import com.android.systemui.keyguard.shared.model.KeyguardState.OCCLUDED 24 import com.android.systemui.keyguard.shared.model.KeyguardState.PRIMARY_BOUNCER 25 import com.android.systemui.keyguard.ui.KeyguardTransitionAnimationFlow 26 import com.android.systemui.keyguard.ui.transitions.BlurConfig 27 import com.android.systemui.keyguard.ui.transitions.PrimaryBouncerTransition 28 import javax.inject.Inject 29 import kotlinx.coroutines.flow.Flow 30 31 @SysUISingleton 32 class PrimaryBouncerToOccludedTransitionViewModel 33 @Inject 34 constructor( 35 shadeDependentFlows: ShadeDependentFlows, 36 blurConfig: BlurConfig, 37 animationFlow: KeyguardTransitionAnimationFlow, 38 ) : PrimaryBouncerTransition { 39 private val transitionAnimation = 40 animationFlow 41 .setup( 42 duration = FromPrimaryBouncerTransitionInteractor.TO_OCCLUDED_DURATION, 43 edge = Edge.INVALID, 44 ) 45 .setupWithoutSceneContainer(edge = Edge.create(PRIMARY_BOUNCER, OCCLUDED)) 46 47 override val windowBlurRadius: Flow<Float> = 48 shadeDependentFlows.transitionFlow( 49 flowWhenShadeIsExpanded = 50 if (Flags.notificationShadeBlur()) { 51 transitionAnimation.immediatelyTransitionTo(blurConfig.maxBlurRadiusPx) 52 } else { 53 transitionAnimation.immediatelyTransitionTo(blurConfig.minBlurRadiusPx) 54 }, 55 flowWhenShadeIsNotExpanded = 56 transitionAnimation.immediatelyTransitionTo(blurConfig.minBlurRadiusPx), 57 ) 58 59 override val notificationBlurRadius: Flow<Float> = 60 transitionAnimation.immediatelyTransitionTo(0.0f) 61 } 62