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 import kotlinx.coroutines.flow.MutableStateFlow 26 import kotlinx.coroutines.flow.asStateFlow 27 28 /** Encapsulates business-logic specifically related to the keyguard bottom area. */ 29 @SysUISingleton 30 class KeyguardBottomAreaInteractor 31 @Inject 32 constructor( 33 private val repository: KeyguardRepository, 34 ) { 35 /** Whether to animate the next doze mode transition. */ 36 val animateDozingTransitions: Flow<Boolean> = repository.animateBottomAreaDozingTransitions 37 /** The amount of alpha for the UI components of the bottom area. */ 38 val alpha: Flow<Float> = repository.bottomAreaAlpha 39 /** The position of the keyguard clock. */ 40 private val _clockPosition = MutableStateFlow(Position(0, 0)) 41 /** See [ClockSection] */ 42 @Deprecated("with MigrateClocksToBlueprint.isEnabled") 43 val clockPosition: Flow<Position> = _clockPosition.asStateFlow() 44 setClockPositionnull45 fun setClockPosition(x: Int, y: Int) { 46 _clockPosition.value = Position(x, y) 47 } 48 setAlphanull49 fun setAlpha(alpha: Float) { 50 repository.setBottomAreaAlpha(alpha) 51 } 52 setAnimateDozingTransitionsnull53 fun setAnimateDozingTransitions(animate: Boolean) { 54 repository.setAnimateDozingTransitions(animate) 55 } 56 57 /** 58 * Returns whether the keyguard bottom area should be constrained to the top of the lock icon 59 */ shouldConstrainToTopOfLockIconnull60 fun shouldConstrainToTopOfLockIcon(): Boolean = repository.isUdfpsSupported() 61 } 62