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

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

Merge "Remove clock id check and change them to properties of ClockConfig" into main

parents 7a03fb2c aaf26c55
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -267,6 +267,9 @@ data class ClockConfig(

    /** True if the clock will react to tone changes in the seed color. */
    val isReactiveToTone: Boolean = true,

    /** True if the clock is large frame clock, which will use weather in compose. */
    val useCustomClockScene: Boolean = false,
)

/** Render configuration options for a clock face. Modifies the way SystemUI behaves. */
@@ -283,6 +286,9 @@ data class ClockFaceConfig(
     * animation will be used (e.g. a simple translation).
     */
    val hasCustomPositionUpdatedAnimation: Boolean = false,

    /** True if the clock is large frame clock, which will use weatherBlueprint in compose. */
    val useCustomClockScene: Boolean = false,
)

/** Structure for keeping clock-specific settings */
+6 −10
Original line number Diff line number Diff line
@@ -36,7 +36,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.shared.clocks.DEFAULT_CLOCK_ID
import kotlinx.coroutines.launch

object KeyguardClockViewBinder {
@@ -76,13 +75,13 @@ object KeyguardClockViewBinder {
                }
                launch {
                    if (!MigrateClocksToBlueprint.isEnabled) return@launch
                    viewModel.clockShouldBeCentered.collect { clockShouldBeCentered ->
                    viewModel.clockShouldBeCentered.collect {
                        viewModel.currentClock.value?.let {
                            // Weather clock also has hasCustomPositionUpdatedAnimation as true
                            // TODO(b/323020908): remove ID check
                            // TODO(b/301502635): remove "!it.config.useCustomClockScene" when
                            // migrate clocks to blueprint is fully rolled out
                            if (
                                it.largeClock.config.hasCustomPositionUpdatedAnimation &&
                                    it.config.id == DEFAULT_CLOCK_ID
                                    !it.config.useCustomClockScene
                            ) {
                                blueprintInteractor.refreshBlueprint(Type.DefaultClockStepping)
                            } else {
@@ -93,12 +92,9 @@ object KeyguardClockViewBinder {
                }
                launch {
                    if (!MigrateClocksToBlueprint.isEnabled) return@launch
                    viewModel.isAodIconsVisible.collect { isAodIconsVisible ->
                    viewModel.isAodIconsVisible.collect {
                        viewModel.currentClock.value?.let {
                            // Weather clock also has hasCustomPositionUpdatedAnimation as true
                            if (
                                viewModel.useLargeClock && it.config.id == "DIGITAL_CLOCK_WEATHER"
                            ) {
                            if (viewModel.useLargeClock && it.config.useCustomClockScene) {
                                blueprintInteractor.refreshBlueprint(Type.DefaultTransition)
                            }
                        }
+1 −2
Original line number Diff line number Diff line
@@ -118,8 +118,7 @@ constructor(
                currentClock
            ) { isLargeClockVisible, clockShouldBeCentered, shadeMode, currentClock ->
                val shouldUseSplitShade = shadeMode == ShadeMode.Split
                // TODO(b/326098079): make id a constant field in config
                if (currentClock?.config?.id == "DIGITAL_CLOCK_WEATHER") {
                if (currentClock?.config?.useCustomClockScene == true) {
                    val weatherClockLayout =
                        when {
                            shouldUseSplitShade && clockShouldBeCentered ->
+2 −2
Original line number Diff line number Diff line
@@ -205,9 +205,9 @@ public class KeyguardClockSwitchControllerBaseTest extends SysuiTestCase {
        when(mClockRegistry.createCurrentClock()).thenReturn(mClockController);
        when(mClockEventController.getClock()).thenReturn(mClockController);
        when(mSmallClockController.getConfig())
                .thenReturn(new ClockFaceConfig(ClockTickRate.PER_MINUTE, false, false));
                .thenReturn(new ClockFaceConfig(ClockTickRate.PER_MINUTE, false, false, false));
        when(mLargeClockController.getConfig())
                .thenReturn(new ClockFaceConfig(ClockTickRate.PER_MINUTE, false, false));
                .thenReturn(new ClockFaceConfig(ClockTickRate.PER_MINUTE, false, false, false));

        mSliceView = new View(getContext());
        when(mView.findViewById(R.id.keyguard_slice_view)).thenReturn(mSliceView);
+2 −2
Original line number Diff line number Diff line
@@ -272,9 +272,9 @@ public class KeyguardClockSwitchControllerTest extends KeyguardClockSwitchContro
        assertEquals(View.VISIBLE, mFakeDateView.getVisibility());

        when(mSmallClockController.getConfig())
                .thenReturn(new ClockFaceConfig(ClockTickRate.PER_MINUTE, true, false));
                .thenReturn(new ClockFaceConfig(ClockTickRate.PER_MINUTE, true, false, true));
        when(mLargeClockController.getConfig())
                .thenReturn(new ClockFaceConfig(ClockTickRate.PER_MINUTE, true, false));
                .thenReturn(new ClockFaceConfig(ClockTickRate.PER_MINUTE, true, false, true));
        verify(mClockRegistry).registerClockChangeListener(listenerArgumentCaptor.capture());
        listenerArgumentCaptor.getValue().onCurrentClockChanged();

Loading