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

Commit 472e3aa9 authored by Hawkwood Glazier's avatar Hawkwood Glazier Committed by Android (Google) Code Review
Browse files

Merge "Remove the dynamic Layer Factories" into main

parents bb4f085b f8f5ad5b
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ import androidx.compose.ui.viewinterop.AndroidView
import com.android.compose.animation.scene.ElementKey
import com.android.compose.animation.scene.SceneScope
import com.android.compose.modifiers.padding
import com.android.systemui.customization.R as customizationR
import com.android.systemui.customization.R as customR
import com.android.systemui.keyguard.ui.composable.blueprint.WeatherClockElementKeys
import com.android.systemui.keyguard.ui.composable.modifier.burnInAware
import com.android.systemui.keyguard.ui.viewmodel.AodBurnInViewModel
@@ -57,12 +57,12 @@ constructor(
        Row(
            modifier =
                Modifier.padding(
                        horizontal = dimensionResource(customizationR.dimen.clock_padding_start)
                        horizontal = dimensionResource(customR.dimen.clock_padding_start)
                    )
                    .burnInAware(aodBurnInViewModel, burnInParams, isClock = true)
        ) {
            WeatherElement(
                weatherClockElementViewId = customizationR.id.weather_clock_time,
                weatherClockElementViewId = customR.id.weather_clock_time,
                clock = clock,
                elementKey = WeatherClockElementKeys.timeElementKey,
            )
@@ -75,7 +75,7 @@ constructor(
        modifier: Modifier = Modifier,
    ) {
        WeatherElement(
            weatherClockElementViewId = customizationR.id.weather_clock_date,
            weatherClockElementViewId = customR.id.weather_clock_date,
            clock = clock,
            elementKey = WeatherClockElementKeys.dateElementKey,
            modifier = modifier,
@@ -88,7 +88,7 @@ constructor(
        modifier: Modifier = Modifier,
    ) {
        WeatherElement(
            weatherClockElementViewId = customizationR.id.weather_clock_weather_icon,
            weatherClockElementViewId = customR.id.weather_clock_weather_icon,
            clock = clock,
            elementKey = WeatherClockElementKeys.weatherIconElementKey,
            modifier = modifier.wrapContentSize(),
@@ -101,7 +101,7 @@ constructor(
        modifier: Modifier = Modifier,
    ) {
        WeatherElement(
            weatherClockElementViewId = customizationR.id.weather_clock_alarm_dnd,
            weatherClockElementViewId = customR.id.weather_clock_alarm_dnd,
            clock = clock,
            elementKey = WeatherClockElementKeys.dndAlarmElementKey,
            modifier = modifier.wrapContentSize(),
@@ -114,7 +114,7 @@ constructor(
        modifier: Modifier = Modifier,
    ) {
        WeatherElement(
            weatherClockElementViewId = customizationR.id.weather_clock_temperature,
            weatherClockElementViewId = customR.id.weather_clock_temperature,
            clock = clock,
            elementKey = WeatherClockElementKeys.temperatureElementKey,
            modifier = modifier.wrapContentSize(),
@@ -159,7 +159,7 @@ constructor(
            modifier =
                Modifier.height(IntrinsicSize.Max)
                    .padding(
                        horizontal = dimensionResource(customizationR.dimen.clock_padding_start)
                        horizontal = dimensionResource(customR.dimen.clock_padding_start)
                    )
                    .burnInAware(aodBurnInViewModel, burnInParams, isClock = true)
        ) {
@@ -168,7 +168,7 @@ constructor(
                modifier =
                    Modifier.fillMaxSize()
                        .padding(
                            start = dimensionResource(customizationR.dimen.clock_padding_start)
                            start = dimensionResource(customR.dimen.clock_padding_start)
                        )
            ) {
                Weather(clock = clock, modifier = Modifier.align(Alignment.TopStart))
+3 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <item type="id" name="lockscreen_clock_view_large" />
    <item type="id" name="lockscreen_clock_view" />

    <!-- View ids for elements in large weather clock -->
    <item type="id" name="weather_clock_time" />
    <item type="id" name="weather_clock_date" />
+11 −23
Original line number Diff line number Diff line
@@ -30,16 +30,16 @@ import com.android.systemui.plugins.clocks.ClockFaceEvents
import com.android.systemui.plugins.clocks.ClockReactiveSetting
import com.android.systemui.plugins.clocks.WeatherData
import com.android.systemui.plugins.clocks.ZenData
import com.android.systemui.shared.clocks.view.DigitalClockFaceView
import com.android.systemui.shared.clocks.view.FlexClockView
import com.android.systemui.shared.clocks.view.SimpleDigitalClockTextView
import java.util.Locale
import java.util.TimeZone

class ComposedDigitalLayerController(
    private val ctx: Context,
    private val assets: AssetLoader,
    private val resources: Resources,
    private val assets: AssetLoader, // TODO(b/364680879): Remove and replace w/ resources
    private val layer: ComposedDigitalHandLayer,
    private val isLargeClock: Boolean,
    messageBuffer: MessageBuffer,
) : SimpleClockLayerController {
    private val logger = Logger(messageBuffer, ComposedDigitalLayerController::class.simpleName!!)
@@ -48,34 +48,22 @@ class ComposedDigitalLayerController(
    val dozeState = DefaultClockController.AnimationState(1F)
    var isRegionDark = true

    override var view: DigitalClockFaceView =
        when (layer.customizedView) {
            "FlexClockView" -> FlexClockView(ctx, assets, messageBuffer)
            else -> {
                throw IllegalStateException("CustomizedView string is not valid")
            }
        }

    // Matches LayerControllerConstructor
    internal constructor(
        ctx: Context,
        assets: AssetLoader,
        layer: ClockLayer,
        isLargeClock: Boolean,
        messageBuffer: MessageBuffer,
    ) : this(ctx, assets, layer as ComposedDigitalHandLayer, isLargeClock, messageBuffer)
    override val view = FlexClockView(ctx, assets, messageBuffer)

    init {
        layer.digitalLayers.forEach {
            val childView = SimpleDigitalClockTextView(ctx, messageBuffer)
            val controller =
                SimpleClockLayerController.Factory.create(
                SimpleDigitalHandLayerController(
                    ctx,
                    resources,
                    assets,
                    it,
                    isLargeClock,
                    it as DigitalHandLayer,
                    childView,
                    messageBuffer,
                )
            view.addView(controller.view)

            view.addView(childView)
            layerControllers.add(controller)
        }
    }
+17 −17
Original line number Diff line number Diff line
@@ -53,11 +53,8 @@ class DefaultClockProvider(
        }

        return if (clockReactiveVariants) {
            // TODO handle the case here where only the smallClock message buffer is added
            val assetLoader =
                AssetLoader(ctx, ctx, "clocks/", messageBuffers?.smallClockMessageBuffer!!)

            SimpleClockController(ctx, assetLoader, FLEX_DESIGN, messageBuffers)
            val assets = AssetLoader(ctx, ctx, "clocks/", messageBuffers!!.infraMessageBuffer)
            FlexClockController(ctx, resources, assets, FLEX_DESIGN, messageBuffers)
        } else {
            DefaultClockController(
                ctx,
@@ -82,6 +79,9 @@ class DefaultClockProvider(
            resources.getString(R.string.clock_default_description),
            // TODO(b/352049256): Update placeholder to actual resource
            resources.getDrawable(R.drawable.clock_default_thumbnail, null),
            isReactiveToTone = true,
            isReactiveToTouch = clockReactiveVariants,
            axes = listOf(), // TODO: Ater some picker definition
        )
    }

@@ -118,9 +118,9 @@ class DefaultClockProvider(
                                    alignment =
                                        DigitalAlignment(
                                            HorizontalAlignment.CENTER,
                                            VerticalAlignment.CENTER
                                            VerticalAlignment.CENTER,
                                        ),
                                    dateTimeFormat = "hh"
                                    dateTimeFormat = "hh",
                                ),
                                DigitalHandLayer(
                                    layerBounds = LayerBounds.FIT,
@@ -146,9 +146,9 @@ class DefaultClockProvider(
                                    alignment =
                                        DigitalAlignment(
                                            HorizontalAlignment.CENTER,
                                            VerticalAlignment.CENTER
                                            VerticalAlignment.CENTER,
                                        ),
                                    dateTimeFormat = "hh"
                                    dateTimeFormat = "hh",
                                ),
                                DigitalHandLayer(
                                    layerBounds = LayerBounds.FIT,
@@ -174,9 +174,9 @@ class DefaultClockProvider(
                                    alignment =
                                        DigitalAlignment(
                                            HorizontalAlignment.CENTER,
                                            VerticalAlignment.CENTER
                                            VerticalAlignment.CENTER,
                                        ),
                                    dateTimeFormat = "mm"
                                    dateTimeFormat = "mm",
                                ),
                                DigitalHandLayer(
                                    layerBounds = LayerBounds.FIT,
@@ -202,11 +202,11 @@ class DefaultClockProvider(
                                    alignment =
                                        DigitalAlignment(
                                            HorizontalAlignment.CENTER,
                                            VerticalAlignment.CENTER
                                            VerticalAlignment.CENTER,
                                        ),
                                    dateTimeFormat = "mm",
                                ),
                            ),
                                    dateTimeFormat = "mm"
                                )
                            )
                    )
                )

@@ -230,7 +230,7 @@ class DefaultClockProvider(
                                renderType = RenderType.CHANGE_WEIGHT,
                            ),
                        alignment = DigitalAlignment(HorizontalAlignment.LEFT, null),
                        dateTimeFormat = "h:mm"
                        dateTimeFormat = "h:mm",
                    )
                )

@@ -239,7 +239,7 @@ class DefaultClockProvider(
                name = "@string/clock_default_name",
                description = "@string/clock_default_description",
                large = ClockFace(layers = largeLayer),
                small = ClockFace(layers = smallLayer)
                small = ClockFace(layers = smallLayer),
            )
        }
    }
+17 −19
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ package com.android.systemui.shared.clocks

import android.content.Context
import android.content.res.Resources
import com.android.systemui.monet.Style as MonetStyle
import com.android.systemui.customization.R
import com.android.systemui.plugins.clocks.AlarmData
import com.android.systemui.plugins.clocks.ClockConfig
import com.android.systemui.plugins.clocks.ClockController
@@ -27,21 +27,24 @@ import com.android.systemui.plugins.clocks.ClockMessageBuffers
import com.android.systemui.plugins.clocks.ClockReactiveSetting
import com.android.systemui.plugins.clocks.WeatherData
import com.android.systemui.plugins.clocks.ZenData
import com.android.systemui.shared.clocks.view.FlexClockView
import java.io.PrintWriter
import java.util.Locale
import java.util.TimeZone

/** Controller for a simple json specified clock */
class SimpleClockController(
/** Controller for the default flex clock */
class FlexClockController(
    private val ctx: Context,
    private val assets: AssetLoader,
    val design: ClockDesign,
    private val resources: Resources,
    private val assets: AssetLoader, // TODO(b/364680879): Remove and replace w/ resources
    val design: ClockDesign, // TODO(b/364680879): Remove when done inlining
    val messageBuffers: ClockMessageBuffers?,
) : ClockController {
    override val smallClock = run {
        val buffer = messageBuffers?.smallClockMessageBuffer ?: LogUtil.DEFAULT_MESSAGE_BUFFER
        SimpleClockFaceController(
        FlexClockFaceController(
            ctx,
            resources,
            assets.copy(messageBuffer = buffer),
            design.small ?: design.large!!,
            false,
@@ -51,8 +54,9 @@ class SimpleClockController(

    override val largeClock = run {
        val buffer = messageBuffers?.largeClockMessageBuffer ?: LogUtil.DEFAULT_MESSAGE_BUFFER
        SimpleClockFaceController(
        FlexClockFaceController(
            ctx,
            resources,
            assets.copy(messageBuffer = buffer),
            design.large ?: design.small!!,
            true,
@@ -62,16 +66,10 @@ class SimpleClockController(

    override val config: ClockConfig by lazy {
        ClockConfig(
            design.id,
            design.name?.let { assets.tryReadString(it) ?: it } ?: "",
            design.description?.let { assets.tryReadString(it) ?: it } ?: "",
            isReactiveToTone =
                design.colorPalette == null || design.colorPalette == MonetStyle.CLOCK,
            useAlternateSmartspaceAODTransition =
                smallClock.config.hasCustomWeatherDataDisplay ||
                    largeClock.config.hasCustomWeatherDataDisplay,
            useCustomClockScene =
                smallClock.config.useCustomClockScene || largeClock.config.useCustomClockScene,
            DEFAULT_CLOCK_ID,
            resources.getString(R.string.clock_default_name),
            resources.getString(R.string.clock_default_description),
            isReactiveToTone = true,
        )
    }

@@ -80,8 +78,8 @@ class SimpleClockController(
            override var isReactiveTouchInteractionEnabled = false
                set(value) {
                    field = value
                    smallClock.events.isReactiveTouchInteractionEnabled = value
                    largeClock.events.isReactiveTouchInteractionEnabled = value
                    val view = largeClock.view as FlexClockView
                    view.isReactiveTouchInteractionEnabled = value
                }

            override fun onTimeZoneChanged(timeZone: TimeZone) {
Loading