From 306ca3de1bbb6db3d5d8e02900998f4ffaa0bf23 Mon Sep 17 00:00:00 2001 From: Alejandro Nijamkin Date: Thu, 26 Jan 2023 18:57:20 -0800 Subject: [PATCH] Fixes alpha issue in lock screen shortcuts. This bug was introduced in ag/21077389 where we implemented "dimming" of the views to support the remote rendering of the screen preview that's shown in the wallpaper picker but never tested that it doesn't affect the views when shown in the normal lock screen. This CL fixes that. Fix: 266875410 Test: manually verified that pulling the shade down or the bouncer up properly fades out the lock screen shortcuts Test: manually verified that the appropriate "dimming" of the currently-not-selected button is working as expected in the wallpaper picker Change-Id: I9f3e6f7ec600567065d10e6f94a87096607817bf --- .../ui/binder/KeyguardBottomAreaViewBinder.kt | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaViewBinder.kt index e9d7a5b8ed6f3..3319f9d467ecc 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaViewBinder.kt @@ -49,6 +49,7 @@ import kotlin.math.pow import kotlin.math.sqrt import kotlin.time.Duration.Companion.milliseconds import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.flatMapLatest @@ -163,11 +164,25 @@ object KeyguardBottomAreaViewBinder { ambientIndicationArea?.alpha = alpha indicationArea.alpha = alpha - startButton.alpha = alpha - endButton.alpha = alpha } } + launch { + updateButtonAlpha( + view = startButton, + viewModel = viewModel.startButton, + alphaFlow = viewModel.alpha, + ) + } + + launch { + updateButtonAlpha( + view = endButton, + viewModel = viewModel.endButton, + alphaFlow = viewModel.alpha, + ) + } + launch { viewModel.indicationAreaTranslationX.collect { translationX -> indicationArea.translationX = translationX @@ -321,7 +336,6 @@ object KeyguardBottomAreaViewBinder { .animate() .scaleX(if (viewModel.isSelected) SCALE_SELECTED_BUTTON else 1f) .scaleY(if (viewModel.isSelected) SCALE_SELECTED_BUTTON else 1f) - .alpha(if (viewModel.isDimmed) DIM_ALPHA else 1f) .start() view.isClickable = viewModel.isClickable @@ -341,6 +355,17 @@ object KeyguardBottomAreaViewBinder { view.isSelected = viewModel.isSelected } + private suspend fun updateButtonAlpha( + view: View, + viewModel: Flow, + alphaFlow: Flow, + ) { + combine(viewModel.map { it.isDimmed }, alphaFlow) { isDimmed, alpha -> + if (isDimmed) DIM_ALPHA else alpha + } + .collect { view.alpha = it } + } + private class OnTouchListener( private val view: View, private val viewModel: KeyguardQuickAffordanceViewModel,