Loading packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepositoryModule.kt +5 −0 Original line number Diff line number Diff line Loading @@ -76,4 +76,9 @@ interface KeyguardRepositoryModule { @Binds fun trustRepository(impl: TrustRepositoryImpl): TrustRepository @Binds fun keyguardClockRepository(impl: KeyguardClockRepositoryImpl): KeyguardClockRepository @Binds fun keyguardSmartspaceRepository( impl: KeyguardSmartspaceRepositoryImpl ): KeyguardSmartspaceRepository } packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardSmartspaceRepository.kt +52 −3 Original line number Diff line number Diff line Loading @@ -16,19 +16,68 @@ package com.android.systemui.keyguard.data.repository import android.content.Context import android.provider.Settings import android.view.View import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.settings.UserTracker import com.android.systemui.util.settings.SecureSettings import com.android.systemui.util.settings.SettingsProxyExt.observerFlow import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.flow.stateIn interface KeyguardSmartspaceRepository { val bcSmartspaceVisibility: StateFlow<Int> val isWeatherEnabled: StateFlow<Boolean> fun setBcSmartspaceVisibility(visibility: Int) } @SysUISingleton class KeyguardSmartspaceRepository @Inject constructor() { class KeyguardSmartspaceRepositoryImpl @Inject constructor( context: Context, private val secureSettings: SecureSettings, private val userTracker: UserTracker, @Application private val applicationScope: CoroutineScope, ) : KeyguardSmartspaceRepository { private val _bcSmartspaceVisibility: MutableStateFlow<Int> = MutableStateFlow(View.GONE) val bcSmartspaceVisibility: StateFlow<Int> = _bcSmartspaceVisibility.asStateFlow() override val bcSmartspaceVisibility: StateFlow<Int> = _bcSmartspaceVisibility.asStateFlow() val defaultValue = context.resources.getBoolean( com.android.internal.R.bool.config_lockscreenWeatherEnabledByDefault ) override val isWeatherEnabled: StateFlow<Boolean> = secureSettings .observerFlow( names = arrayOf(Settings.Secure.LOCK_SCREEN_WEATHER_ENABLED), userId = userTracker.userId, ) .onStart { emit(Unit) } .map { getLockscreenWeatherEnabled() } .stateIn( scope = applicationScope, started = SharingStarted.WhileSubscribed(), initialValue = getLockscreenWeatherEnabled() ) fun setBcSmartspaceVisibility(visibility: Int) { override fun setBcSmartspaceVisibility(visibility: Int) { _bcSmartspaceVisibility.value = visibility } private fun getLockscreenWeatherEnabled(): Boolean { return secureSettings.getIntForUser( Settings.Secure.LOCK_SCREEN_WEATHER_ENABLED, if (defaultValue) 1 else 0, userTracker.userId ) == 1 } } packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardSmartspaceInteractor.kt +1 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ constructor( private val keyguardSmartspaceRepository: KeyguardSmartspaceRepository, ) { val bcSmartspaceVisibility: StateFlow<Int> = keyguardSmartspaceRepository.bcSmartspaceVisibility val isWeatherEnabled: StateFlow<Boolean> = keyguardSmartspaceRepository.isWeatherEnabled fun setBcSmartspaceVisibility(visibility: Int) { keyguardSmartspaceRepository.setBcSmartspaceVisibility(visibility) Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSection.kt +9 −15 Original line number Diff line number Diff line Loading @@ -42,10 +42,10 @@ constructor( val context: Context, val keyguardClockViewModel: KeyguardClockViewModel, val keyguardSmartspaceViewModel: KeyguardSmartspaceViewModel, val keyguardSmartspaceInteractor: KeyguardSmartspaceInteractor, private val keyguardSmartspaceInteractor: KeyguardSmartspaceInteractor, val smartspaceController: LockscreenSmartspaceController, val keyguardUnlockAnimationController: KeyguardUnlockAnimationController, val blueprintInteractor: Lazy<KeyguardBlueprintInteractor>, private val blueprintInteractor: Lazy<KeyguardBlueprintInteractor>, ) : KeyguardSection() { private var smartspaceView: View? = null private var weatherView: View? = null Loading @@ -61,13 +61,11 @@ constructor( weatherView = smartspaceController.buildAndConnectWeatherView(constraintLayout) dateView = smartspaceController.buildAndConnectDateView(constraintLayout) pastVisibility = smartspaceView?.visibility ?: View.GONE if (keyguardSmartspaceViewModel.isSmartspaceEnabled) { constraintLayout.addView(smartspaceView) if (keyguardSmartspaceViewModel.isDateWeatherDecoupled) { constraintLayout.addView(weatherView) constraintLayout.addView(dateView) } } keyguardUnlockAnimationController.lockscreenSmartspace = smartspaceView smartspaceVisibilityListener = OnGlobalLayoutListener { smartspaceView?.let { Loading Loading @@ -205,14 +203,10 @@ constructor( constraintSet.apply { val weatherVisibility = when (keyguardClockViewModel.hasCustomWeatherDataDisplay.value) { true -> ConstraintSet.GONE false -> when (keyguardSmartspaceViewModel.isWeatherEnabled) { when (keyguardSmartspaceViewModel.isWeatherVisible.value) { true -> ConstraintSet.VISIBLE false -> ConstraintSet.GONE } } setVisibility(sharedR.id.weather_smartspace_view, weatherVisibility) setAlpha( sharedR.id.weather_smartspace_view, Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModel.kt +2 −2 Original line number Diff line number Diff line Loading @@ -84,8 +84,8 @@ constructor( combine( isLargeClockVisible, currentClock, ) { isLargeClock, clock -> clock?.let { clock -> ) { isLargeClock, currentClock -> currentClock?.let { clock -> val face = if (isLargeClock) clock.largeClock else clock.smallClock face.config.hasCustomWeatherDataDisplay } Loading Loading
packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepositoryModule.kt +5 −0 Original line number Diff line number Diff line Loading @@ -76,4 +76,9 @@ interface KeyguardRepositoryModule { @Binds fun trustRepository(impl: TrustRepositoryImpl): TrustRepository @Binds fun keyguardClockRepository(impl: KeyguardClockRepositoryImpl): KeyguardClockRepository @Binds fun keyguardSmartspaceRepository( impl: KeyguardSmartspaceRepositoryImpl ): KeyguardSmartspaceRepository }
packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardSmartspaceRepository.kt +52 −3 Original line number Diff line number Diff line Loading @@ -16,19 +16,68 @@ package com.android.systemui.keyguard.data.repository import android.content.Context import android.provider.Settings import android.view.View import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.settings.UserTracker import com.android.systemui.util.settings.SecureSettings import com.android.systemui.util.settings.SettingsProxyExt.observerFlow import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.flow.stateIn interface KeyguardSmartspaceRepository { val bcSmartspaceVisibility: StateFlow<Int> val isWeatherEnabled: StateFlow<Boolean> fun setBcSmartspaceVisibility(visibility: Int) } @SysUISingleton class KeyguardSmartspaceRepository @Inject constructor() { class KeyguardSmartspaceRepositoryImpl @Inject constructor( context: Context, private val secureSettings: SecureSettings, private val userTracker: UserTracker, @Application private val applicationScope: CoroutineScope, ) : KeyguardSmartspaceRepository { private val _bcSmartspaceVisibility: MutableStateFlow<Int> = MutableStateFlow(View.GONE) val bcSmartspaceVisibility: StateFlow<Int> = _bcSmartspaceVisibility.asStateFlow() override val bcSmartspaceVisibility: StateFlow<Int> = _bcSmartspaceVisibility.asStateFlow() val defaultValue = context.resources.getBoolean( com.android.internal.R.bool.config_lockscreenWeatherEnabledByDefault ) override val isWeatherEnabled: StateFlow<Boolean> = secureSettings .observerFlow( names = arrayOf(Settings.Secure.LOCK_SCREEN_WEATHER_ENABLED), userId = userTracker.userId, ) .onStart { emit(Unit) } .map { getLockscreenWeatherEnabled() } .stateIn( scope = applicationScope, started = SharingStarted.WhileSubscribed(), initialValue = getLockscreenWeatherEnabled() ) fun setBcSmartspaceVisibility(visibility: Int) { override fun setBcSmartspaceVisibility(visibility: Int) { _bcSmartspaceVisibility.value = visibility } private fun getLockscreenWeatherEnabled(): Boolean { return secureSettings.getIntForUser( Settings.Secure.LOCK_SCREEN_WEATHER_ENABLED, if (defaultValue) 1 else 0, userTracker.userId ) == 1 } }
packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardSmartspaceInteractor.kt +1 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ constructor( private val keyguardSmartspaceRepository: KeyguardSmartspaceRepository, ) { val bcSmartspaceVisibility: StateFlow<Int> = keyguardSmartspaceRepository.bcSmartspaceVisibility val isWeatherEnabled: StateFlow<Boolean> = keyguardSmartspaceRepository.isWeatherEnabled fun setBcSmartspaceVisibility(visibility: Int) { keyguardSmartspaceRepository.setBcSmartspaceVisibility(visibility) Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSection.kt +9 −15 Original line number Diff line number Diff line Loading @@ -42,10 +42,10 @@ constructor( val context: Context, val keyguardClockViewModel: KeyguardClockViewModel, val keyguardSmartspaceViewModel: KeyguardSmartspaceViewModel, val keyguardSmartspaceInteractor: KeyguardSmartspaceInteractor, private val keyguardSmartspaceInteractor: KeyguardSmartspaceInteractor, val smartspaceController: LockscreenSmartspaceController, val keyguardUnlockAnimationController: KeyguardUnlockAnimationController, val blueprintInteractor: Lazy<KeyguardBlueprintInteractor>, private val blueprintInteractor: Lazy<KeyguardBlueprintInteractor>, ) : KeyguardSection() { private var smartspaceView: View? = null private var weatherView: View? = null Loading @@ -61,13 +61,11 @@ constructor( weatherView = smartspaceController.buildAndConnectWeatherView(constraintLayout) dateView = smartspaceController.buildAndConnectDateView(constraintLayout) pastVisibility = smartspaceView?.visibility ?: View.GONE if (keyguardSmartspaceViewModel.isSmartspaceEnabled) { constraintLayout.addView(smartspaceView) if (keyguardSmartspaceViewModel.isDateWeatherDecoupled) { constraintLayout.addView(weatherView) constraintLayout.addView(dateView) } } keyguardUnlockAnimationController.lockscreenSmartspace = smartspaceView smartspaceVisibilityListener = OnGlobalLayoutListener { smartspaceView?.let { Loading Loading @@ -205,14 +203,10 @@ constructor( constraintSet.apply { val weatherVisibility = when (keyguardClockViewModel.hasCustomWeatherDataDisplay.value) { true -> ConstraintSet.GONE false -> when (keyguardSmartspaceViewModel.isWeatherEnabled) { when (keyguardSmartspaceViewModel.isWeatherVisible.value) { true -> ConstraintSet.VISIBLE false -> ConstraintSet.GONE } } setVisibility(sharedR.id.weather_smartspace_view, weatherVisibility) setAlpha( sharedR.id.weather_smartspace_view, Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModel.kt +2 −2 Original line number Diff line number Diff line Loading @@ -84,8 +84,8 @@ constructor( combine( isLargeClockVisible, currentClock, ) { isLargeClock, clock -> clock?.let { clock -> ) { isLargeClock, currentClock -> currentClock?.let { clock -> val face = if (isLargeClock) clock.largeClock else clock.smallClock face.config.hasCustomWeatherDataDisplay } Loading