Loading packages/SystemUI/customization/src/com/android/systemui/shared/clocks/ClockDesign.kt +0 −6 Original line number Diff line number Diff line Loading @@ -166,12 +166,6 @@ data class FontTextStyle( // A color literal like `#FF00FF` or a color resource like `@android:color/system_accent1_100` val fillColorDark: String? = null, override val fontSizeScale: Float? = null, /** * use `wdth` for width, `wght` for weight, 'opsz' for optical size single quote for tag name, * and no quote for value separate different axis with `,` e.g. "'wght' 1000, 'wdth' 108, 'opsz' * 90" */ var fontVariation: String? = null, // used when alternate in one font file is needed var fontFeatureSettings: String? = null, val renderType: RenderType = RenderType.STROKE_TEXT, Loading packages/SystemUI/customization/src/com/android/systemui/shared/clocks/ClockRegistry.kt +15 −10 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import org.json.JSONObject private val KEY_TIMESTAMP = "appliedTimestamp" private val KNOWN_PLUGINS = Loading Loading @@ -299,7 +300,7 @@ open class ClockRegistry( ) } ClockSettings.deserialize(json) ClockSettings.fromJson(JSONObject(json)) } catch (ex: Exception) { logger.e("Failed to parse clock settings", ex) null Loading @@ -312,21 +313,24 @@ open class ClockRegistry( assert.isNotMainThread() try { value?.metadata?.put(KEY_TIMESTAMP, System.currentTimeMillis()) val json = value?.let { it.metadata.put(KEY_TIMESTAMP, System.currentTimeMillis()) ClockSettings.toJson(it) } ?: "" val json = ClockSettings.serialize(value) if (handleAllUsers) { Settings.Secure.putStringForUser( context.contentResolver, Settings.Secure.LOCK_SCREEN_CUSTOM_CLOCK_FACE, json, json.toString(), ActivityManager.getCurrentUser(), ) } else { Settings.Secure.putString( context.contentResolver, Settings.Secure.LOCK_SCREEN_CUSTOM_CLOCK_FACE, json, json.toString(), ) } } catch (ex: Exception) { Loading Loading @@ -557,14 +561,15 @@ open class ClockRegistry( } fun getClocks(): List<ClockMetadata> { if (!isEnabled) { return listOf(availableClocks[DEFAULT_CLOCK_ID]!!.metadata) } if (!isEnabled) return listOf(availableClocks[DEFAULT_CLOCK_ID]!!.metadata) return availableClocks.map { (_, clock) -> clock.metadata } } fun getClockPickerConfig(clockId: ClockId): ClockPickerConfig? = availableClocks[clockId]?.provider?.getClockPickerConfig(clockId) fun getClockPickerConfig(clockId: ClockId): ClockPickerConfig? { val clockSettings = settings?.let { if (clockId == it.clockId) it else null } ?: ClockSettings(clockId) return availableClocks[clockId]?.provider?.getClockPickerConfig(clockSettings) } fun createExampleClock(clockId: ClockId): ClockController? = createClock(clockId) Loading packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockProvider.kt +39 −88 Original line number Diff line number Diff line Loading @@ -19,10 +19,9 @@ import android.view.LayoutInflater import com.android.systemui.customization.R import com.android.systemui.log.core.LogLevel import com.android.systemui.log.core.LogcatOnlyMessageBuffer import com.android.systemui.plugins.clocks.AxisType import com.android.systemui.plugins.clocks.ClockController import com.android.systemui.plugins.clocks.ClockFontAxis import com.android.systemui.plugins.clocks.ClockId import com.android.systemui.plugins.clocks.ClockFontAxisSetting import com.android.systemui.plugins.clocks.ClockMessageBuffers import com.android.systemui.plugins.clocks.ClockMetadata import com.android.systemui.plugins.clocks.ClockPickerConfig Loading Loading @@ -61,7 +60,15 @@ class DefaultClockProvider( messageBuffers?.infraMessageBuffer ?: LogcatOnlyMessageBuffer(LogLevel.INFO) val assets = AssetLoader(ctx, ctx, "clocks/", buffer) assets.setSeedColor(settings.seedColor, null) FlexClockController(ctx, resources, assets, FLEX_DESIGN, messageBuffers) val fontAxes = ClockFontAxis.merge(FlexClockController.FONT_AXES, settings.axes) FlexClockController( ctx, resources, settings.copy(axes = fontAxes.map { it.toSetting() }), assets, FLEX_DESIGN, messageBuffers, ) } else { DefaultClockController( ctx, Loading @@ -75,11 +82,14 @@ class DefaultClockProvider( } } override fun getClockPickerConfig(id: ClockId): ClockPickerConfig { if (id != DEFAULT_CLOCK_ID) { throw IllegalArgumentException("$id is unsupported by $TAG") override fun getClockPickerConfig(settings: ClockSettings): ClockPickerConfig { if (settings.clockId != DEFAULT_CLOCK_ID) { throw IllegalArgumentException("${settings.clockId} is unsupported by $TAG") } val fontAxes = if (!isClockReactiveVariantsEnabled) listOf() else ClockFontAxis.merge(FlexClockController.FONT_AXES, settings.axes) return ClockPickerConfig( DEFAULT_CLOCK_ID, resources.getString(R.string.clock_default_name), Loading @@ -87,52 +97,28 @@ class DefaultClockProvider( // TODO(b/352049256): Update placeholder to actual resource resources.getDrawable(R.drawable.clock_default_thumbnail, null), isReactiveToTone = true, // TODO(b/364673969): Populate the rest of this axes = if (isClockReactiveVariantsEnabled) listOf( ClockFontAxis( key = "wght", type = AxisType.Float, minValue = 1f, currentValue = 400f, maxValue = 1000f, name = "Weight", description = "Glyph Weight", ), ClockFontAxis( key = "wdth", type = AxisType.Float, minValue = 25f, currentValue = 100f, maxValue = 151f, name = "Width", description = "Glyph Width", ), ClockFontAxis( key = "ROND", type = AxisType.Boolean, minValue = 0f, currentValue = 0f, maxValue = 100f, name = "Round", description = "Glyph Roundness", ), ClockFontAxis( key = "slnt", type = AxisType.Boolean, minValue = 0f, currentValue = 0f, maxValue = -10f, name = "Slant", description = "Glyph Slant", ), ) else listOf(), axes = fontAxes, ) } companion object { // TODO(b/364681643): Variations for retargetted DIGITAL_CLOCK_FLEX val LEGACY_FLEX_LS_VARIATION = listOf( ClockFontAxisSetting("wght", 600f), ClockFontAxisSetting("wdth", 100f), ClockFontAxisSetting("ROND", 100f), ClockFontAxisSetting("slnt", 0f), ) val LEGACY_FLEX_AOD_VARIATION = listOf( ClockFontAxisSetting("wght", 74f), ClockFontAxisSetting("wdth", 43f), ClockFontAxisSetting("ROND", 100f), ClockFontAxisSetting("slnt", 0f), ) val FLEX_DESIGN = run { val largeLayer = listOf( Loading @@ -144,16 +130,9 @@ class DefaultClockProvider( DigitalHandLayer( layerBounds = LayerBounds.FIT, timespec = DigitalTimespec.FIRST_DIGIT, style = FontTextStyle( lineHeight = 147.25f, fontVariation = "'wght' 603, 'wdth' 100, 'opsz' 144, 'ROND' 100, 'slnt' 0", ), style = FontTextStyle(lineHeight = 147.25f), aodStyle = FontTextStyle( fontVariation = "'wght' 74, 'wdth' 43, 'opsz' 144, 'ROND' 100, 'slnt' 0", fillColorLight = "#FFFFFFFF", outlineColor = "#00000000", renderType = RenderType.CHANGE_WEIGHT, Loading @@ -170,16 +149,9 @@ class DefaultClockProvider( DigitalHandLayer( layerBounds = LayerBounds.FIT, timespec = DigitalTimespec.SECOND_DIGIT, style = FontTextStyle( lineHeight = 147.25f, fontVariation = "'wght' 603, 'wdth' 100, 'opsz' 144, 'ROND' 100, 'slnt' 0", ), style = FontTextStyle(lineHeight = 147.25f), aodStyle = FontTextStyle( fontVariation = "'wght' 74, 'wdth' 43, 'opsz' 144, 'ROND' 100, 'slnt' 0", fillColorLight = "#FFFFFFFF", outlineColor = "#00000000", renderType = RenderType.CHANGE_WEIGHT, Loading @@ -196,16 +168,9 @@ class DefaultClockProvider( DigitalHandLayer( layerBounds = LayerBounds.FIT, timespec = DigitalTimespec.FIRST_DIGIT, style = FontTextStyle( lineHeight = 147.25f, fontVariation = "'wght' 603, 'wdth' 100, 'opsz' 144, 'ROND' 100, 'slnt' 0", ), style = FontTextStyle(lineHeight = 147.25f), aodStyle = FontTextStyle( fontVariation = "'wght' 74, 'wdth' 43, 'opsz' 144, 'ROND' 100, 'slnt' 0", fillColorLight = "#FFFFFFFF", outlineColor = "#00000000", renderType = RenderType.CHANGE_WEIGHT, Loading @@ -222,16 +187,9 @@ class DefaultClockProvider( DigitalHandLayer( layerBounds = LayerBounds.FIT, timespec = DigitalTimespec.SECOND_DIGIT, style = FontTextStyle( lineHeight = 147.25f, fontVariation = "'wght' 603, 'wdth' 100, 'opsz' 144, 'ROND' 100, 'slnt' 0", ), style = FontTextStyle(lineHeight = 147.25f), aodStyle = FontTextStyle( fontVariation = "'wght' 74, 'wdth' 43, 'opsz' 144, 'ROND' 100, 'slnt' 0", fillColorLight = "#FFFFFFFF", outlineColor = "#00000000", renderType = RenderType.CHANGE_WEIGHT, Loading @@ -254,16 +212,9 @@ class DefaultClockProvider( DigitalHandLayer( layerBounds = LayerBounds.FIT, timespec = DigitalTimespec.TIME_FULL_FORMAT, style = FontTextStyle( fontVariation = "'wght' 600, 'wdth' 100, 'opsz' 144, 'ROND' 100, 'slnt' 0", fontSizeScale = 0.98f, ), style = FontTextStyle(fontSizeScale = 0.98f), aodStyle = FontTextStyle( fontVariation = "'wght' 133, 'wdth' 43, 'opsz' 144, 'ROND' 100, 'slnt' 0", fillColorLight = "#FFFFFFFF", outlineColor = "#00000000", renderType = RenderType.CHANGE_WEIGHT, Loading packages/SystemUI/customization/src/com/android/systemui/shared/clocks/FlexClockController.kt +51 −2 Original line number Diff line number Diff line Loading @@ -20,11 +20,14 @@ import android.content.Context import android.content.res.Resources import com.android.systemui.customization.R import com.android.systemui.plugins.clocks.AlarmData import com.android.systemui.plugins.clocks.AxisType import com.android.systemui.plugins.clocks.ClockConfig import com.android.systemui.plugins.clocks.ClockController import com.android.systemui.plugins.clocks.ClockEvents import com.android.systemui.plugins.clocks.ClockFontAxis import com.android.systemui.plugins.clocks.ClockFontAxisSetting import com.android.systemui.plugins.clocks.ClockMessageBuffers import com.android.systemui.plugins.clocks.ClockSettings import com.android.systemui.plugins.clocks.ThemeConfig import com.android.systemui.plugins.clocks.WeatherData import com.android.systemui.plugins.clocks.ZenData Loading @@ -37,6 +40,7 @@ import java.util.TimeZone class FlexClockController( private val ctx: Context, private val resources: Resources, private val settings: ClockSettings, 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?, Loading Loading @@ -114,13 +118,16 @@ class FlexClockController( } override fun onFontAxesChanged(axes: List<ClockFontAxisSetting>) { smallClock.events.onFontAxesChanged(axes) largeClock.events.onFontAxesChanged(axes) val fontAxes = ClockFontAxis.merge(FONT_AXES, axes).map { it.toSetting() } smallClock.events.onFontAxesChanged(fontAxes) largeClock.events.onFontAxesChanged(fontAxes) } } override fun initialize(isDarkTheme: Boolean, dozeFraction: Float, foldFraction: Float) { val theme = ThemeConfig(isDarkTheme, assets.seedColor) events.onFontAxesChanged(settings.axes) smallClock.run { events.onThemeChanged(theme) animations.doze(dozeFraction) Loading @@ -137,4 +144,46 @@ class FlexClockController( } override fun dump(pw: PrintWriter) {} companion object { val FONT_AXES = listOf( ClockFontAxis( key = "wght", type = AxisType.Float, minValue = 1f, currentValue = 400f, maxValue = 1000f, name = "Weight", description = "Glyph Weight", ), ClockFontAxis( key = "wdth", type = AxisType.Float, minValue = 25f, currentValue = 100f, maxValue = 151f, name = "Width", description = "Glyph Width", ), ClockFontAxis( key = "ROND", type = AxisType.Boolean, minValue = 0f, currentValue = 0f, maxValue = 100f, name = "Round", description = "Glyph Roundness", ), ClockFontAxis( key = "slnt", type = AxisType.Boolean, minValue = 0f, currentValue = 0f, maxValue = -10f, name = "Slant", description = "Glyph Slant", ), ) } } packages/SystemUI/customization/src/com/android/systemui/shared/clocks/view/FlexClockView.kt +0 −61 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.systemui.shared.clocks.view import android.content.Context import android.graphics.Canvas import android.graphics.Point import android.view.MotionEvent import android.view.View import android.view.ViewGroup import android.widget.RelativeLayout Loading @@ -28,7 +27,6 @@ import com.android.systemui.customization.R import com.android.systemui.log.core.MessageBuffer import com.android.systemui.shared.clocks.AssetLoader import com.android.systemui.shared.clocks.DigitTranslateAnimator import com.android.systemui.shared.clocks.FontTextStyle import kotlin.math.abs import kotlin.math.max import kotlin.math.min Loading @@ -52,65 +50,6 @@ class FlexClockView(context: Context, val assets: AssetLoader, messageBuffer: Me ) } private var prevX = 0f private var prevY = 0f private var isDown = false private var wght = 603f private var wdth = 100f private val MAX_WGHT = 950f private val MIN_WGHT = 50f private val WGHT_SCALE = 0.5f private val MAX_WDTH = 150f private val MIN_WDTH = 0f private val WDTH_SCALE = 0.2f override fun onTouchEvent(evt: MotionEvent): Boolean { if (!isReactiveTouchInteractionEnabled) { return super.onTouchEvent(evt) } when (evt.action) { MotionEvent.ACTION_DOWN -> { isDown = true prevX = evt.x prevY = evt.y return true } MotionEvent.ACTION_MOVE -> { if (!isDown) { return super.onTouchEvent(evt) } wdth = clamp(wdth + (evt.x - prevX) * WDTH_SCALE, MIN_WDTH, MAX_WDTH) wght = clamp(wght + (evt.y - prevY) * WGHT_SCALE, MIN_WGHT, MAX_WGHT) prevX = evt.x prevY = evt.y val fvar = "'wght' $wght, 'wdth' $wdth, 'opsz' 144, 'ROND' 100" digitalClockTextViewMap.forEach { (_, view) -> val textStyle = view.textStyle as FontTextStyle textStyle.fontVariation = fvar view.applyStyles(assets, textStyle, view.aodStyle) } requestLayout() invalidate() return true } MotionEvent.ACTION_UP -> { isDown = false return true } } return super.onTouchEvent(evt) } override fun addView(child: View?) { super.addView(child) (child as SimpleDigitalClockTextView).digitTranslateAnimator = Loading Loading
packages/SystemUI/customization/src/com/android/systemui/shared/clocks/ClockDesign.kt +0 −6 Original line number Diff line number Diff line Loading @@ -166,12 +166,6 @@ data class FontTextStyle( // A color literal like `#FF00FF` or a color resource like `@android:color/system_accent1_100` val fillColorDark: String? = null, override val fontSizeScale: Float? = null, /** * use `wdth` for width, `wght` for weight, 'opsz' for optical size single quote for tag name, * and no quote for value separate different axis with `,` e.g. "'wght' 1000, 'wdth' 108, 'opsz' * 90" */ var fontVariation: String? = null, // used when alternate in one font file is needed var fontFeatureSettings: String? = null, val renderType: RenderType = RenderType.STROKE_TEXT, Loading
packages/SystemUI/customization/src/com/android/systemui/shared/clocks/ClockRegistry.kt +15 −10 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import org.json.JSONObject private val KEY_TIMESTAMP = "appliedTimestamp" private val KNOWN_PLUGINS = Loading Loading @@ -299,7 +300,7 @@ open class ClockRegistry( ) } ClockSettings.deserialize(json) ClockSettings.fromJson(JSONObject(json)) } catch (ex: Exception) { logger.e("Failed to parse clock settings", ex) null Loading @@ -312,21 +313,24 @@ open class ClockRegistry( assert.isNotMainThread() try { value?.metadata?.put(KEY_TIMESTAMP, System.currentTimeMillis()) val json = value?.let { it.metadata.put(KEY_TIMESTAMP, System.currentTimeMillis()) ClockSettings.toJson(it) } ?: "" val json = ClockSettings.serialize(value) if (handleAllUsers) { Settings.Secure.putStringForUser( context.contentResolver, Settings.Secure.LOCK_SCREEN_CUSTOM_CLOCK_FACE, json, json.toString(), ActivityManager.getCurrentUser(), ) } else { Settings.Secure.putString( context.contentResolver, Settings.Secure.LOCK_SCREEN_CUSTOM_CLOCK_FACE, json, json.toString(), ) } } catch (ex: Exception) { Loading Loading @@ -557,14 +561,15 @@ open class ClockRegistry( } fun getClocks(): List<ClockMetadata> { if (!isEnabled) { return listOf(availableClocks[DEFAULT_CLOCK_ID]!!.metadata) } if (!isEnabled) return listOf(availableClocks[DEFAULT_CLOCK_ID]!!.metadata) return availableClocks.map { (_, clock) -> clock.metadata } } fun getClockPickerConfig(clockId: ClockId): ClockPickerConfig? = availableClocks[clockId]?.provider?.getClockPickerConfig(clockId) fun getClockPickerConfig(clockId: ClockId): ClockPickerConfig? { val clockSettings = settings?.let { if (clockId == it.clockId) it else null } ?: ClockSettings(clockId) return availableClocks[clockId]?.provider?.getClockPickerConfig(clockSettings) } fun createExampleClock(clockId: ClockId): ClockController? = createClock(clockId) Loading
packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockProvider.kt +39 −88 Original line number Diff line number Diff line Loading @@ -19,10 +19,9 @@ import android.view.LayoutInflater import com.android.systemui.customization.R import com.android.systemui.log.core.LogLevel import com.android.systemui.log.core.LogcatOnlyMessageBuffer import com.android.systemui.plugins.clocks.AxisType import com.android.systemui.plugins.clocks.ClockController import com.android.systemui.plugins.clocks.ClockFontAxis import com.android.systemui.plugins.clocks.ClockId import com.android.systemui.plugins.clocks.ClockFontAxisSetting import com.android.systemui.plugins.clocks.ClockMessageBuffers import com.android.systemui.plugins.clocks.ClockMetadata import com.android.systemui.plugins.clocks.ClockPickerConfig Loading Loading @@ -61,7 +60,15 @@ class DefaultClockProvider( messageBuffers?.infraMessageBuffer ?: LogcatOnlyMessageBuffer(LogLevel.INFO) val assets = AssetLoader(ctx, ctx, "clocks/", buffer) assets.setSeedColor(settings.seedColor, null) FlexClockController(ctx, resources, assets, FLEX_DESIGN, messageBuffers) val fontAxes = ClockFontAxis.merge(FlexClockController.FONT_AXES, settings.axes) FlexClockController( ctx, resources, settings.copy(axes = fontAxes.map { it.toSetting() }), assets, FLEX_DESIGN, messageBuffers, ) } else { DefaultClockController( ctx, Loading @@ -75,11 +82,14 @@ class DefaultClockProvider( } } override fun getClockPickerConfig(id: ClockId): ClockPickerConfig { if (id != DEFAULT_CLOCK_ID) { throw IllegalArgumentException("$id is unsupported by $TAG") override fun getClockPickerConfig(settings: ClockSettings): ClockPickerConfig { if (settings.clockId != DEFAULT_CLOCK_ID) { throw IllegalArgumentException("${settings.clockId} is unsupported by $TAG") } val fontAxes = if (!isClockReactiveVariantsEnabled) listOf() else ClockFontAxis.merge(FlexClockController.FONT_AXES, settings.axes) return ClockPickerConfig( DEFAULT_CLOCK_ID, resources.getString(R.string.clock_default_name), Loading @@ -87,52 +97,28 @@ class DefaultClockProvider( // TODO(b/352049256): Update placeholder to actual resource resources.getDrawable(R.drawable.clock_default_thumbnail, null), isReactiveToTone = true, // TODO(b/364673969): Populate the rest of this axes = if (isClockReactiveVariantsEnabled) listOf( ClockFontAxis( key = "wght", type = AxisType.Float, minValue = 1f, currentValue = 400f, maxValue = 1000f, name = "Weight", description = "Glyph Weight", ), ClockFontAxis( key = "wdth", type = AxisType.Float, minValue = 25f, currentValue = 100f, maxValue = 151f, name = "Width", description = "Glyph Width", ), ClockFontAxis( key = "ROND", type = AxisType.Boolean, minValue = 0f, currentValue = 0f, maxValue = 100f, name = "Round", description = "Glyph Roundness", ), ClockFontAxis( key = "slnt", type = AxisType.Boolean, minValue = 0f, currentValue = 0f, maxValue = -10f, name = "Slant", description = "Glyph Slant", ), ) else listOf(), axes = fontAxes, ) } companion object { // TODO(b/364681643): Variations for retargetted DIGITAL_CLOCK_FLEX val LEGACY_FLEX_LS_VARIATION = listOf( ClockFontAxisSetting("wght", 600f), ClockFontAxisSetting("wdth", 100f), ClockFontAxisSetting("ROND", 100f), ClockFontAxisSetting("slnt", 0f), ) val LEGACY_FLEX_AOD_VARIATION = listOf( ClockFontAxisSetting("wght", 74f), ClockFontAxisSetting("wdth", 43f), ClockFontAxisSetting("ROND", 100f), ClockFontAxisSetting("slnt", 0f), ) val FLEX_DESIGN = run { val largeLayer = listOf( Loading @@ -144,16 +130,9 @@ class DefaultClockProvider( DigitalHandLayer( layerBounds = LayerBounds.FIT, timespec = DigitalTimespec.FIRST_DIGIT, style = FontTextStyle( lineHeight = 147.25f, fontVariation = "'wght' 603, 'wdth' 100, 'opsz' 144, 'ROND' 100, 'slnt' 0", ), style = FontTextStyle(lineHeight = 147.25f), aodStyle = FontTextStyle( fontVariation = "'wght' 74, 'wdth' 43, 'opsz' 144, 'ROND' 100, 'slnt' 0", fillColorLight = "#FFFFFFFF", outlineColor = "#00000000", renderType = RenderType.CHANGE_WEIGHT, Loading @@ -170,16 +149,9 @@ class DefaultClockProvider( DigitalHandLayer( layerBounds = LayerBounds.FIT, timespec = DigitalTimespec.SECOND_DIGIT, style = FontTextStyle( lineHeight = 147.25f, fontVariation = "'wght' 603, 'wdth' 100, 'opsz' 144, 'ROND' 100, 'slnt' 0", ), style = FontTextStyle(lineHeight = 147.25f), aodStyle = FontTextStyle( fontVariation = "'wght' 74, 'wdth' 43, 'opsz' 144, 'ROND' 100, 'slnt' 0", fillColorLight = "#FFFFFFFF", outlineColor = "#00000000", renderType = RenderType.CHANGE_WEIGHT, Loading @@ -196,16 +168,9 @@ class DefaultClockProvider( DigitalHandLayer( layerBounds = LayerBounds.FIT, timespec = DigitalTimespec.FIRST_DIGIT, style = FontTextStyle( lineHeight = 147.25f, fontVariation = "'wght' 603, 'wdth' 100, 'opsz' 144, 'ROND' 100, 'slnt' 0", ), style = FontTextStyle(lineHeight = 147.25f), aodStyle = FontTextStyle( fontVariation = "'wght' 74, 'wdth' 43, 'opsz' 144, 'ROND' 100, 'slnt' 0", fillColorLight = "#FFFFFFFF", outlineColor = "#00000000", renderType = RenderType.CHANGE_WEIGHT, Loading @@ -222,16 +187,9 @@ class DefaultClockProvider( DigitalHandLayer( layerBounds = LayerBounds.FIT, timespec = DigitalTimespec.SECOND_DIGIT, style = FontTextStyle( lineHeight = 147.25f, fontVariation = "'wght' 603, 'wdth' 100, 'opsz' 144, 'ROND' 100, 'slnt' 0", ), style = FontTextStyle(lineHeight = 147.25f), aodStyle = FontTextStyle( fontVariation = "'wght' 74, 'wdth' 43, 'opsz' 144, 'ROND' 100, 'slnt' 0", fillColorLight = "#FFFFFFFF", outlineColor = "#00000000", renderType = RenderType.CHANGE_WEIGHT, Loading @@ -254,16 +212,9 @@ class DefaultClockProvider( DigitalHandLayer( layerBounds = LayerBounds.FIT, timespec = DigitalTimespec.TIME_FULL_FORMAT, style = FontTextStyle( fontVariation = "'wght' 600, 'wdth' 100, 'opsz' 144, 'ROND' 100, 'slnt' 0", fontSizeScale = 0.98f, ), style = FontTextStyle(fontSizeScale = 0.98f), aodStyle = FontTextStyle( fontVariation = "'wght' 133, 'wdth' 43, 'opsz' 144, 'ROND' 100, 'slnt' 0", fillColorLight = "#FFFFFFFF", outlineColor = "#00000000", renderType = RenderType.CHANGE_WEIGHT, Loading
packages/SystemUI/customization/src/com/android/systemui/shared/clocks/FlexClockController.kt +51 −2 Original line number Diff line number Diff line Loading @@ -20,11 +20,14 @@ import android.content.Context import android.content.res.Resources import com.android.systemui.customization.R import com.android.systemui.plugins.clocks.AlarmData import com.android.systemui.plugins.clocks.AxisType import com.android.systemui.plugins.clocks.ClockConfig import com.android.systemui.plugins.clocks.ClockController import com.android.systemui.plugins.clocks.ClockEvents import com.android.systemui.plugins.clocks.ClockFontAxis import com.android.systemui.plugins.clocks.ClockFontAxisSetting import com.android.systemui.plugins.clocks.ClockMessageBuffers import com.android.systemui.plugins.clocks.ClockSettings import com.android.systemui.plugins.clocks.ThemeConfig import com.android.systemui.plugins.clocks.WeatherData import com.android.systemui.plugins.clocks.ZenData Loading @@ -37,6 +40,7 @@ import java.util.TimeZone class FlexClockController( private val ctx: Context, private val resources: Resources, private val settings: ClockSettings, 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?, Loading Loading @@ -114,13 +118,16 @@ class FlexClockController( } override fun onFontAxesChanged(axes: List<ClockFontAxisSetting>) { smallClock.events.onFontAxesChanged(axes) largeClock.events.onFontAxesChanged(axes) val fontAxes = ClockFontAxis.merge(FONT_AXES, axes).map { it.toSetting() } smallClock.events.onFontAxesChanged(fontAxes) largeClock.events.onFontAxesChanged(fontAxes) } } override fun initialize(isDarkTheme: Boolean, dozeFraction: Float, foldFraction: Float) { val theme = ThemeConfig(isDarkTheme, assets.seedColor) events.onFontAxesChanged(settings.axes) smallClock.run { events.onThemeChanged(theme) animations.doze(dozeFraction) Loading @@ -137,4 +144,46 @@ class FlexClockController( } override fun dump(pw: PrintWriter) {} companion object { val FONT_AXES = listOf( ClockFontAxis( key = "wght", type = AxisType.Float, minValue = 1f, currentValue = 400f, maxValue = 1000f, name = "Weight", description = "Glyph Weight", ), ClockFontAxis( key = "wdth", type = AxisType.Float, minValue = 25f, currentValue = 100f, maxValue = 151f, name = "Width", description = "Glyph Width", ), ClockFontAxis( key = "ROND", type = AxisType.Boolean, minValue = 0f, currentValue = 0f, maxValue = 100f, name = "Round", description = "Glyph Roundness", ), ClockFontAxis( key = "slnt", type = AxisType.Boolean, minValue = 0f, currentValue = 0f, maxValue = -10f, name = "Slant", description = "Glyph Slant", ), ) } }
packages/SystemUI/customization/src/com/android/systemui/shared/clocks/view/FlexClockView.kt +0 −61 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.systemui.shared.clocks.view import android.content.Context import android.graphics.Canvas import android.graphics.Point import android.view.MotionEvent import android.view.View import android.view.ViewGroup import android.widget.RelativeLayout Loading @@ -28,7 +27,6 @@ import com.android.systemui.customization.R import com.android.systemui.log.core.MessageBuffer import com.android.systemui.shared.clocks.AssetLoader import com.android.systemui.shared.clocks.DigitTranslateAnimator import com.android.systemui.shared.clocks.FontTextStyle import kotlin.math.abs import kotlin.math.max import kotlin.math.min Loading @@ -52,65 +50,6 @@ class FlexClockView(context: Context, val assets: AssetLoader, messageBuffer: Me ) } private var prevX = 0f private var prevY = 0f private var isDown = false private var wght = 603f private var wdth = 100f private val MAX_WGHT = 950f private val MIN_WGHT = 50f private val WGHT_SCALE = 0.5f private val MAX_WDTH = 150f private val MIN_WDTH = 0f private val WDTH_SCALE = 0.2f override fun onTouchEvent(evt: MotionEvent): Boolean { if (!isReactiveTouchInteractionEnabled) { return super.onTouchEvent(evt) } when (evt.action) { MotionEvent.ACTION_DOWN -> { isDown = true prevX = evt.x prevY = evt.y return true } MotionEvent.ACTION_MOVE -> { if (!isDown) { return super.onTouchEvent(evt) } wdth = clamp(wdth + (evt.x - prevX) * WDTH_SCALE, MIN_WDTH, MAX_WDTH) wght = clamp(wght + (evt.y - prevY) * WGHT_SCALE, MIN_WGHT, MAX_WGHT) prevX = evt.x prevY = evt.y val fvar = "'wght' $wght, 'wdth' $wdth, 'opsz' 144, 'ROND' 100" digitalClockTextViewMap.forEach { (_, view) -> val textStyle = view.textStyle as FontTextStyle textStyle.fontVariation = fvar view.applyStyles(assets, textStyle, view.aodStyle) } requestLayout() invalidate() return true } MotionEvent.ACTION_UP -> { isDown = false return true } } return super.onTouchEvent(evt) } override fun addView(child: View?) { super.addView(child) (child as SimpleDigitalClockTextView).digitTranslateAnimator = Loading