Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eb34e33e authored by Ale Nijamkin's avatar Ale Nijamkin Committed by Android (Google) Code Review
Browse files

Merge "Fixes alpha issue in lock screen shortcuts." into tm-qpr-dev

parents a1531f2c 306ca3de
Loading
Loading
Loading
Loading
+28 −3
Original line number Diff line number Diff line
@@ -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<KeyguardQuickAffordanceViewModel>,
        alphaFlow: Flow<Float>,
    ) {
        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,