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

Commit 2a8c7757 authored by George Lin's avatar George Lin
Browse files

Remove fontAxes from the ClockMetadataViewModel

This is to remove font axes since we can just use the axis config

Test: Manually tested
Bug: 395647577
Flag: com.android.systemui.shared.new_customization_picker_ui
Change-Id: I1d2e16e0c260c9f7ee53992e0a1ecf4c159710dd
parent c5da3fc5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ interface ClockPickerRepository {

    suspend fun setClockSize(size: ClockSize)

    suspend fun setClockFontAxes(axisSettings: ClockAxisStyle)
    suspend fun setClockAxisStyle(axisStyle: ClockAxisStyle)

    fun isReactiveToTone(clockId: ClockId): Boolean?
}
+2 −7
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import com.android.customization.picker.clock.shared.ClockSize
import com.android.customization.picker.clock.shared.model.ClockMetadataModel
import com.android.systemui.plugins.clocks.AxisPresetConfig
import com.android.systemui.plugins.clocks.ClockAxisStyle
import com.android.systemui.plugins.clocks.ClockFontAxis
import com.android.systemui.plugins.clocks.ClockId
import com.android.systemui.plugins.clocks.ClockMetadata
import com.android.systemui.shared.clocks.ClockRegistry
@@ -74,7 +73,6 @@ constructor(
                                    description = clockConfig.description,
                                    thumbnail = clockConfig.thumbnail,
                                    isReactiveToTone = clockConfig.isReactiveToTone,
                                    fontAxes = clockConfig.axes,
                                    axisPresetConfig = clockConfig.presetConfig,
                                )
                            } else {
@@ -125,7 +123,6 @@ constructor(
                                    description = it.description,
                                    thumbnail = it.thumbnail,
                                    isReactiveToTone = it.isReactiveToTone,
                                    fontAxes = it.axes,
                                    axisPresetConfig = it.presetConfig,
                                    selectedColorId = metadata?.getSelectedColorId(),
                                    colorTone =
@@ -198,9 +195,9 @@ constructor(
        )
    }

    override suspend fun setClockFontAxes(axisSettings: ClockAxisStyle) {
    override suspend fun setClockAxisStyle(axisStyle: ClockAxisStyle) {
        registry.mutateSetting { oldSettings ->
            val newSettings = oldSettings.copy(axes = axisSettings)
            val newSettings = oldSettings.copy(axes = axisStyle)
            newSettings.metadata = oldSettings.metadata
            newSettings
        }
@@ -231,7 +228,6 @@ constructor(
        description: String,
        thumbnail: Drawable,
        isReactiveToTone: Boolean,
        fontAxes: List<ClockFontAxis>,
        axisPresetConfig: AxisPresetConfig?,
        selectedColorId: String? = null,
        @IntRange(from = 0, to = 100) colorTone: Int = 0,
@@ -243,7 +239,6 @@ constructor(
            description = description,
            thumbnail = thumbnail,
            isReactiveToTone = isReactiveToTone,
            fontAxes = fontAxes,
            axisPresetConfig = axisPresetConfig,
            selectedColorId = selectedColorId,
            colorToneProgress = colorTone,
+2 −4
Original line number Diff line number Diff line
@@ -61,9 +61,7 @@ constructor(
    val seedColor: Flow<Int?> = repository.selectedClock.map { clock -> clock.seedColor }

    val axisSettings: Flow<ClockAxisStyle?> =
        repository.selectedClock.map { clock ->
            if (clock.fontAxes.isEmpty()) null else ClockAxisStyle(clock.fontAxes)
        }
        repository.selectedClock.map { it.axisPresetConfig?.current?.style }

    val selectedClockSize: Flow<ClockSize> = repository.selectedClockSize

@@ -136,7 +134,7 @@ constructor(
            )
        }
        clockSnapshotModel.clockId?.let { repository.setSelectedClock(it) }
        clockSnapshotModel.axisSettings?.let { repository.setClockFontAxes(it) }
        clockSnapshotModel.axisSettings?.let { repository.setClockAxisStyle(it) }
    }

    private suspend fun storeCurrentClockOption(clockSnapshotModel: ClockSnapshotModel) {
+2 −2
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ constructor(private val repository: ClockPickerRepository) : SnapshotRestorer {
                seedColor = repository.selectedClock.map { clock -> clock.seedColor }.firstOrNull(),
                axisSettings =
                    repository.selectedClock
                        .map { clock -> ClockAxisStyle(clock.fontAxes) }
                        .map { clock -> clock.axisPresetConfig?.current?.style ?: ClockAxisStyle() }
                        .firstOrNull(),
            )
        return snapshot(originalOption)
@@ -97,7 +97,7 @@ constructor(private val repository: ClockPickerRepository) : SnapshotRestorer {
                )
            }
            optionToRestore.clockId?.let { repository.setSelectedClock(it) }
            optionToRestore.axisSettings?.let { repository.setClockFontAxes(it) }
            optionToRestore.axisSettings?.let { repository.setClockAxisStyle(it) }
        }
    }

+0 −2
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.graphics.drawable.Drawable
import androidx.annotation.ColorInt
import androidx.annotation.IntRange
import com.android.systemui.plugins.clocks.AxisPresetConfig
import com.android.systemui.plugins.clocks.ClockFontAxis

/** Model for clock metadata. */
data class ClockMetadataModel(
@@ -30,7 +29,6 @@ data class ClockMetadataModel(
    val description: String,
    val thumbnail: Drawable,
    val isReactiveToTone: Boolean,
    val fontAxes: List<ClockFontAxis>,
    val axisPresetConfig: AxisPresetConfig?, // Null indicates the preset list should be disabled.
    val selectedColorId: String?,
    @IntRange(from = 0, to = 100) val colorToneProgress: Int,
Loading