summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/animation/src/com/android/systemui/animation/FontVariationUtils.kt25
-rw-r--r--packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockProvider.kt17
-rw-r--r--packages/SystemUI/customization/src/com/android/systemui/shared/clocks/FlexClockController.kt9
-rw-r--r--packages/SystemUI/customization/src/com/android/systemui/shared/clocks/FlexClockFaceController.kt3
-rw-r--r--packages/SystemUI/customization/src/com/android/systemui/shared/clocks/view/SimpleDigitalClockTextView.kt19
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/animation/FontVariationUtilsTest.kt22
6 files changed, 52 insertions, 43 deletions
diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/FontVariationUtils.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/FontVariationUtils.kt
index 78ae4af258fc..9545bda80b2d 100644
--- a/packages/SystemUI/animation/src/com/android/systemui/animation/FontVariationUtils.kt
+++ b/packages/SystemUI/animation/src/com/android/systemui/animation/FontVariationUtils.kt
@@ -1,9 +1,12 @@
package com.android.systemui.animation
-private const val TAG_WGHT = "wght"
-private const val TAG_WDTH = "wdth"
-private const val TAG_OPSZ = "opsz"
-private const val TAG_ROND = "ROND"
+object GSFAxes {
+ const val WEIGHT = "wght"
+ const val WIDTH = "wdth"
+ const val SLANT = "slnt"
+ const val ROUND = "ROND"
+ const val OPTICAL_SIZE = "opsz"
+}
class FontVariationUtils {
private var mWeight = -1
@@ -21,7 +24,7 @@ class FontVariationUtils {
weight: Int = -1,
width: Int = -1,
opticalSize: Int = -1,
- roundness: Int = -1
+ roundness: Int = -1,
): String {
isUpdated = false
if (weight >= 0 && mWeight != weight) {
@@ -43,16 +46,20 @@ class FontVariationUtils {
}
var resultString = ""
if (mWeight >= 0) {
- resultString += "'$TAG_WGHT' $mWeight"
+ resultString += "'${GSFAxes.WEIGHT}' $mWeight"
}
if (mWidth >= 0) {
- resultString += (if (resultString.isBlank()) "" else ", ") + "'$TAG_WDTH' $mWidth"
+ resultString +=
+ (if (resultString.isBlank()) "" else ", ") + "'${GSFAxes.WIDTH}' $mWidth"
}
if (mOpticalSize >= 0) {
- resultString += (if (resultString.isBlank()) "" else ", ") + "'$TAG_OPSZ' $mOpticalSize"
+ resultString +=
+ (if (resultString.isBlank()) "" else ", ") +
+ "'${GSFAxes.OPTICAL_SIZE}' $mOpticalSize"
}
if (mRoundness >= 0) {
- resultString += (if (resultString.isBlank()) "" else ", ") + "'$TAG_ROND' $mRoundness"
+ resultString +=
+ (if (resultString.isBlank()) "" else ", ") + "'${GSFAxes.ROUND}' $mRoundness"
}
return if (isUpdated) resultString else ""
}
diff --git a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockProvider.kt b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockProvider.kt
index f6ff3268fca4..36029177d4f6 100644
--- a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockProvider.kt
+++ b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockProvider.kt
@@ -17,6 +17,7 @@ import android.content.Context
import android.content.res.Resources
import android.graphics.Typeface
import android.view.LayoutInflater
+import com.android.systemui.animation.GSFAxes
import com.android.systemui.customization.R
import com.android.systemui.log.core.MessageBuffer
import com.android.systemui.plugins.clocks.ClockController
@@ -107,18 +108,18 @@ class DefaultClockProvider(
// 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),
+ ClockFontAxisSetting(GSFAxes.WEIGHT, 600f),
+ ClockFontAxisSetting(GSFAxes.WIDTH, 100f),
+ ClockFontAxisSetting(GSFAxes.ROUND, 100f),
+ ClockFontAxisSetting(GSFAxes.SLANT, 0f),
)
val LEGACY_FLEX_AOD_VARIATION =
listOf(
- ClockFontAxisSetting("wght", 74f),
- ClockFontAxisSetting("wdth", 43f),
- ClockFontAxisSetting("ROND", 100f),
- ClockFontAxisSetting("slnt", 0f),
+ ClockFontAxisSetting(GSFAxes.WEIGHT, 74f),
+ ClockFontAxisSetting(GSFAxes.WIDTH, 43f),
+ ClockFontAxisSetting(GSFAxes.ROUND, 100f),
+ ClockFontAxisSetting(GSFAxes.SLANT, 0f),
)
val FLEX_TYPEFACE by lazy {
diff --git a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/FlexClockController.kt b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/FlexClockController.kt
index b2bc9ef4e363..cc3769e0a568 100644
--- a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/FlexClockController.kt
+++ b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/FlexClockController.kt
@@ -16,6 +16,7 @@
package com.android.systemui.shared.clocks
+import com.android.systemui.animation.GSFAxes
import com.android.systemui.customization.R
import com.android.systemui.plugins.clocks.AlarmData
import com.android.systemui.plugins.clocks.AxisType
@@ -122,7 +123,7 @@ class FlexClockController(private val clockCtx: ClockContext) : ClockController
val FONT_AXES =
listOf(
ClockFontAxis(
- key = "wght",
+ key = GSFAxes.WEIGHT,
type = AxisType.Float,
minValue = 25f,
currentValue = 400f,
@@ -131,7 +132,7 @@ class FlexClockController(private val clockCtx: ClockContext) : ClockController
description = "Glyph Weight",
),
ClockFontAxis(
- key = "wdth",
+ key = GSFAxes.WIDTH,
type = AxisType.Float,
minValue = 25f,
currentValue = 100f,
@@ -140,7 +141,7 @@ class FlexClockController(private val clockCtx: ClockContext) : ClockController
description = "Glyph Width",
),
ClockFontAxis(
- key = "ROND",
+ key = GSFAxes.ROUND,
type = AxisType.Boolean,
minValue = 0f,
currentValue = 0f,
@@ -149,7 +150,7 @@ class FlexClockController(private val clockCtx: ClockContext) : ClockController
description = "Glyph Roundness",
),
ClockFontAxis(
- key = "slnt",
+ key = GSFAxes.SLANT,
type = AxisType.Boolean,
minValue = 0f,
currentValue = 0f,
diff --git a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/FlexClockFaceController.kt b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/FlexClockFaceController.kt
index 67cbf3082632..e2bbe0fef3c0 100644
--- a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/FlexClockFaceController.kt
+++ b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/FlexClockFaceController.kt
@@ -21,6 +21,7 @@ import android.view.Gravity
import android.view.View
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import android.widget.FrameLayout
+import com.android.systemui.animation.GSFAxes
import com.android.systemui.customization.R
import com.android.systemui.plugins.clocks.AlarmData
import com.android.systemui.plugins.clocks.ClockAnimations
@@ -130,7 +131,7 @@ class FlexClockFaceController(clockCtx: ClockContext, private val isLargeClock:
if (!isLargeClock) {
axes =
axes.map { axis ->
- if (axis.key == "wdth" && axis.value > SMALL_CLOCK_MAX_WDTH) {
+ if (axis.key == GSFAxes.WIDTH && axis.value > SMALL_CLOCK_MAX_WDTH) {
axis.copy(value = SMALL_CLOCK_MAX_WDTH)
} else {
axis
diff --git a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/view/SimpleDigitalClockTextView.kt b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/view/SimpleDigitalClockTextView.kt
index 2b0825f39243..8e66c7221aaa 100644
--- a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/view/SimpleDigitalClockTextView.kt
+++ b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/view/SimpleDigitalClockTextView.kt
@@ -34,6 +34,7 @@ import android.view.View.MeasureSpec.EXACTLY
import android.view.animation.Interpolator
import android.widget.TextView
import com.android.internal.annotations.VisibleForTesting
+import com.android.systemui.animation.GSFAxes
import com.android.systemui.animation.TextAnimator
import com.android.systemui.customization.R
import com.android.systemui.log.core.Logger
@@ -490,22 +491,22 @@ open class SimpleDigitalClockTextView(clockCtx: ClockContext, attrs: AttributeSe
Paint().also { it.xfermode = PorterDuffXfermode(PorterDuff.Mode.DST_OUT) }
val AOD_COLOR = Color.WHITE
- val OPTICAL_SIZE_AXIS = ClockFontAxisSetting("opsz", 144f)
+ val OPTICAL_SIZE_AXIS = ClockFontAxisSetting(GSFAxes.OPTICAL_SIZE, 144f)
val DEFAULT_LS_VARIATION =
listOf(
OPTICAL_SIZE_AXIS,
- ClockFontAxisSetting("wght", 400f),
- ClockFontAxisSetting("wdth", 100f),
- ClockFontAxisSetting("ROND", 0f),
- ClockFontAxisSetting("slnt", 0f),
+ ClockFontAxisSetting(GSFAxes.WEIGHT, 400f),
+ ClockFontAxisSetting(GSFAxes.WIDTH, 100f),
+ ClockFontAxisSetting(GSFAxes.ROUND, 0f),
+ ClockFontAxisSetting(GSFAxes.SLANT, 0f),
)
val DEFAULT_AOD_VARIATION =
listOf(
OPTICAL_SIZE_AXIS,
- ClockFontAxisSetting("wght", 200f),
- ClockFontAxisSetting("wdth", 100f),
- ClockFontAxisSetting("ROND", 0f),
- ClockFontAxisSetting("slnt", 0f),
+ ClockFontAxisSetting(GSFAxes.WEIGHT, 200f),
+ ClockFontAxisSetting(GSFAxes.WIDTH, 100f),
+ ClockFontAxisSetting(GSFAxes.ROUND, 0f),
+ ClockFontAxisSetting(GSFAxes.SLANT, 0f),
)
}
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/animation/FontVariationUtilsTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/animation/FontVariationUtilsTest.kt
index b0f81c012cca..f44769d522eb 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/animation/FontVariationUtilsTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/animation/FontVariationUtilsTest.kt
@@ -7,11 +7,6 @@ import junit.framework.Assert
import org.junit.Test
import org.junit.runner.RunWith
-private const val TAG_WGHT = "wght"
-private const val TAG_WDTH = "wdth"
-private const val TAG_OPSZ = "opsz"
-private const val TAG_ROND = "ROND"
-
@RunWith(AndroidJUnit4::class)
@SmallTest
class FontVariationUtilsTest : SysuiTestCase() {
@@ -23,19 +18,22 @@ class FontVariationUtilsTest : SysuiTestCase() {
weight = 100,
width = 100,
opticalSize = -1,
- roundness = 100
+ roundness = 100,
)
- Assert.assertEquals("'$TAG_WGHT' 100, '$TAG_WDTH' 100, '$TAG_ROND' 100", initFvar)
+ Assert.assertEquals(
+ "'${GSFAxes.WEIGHT}' 100, '${GSFAxes.WIDTH}' 100, '${GSFAxes.ROUND}' 100",
+ initFvar,
+ )
val updatedFvar =
fontVariationUtils.updateFontVariation(
weight = 200,
width = 100,
opticalSize = 0,
- roundness = 100
+ roundness = 100,
)
Assert.assertEquals(
- "'$TAG_WGHT' 200, '$TAG_WDTH' 100, '$TAG_OPSZ' 0, '$TAG_ROND' 100",
- updatedFvar
+ "'${GSFAxes.WEIGHT}' 200, '${GSFAxes.WIDTH}' 100, '${GSFAxes.OPTICAL_SIZE}' 0, '${GSFAxes.ROUND}' 100",
+ updatedFvar,
)
}
@@ -46,14 +44,14 @@ class FontVariationUtilsTest : SysuiTestCase() {
weight = 100,
width = 100,
opticalSize = 0,
- roundness = 100
+ roundness = 100,
)
val updatedFvar1 =
fontVariationUtils.updateFontVariation(
weight = 100,
width = 100,
opticalSize = 0,
- roundness = 100
+ roundness = 100,
)
Assert.assertEquals("", updatedFvar1)
val updatedFvar2 = fontVariationUtils.updateFontVariation()