• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.systemui.shared.clocks
18 
19 import com.android.systemui.animation.AxisDefinition
20 import com.android.systemui.plugins.clocks.AxisType
21 import com.android.systemui.plugins.clocks.ClockAxisStyle
22 import com.android.systemui.plugins.clocks.ClockFontAxis
23 
24 object FontUtils {
toClockAxisnull25     fun AxisDefinition.toClockAxis(
26         type: AxisType,
27         currentValue: Float? = null,
28         name: String,
29         description: String,
30     ): ClockFontAxis {
31         return ClockFontAxis(
32             key = this.tag,
33             type = type,
34             maxValue = this.maxValue,
35             minValue = this.minValue,
36             currentValue = currentValue ?: this.defaultValue,
37             name = name,
38             description = description,
39         )
40     }
41 
putnull42     fun ClockAxisStyle.put(def: AxisDefinition, value: Float? = null) {
43         this.put(def.tag, value ?: def.defaultValue)
44     }
45 
setnull46     operator fun ClockAxisStyle.set(def: AxisDefinition, value: Float) {
47         this[def.tag] = value
48     }
49 
getnull50     operator fun ClockAxisStyle.get(def: AxisDefinition): Float {
51         return this[def.tag] ?: def.defaultValue
52     }
53 }
54