1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 * except in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the 10 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 11 * KIND, either express or implied. See the License for the specific language governing 12 * permissions and limitations under the License. 13 */ 14 package com.android.systemui.plugins.clocks 15 16 import android.graphics.drawable.Drawable 17 18 data class ClockPickerConfig 19 @JvmOverloads 20 constructor( 21 val id: String, 22 23 /** Localized name of the clock */ 24 val name: String, 25 26 /** Localized accessibility description for the clock */ 27 val description: String, 28 29 /* Static & lightweight thumbnail version of the clock */ 30 val thumbnail: Drawable, 31 32 /** True if the clock will react to tone changes in the seed color */ 33 val isReactiveToTone: Boolean = true, 34 35 /** Font axes that can be modified on this clock */ 36 val axes: List<ClockFontAxis> = listOf(), 37 ) 38 39 /** Represents an Axis that can be modified */ 40 data class ClockFontAxis( 41 /** Axis key, not user renderable */ 42 val key: String, 43 44 /** Intended mode of user interaction */ 45 val type: AxisType, 46 47 /** Maximum value the axis supports */ 48 val maxValue: Float, 49 50 /** Minimum value the axis supports */ 51 val minValue: Float, 52 53 /** Current value the axis is set to */ 54 val currentValue: Float, 55 56 /** User-renderable name of the axis */ 57 val name: String, 58 59 /** Description of the axis */ 60 val description: String, 61 ) { toSettingnull62 fun toSetting() = ClockFontAxisSetting(key, currentValue) 63 64 companion object { 65 fun merge( 66 fontAxes: List<ClockFontAxis>, 67 axisSettings: List<ClockFontAxisSetting>, 68 ): List<ClockFontAxis> { 69 val result = mutableListOf<ClockFontAxis>() 70 for (axis in fontAxes) { 71 val setting = axisSettings.firstOrNull { axis.key == it.key } 72 val output = setting?.let { axis.copy(currentValue = it.value) } ?: axis 73 result.add(output) 74 } 75 return result 76 } 77 } 78 } 79 80 /** Axis user interaction modes */ 81 enum class AxisType { 82 /** Continuous range between minValue & maxValue. */ 83 Float, 84 85 /** Only minValue & maxValue are valid. No intermediate values between them are allowed. */ 86 Boolean, 87 } 88