1 /*
2  *  Copyright (C) 2022 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 
18 package com.android.systemui.keyguard.domain.interactor
19 
20 import com.android.systemui.common.shared.model.Position
21 import com.android.systemui.dagger.SysUISingleton
22 import com.android.systemui.keyguard.data.repository.KeyguardRepository
23 import javax.inject.Inject
24 import kotlinx.coroutines.flow.Flow
25 
26 /** Encapsulates business-logic specifically related to the keyguard bottom area. */
27 @SysUISingleton
28 class KeyguardBottomAreaInteractor
29 @Inject
30 constructor(
31     private val repository: KeyguardRepository,
32 ) {
33     /** Whether to animate the next doze mode transition. */
34     val animateDozingTransitions: Flow<Boolean> = repository.animateBottomAreaDozingTransitions
35     /** The amount of alpha for the UI components of the bottom area. */
36     val alpha: Flow<Float> = repository.bottomAreaAlpha
37     /** The position of the keyguard clock. */
38     val clockPosition: Flow<Position> = repository.clockPosition
39 
40     fun setClockPosition(x: Int, y: Int) {
41         repository.setClockPosition(x, y)
42     }
43 
44     fun setAlpha(alpha: Float) {
45         repository.setBottomAreaAlpha(alpha)
46     }
47 
48     fun setAnimateDozingTransitions(animate: Boolean) {
49         repository.setAnimateDozingTransitions(animate)
50     }
51 
52     /**
53      * Returns whether the keyguard bottom area should be constrained to the top of the lock icon
54      */
55     fun shouldConstrainToTopOfLockIcon(): Boolean = repository.isUdfpsSupported()
56 }
57