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

Commit 0df1c851 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update keyguard preview when clock size setting changes" into main

parents 942a581d 2fb3500d
Loading
Loading
Loading
Loading
+35 −34
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.plugins.clocks.ClockController
import com.android.systemui.plugins.clocks.ClockPreviewConfig
import com.android.systemui.shared.clocks.ClockRegistry
import kotlinx.coroutines.flow.combine

/** Binder for the small clock view, large clock view. */
object KeyguardPreviewClockViewBinder {
@@ -76,7 +77,8 @@ object KeyguardPreviewClockViewBinder {
            repeatOnLifecycle(Lifecycle.State.STARTED) {
                var lastClock: ClockController? = null
                launch("$TAG#viewModel.previewClock") {
                        viewModel.previewClock.collect { currentClock ->
                        combine(viewModel.previewClock, viewModel.selectedClockSize, ::Pair)
                            .collect { (currentClock, clockSize) ->
                                lastClock?.let { clock ->
                                    (clock.largeClock.layout.views + clock.smallClock.layout.views)
                                        .forEach { rootView.removeView(it) }
@@ -105,7 +107,7 @@ object KeyguardPreviewClockViewBinder {
                                    clockPreviewConfig,
                                    rootView,
                                    currentClock,
                                viewModel,
                                    clockSize,
                                )
                            }
                    }
@@ -133,7 +135,7 @@ object KeyguardPreviewClockViewBinder {
        clockPreviewConfig: ClockPreviewConfig,
        rootView: ConstraintLayout,
        previewClock: ClockController,
        viewModel: KeyguardPreviewClockViewModel,
        clockSize: ClockSizeSetting?,
    ) {
        val cs = ConstraintSet().apply { clone(rootView) }

@@ -147,16 +149,15 @@ object KeyguardPreviewClockViewBinder {
        previewClock.largeClock.layout.applyPreviewConstraints(configWithUpdatedLockId, cs)
        previewClock.smallClock.layout.applyPreviewConstraints(configWithUpdatedLockId, cs)

        // When selectedClockSize is the initial value, make both clocks invisible to avoid
        // flickering
        // When selectedClockSize is the initial value, make both clocks invisible to avoid flicker
        val largeClockVisibility =
            when (viewModel.selectedClockSize.value) {
            when (clockSize) {
                ClockSizeSetting.DYNAMIC -> VISIBLE
                ClockSizeSetting.SMALL -> INVISIBLE
                null -> INVISIBLE
            }
        val smallClockVisibility =
            when (viewModel.selectedClockSize.value) {
            when (clockSize) {
                ClockSizeSetting.DYNAMIC -> INVISIBLE
                ClockSizeSetting.SMALL -> VISIBLE
                null -> INVISIBLE