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

Commit 47fef544 authored by Sherry Zhou's avatar Sherry Zhou Committed by Android (Google) Code Review
Browse files

Merge "Fix clocks are legacy versions in preview" into main

parents cc79df0a 3caae20a
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ import java.util.TimeZone
 * existing lockscreen clock.
 */
class DefaultClockController(
    ctx: Context,
    private val ctx: Context,
    private val layoutInflater: LayoutInflater,
    private val resources: Resources,
    private val settings: ClockSettings?,
@@ -121,7 +121,11 @@ class DefaultClockController(
        protected var targetRegion: Rect? = null

        override val config = ClockFaceConfig()
        override val layout = DefaultClockFaceLayout(view)
        override val layout =
            DefaultClockFaceLayout(view).apply {
                views[0].id =
                    resources.getIdentifier("lockscreen_clock_view", "id", ctx.packageName)
            }

        override var animations: DefaultClockAnimations = DefaultClockAnimations(view, 0f, 0f)
            internal set
@@ -188,7 +192,11 @@ class DefaultClockController(
        seedColor: Int?,
        messageBuffer: MessageBuffer?,
    ) : DefaultClockFaceController(view, seedColor, messageBuffer) {
        override val layout = DefaultClockFaceLayout(view)
        override val layout =
            DefaultClockFaceLayout(view).apply {
                views[0].id =
                    resources.getIdentifier("lockscreen_clock_view_large", "id", ctx.packageName)
            }
        override val config =
            ClockFaceConfig(hasCustomPositionUpdatedAnimation = hasStepClockAnimation)

+6 −0
Original line number Diff line number Diff line
@@ -116,6 +116,8 @@ interface ClockFaceLayout {

    /** Custom constraints to apply to Lockscreen ConstraintLayout. */
    fun applyConstraints(constraints: ConstraintSet): ConstraintSet

    fun applyPreviewConstraints(constraints: ConstraintSet): ConstraintSet
}

/** A ClockFaceLayout that applies the default lockscreen layout to a single view */
@@ -131,6 +133,10 @@ class DefaultClockFaceLayout(val view: View) : ClockFaceLayout {
        }
        return constraints
    }

    override fun applyPreviewConstraints(constraints: ConstraintSet): ConstraintSet {
        return constraints
    }
}

/** Events that should call when various rendering parameters change */
+11 −0
Original line number Diff line number Diff line
@@ -60,6 +60,8 @@ interface KeyguardClockRepository {

    val currentClock: StateFlow<ClockController?>

    val previewClock: StateFlow<ClockController>

    val clockEventController: ClockEventController
    fun setClockSize(@ClockSize size: Int)
}
@@ -120,6 +122,15 @@ constructor(
                initialValue = clockRegistry.createCurrentClock()
            )

    override val previewClock: StateFlow<ClockController> =
        currentClockId
            .map { clockRegistry.createCurrentClock() }
            .stateIn(
                scope = applicationScope,
                started = SharingStarted.WhileSubscribed(),
                initialValue = clockRegistry.createCurrentClock()
            )

    @VisibleForTesting
    suspend fun getClockSize(): SettingsClockSize {
        return withContext(backgroundDispatcher) {
+2 −0
Original line number Diff line number Diff line
@@ -44,6 +44,8 @@ constructor(

    val currentClock: StateFlow<ClockController?> = keyguardClockRepository.currentClock

    val previewClock: StateFlow<ClockController> = keyguardClockRepository.previewClock

    var clock: ClockController? by keyguardClockRepository.clockEventController::clock

    val clockSize: StateFlow<Int> = keyguardClockRepository.clockSize
+3 −13
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.systemui.keyguard.ui.binder

import android.transition.TransitionManager
import android.transition.TransitionSet
import android.util.Log
import android.view.View.INVISIBLE
import androidx.annotation.VisibleForTesting
import androidx.constraintlayout.helper.widget.Layer
@@ -36,7 +35,6 @@ import com.android.systemui.keyguard.ui.view.layout.sections.ClockSection
import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.plugins.clocks.ClockController
import com.android.systemui.res.R
import com.android.systemui.shared.clocks.DEFAULT_CLOCK_ID
import kotlinx.coroutines.launch

@@ -78,10 +76,6 @@ object KeyguardClockViewBinder {
                launch {
                    if (!migrateClocksToBlueprint()) return@launch
                    viewModel.clockShouldBeCentered.collect { clockShouldBeCentered ->
                        Log.d(
                            "ClockViewBinder",
                            "Sherry clockShouldBeCentered $clockShouldBeCentered"
                        )
                        viewModel.clock?.let {
                            // Weather clock also has hasCustomPositionUpdatedAnimation as true
                            // TODO(b/323020908): remove ID check
@@ -169,16 +163,12 @@ object KeyguardClockViewBinder {
        rootView: ConstraintLayout,
    ) {
        clockController?.let { clock ->
            clock.smallClock.layout.views[0].id = R.id.lockscreen_clock_view
            if (clock.largeClock.layout.views.size == 1) {
                clock.largeClock.layout.views[0].id = R.id.lockscreen_clock_view_large
            }
            // small clock should either be a single view or container with id
            // `lockscreen_clock_view`
            clock.smallClock.layout.views.forEach {
                rootView.addView(it).apply { it.visibility = INVISIBLE }
            }
            clock.largeClock.layout.views.forEach { rootView.addView(it) }
            clock.largeClock.layout.views.forEach {
                rootView.addView(it).apply { it.visibility = INVISIBLE }
            }
        }
    }
    fun applyConstraints(
Loading