summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Hawkwood Glazier <jglazier@google.com> 2025-01-25 09:21:59 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2025-01-25 09:21:59 -0800
commitb0c0ea9b139387fa07c9ffa689b4683f2fbca897 (patch)
tree1188c509bea1b04995c871e74ab1784c77f829a9
parent585b77ac75b8804c577e351143400209e04f57e9 (diff)
parentb9f2a77b2ccb9d5e9a60cf6a30a9ee647b7b22a0 (diff)
Merge changes from topic "gsf_axis_tags" into main
* changes: Log Clock Visibility & Alpha changes in logbuffers Centralize GSF Axis Tags
-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/FlexClockView.kt40
-rw-r--r--packages/SystemUI/customization/src/com/android/systemui/shared/clocks/view/SimpleDigitalClockTextView.kt61
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/animation/FontVariationUtilsTest.kt22
7 files changed, 130 insertions, 47 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/FlexClockView.kt b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/view/FlexClockView.kt
index c40bb9a5ebea..3eb519186a3e 100644
--- a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/view/FlexClockView.kt
+++ b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/view/FlexClockView.kt
@@ -139,13 +139,49 @@ class FlexClockView(clockCtx: ClockContext) : FrameLayout(clockCtx.context) {
digitalClockTextViewMap.forEach { (_, textView) -> textView.refreshText() }
}
+ override fun setVisibility(visibility: Int) {
+ if (visibility != this.visibility) {
+ logger.d({ "setVisibility(${str1 ?: int1})" }) {
+ int1 = visibility
+ str1 =
+ when (visibility) {
+ VISIBLE -> "VISIBLE"
+ INVISIBLE -> "INVISIBLE"
+ GONE -> "GONE"
+ else -> null
+ }
+ }
+ }
+
+ super.setVisibility(visibility)
+ }
+
+ private var loggedAlpha = 1000f
+
+ override fun setAlpha(alpha: Float) {
+ val delta = if (alpha <= 0f || alpha >= 1f) 0.001f else 0.5f
+ if (abs(loggedAlpha - alpha) >= delta) {
+ loggedAlpha = alpha
+ logger.d({ "setAlpha($double1)" }) { double1 = alpha.toDouble() }
+ }
+ super.setAlpha(alpha)
+ }
+
+ private val isDrawn: Boolean
+ get() = (mPrivateFlags and 0x20 /* PFLAG_DRAWN */) > 0
+
override fun invalidate() {
- logger.d("invalidate()")
+ if (isDrawn && visibility == VISIBLE) {
+ logger.d("invalidate()")
+ }
+
super.invalidate()
}
override fun requestLayout() {
- logger.d("requestLayout()")
+ if (!isLayoutRequested()) {
+ logger.d("requestLayout()")
+ }
super.requestLayout()
}
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..fbd5887c5b54 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
@@ -44,6 +45,7 @@ import com.android.systemui.shared.clocks.DimensionParser
import com.android.systemui.shared.clocks.FontTextStyle
import com.android.systemui.shared.clocks.LogUtil
import java.lang.Thread
+import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
@@ -206,7 +208,10 @@ open class SimpleDigitalClockTextView(clockCtx: ClockContext, attrs: AttributeSe
}
override fun onDraw(canvas: Canvas) {
- logger.d({ "onDraw(); ls: $str1" }) { str1 = textAnimator.textInterpolator.shapedText }
+ logger.d({ "onDraw(${str1?.replace("\n", "\\n")})" }) {
+ str1 = textAnimator.textInterpolator.shapedText
+ }
+
val translation = getLocalTranslation()
canvas.translate(translation.x.toFloat(), translation.y.toFloat())
digitTranslateAnimator?.let {
@@ -221,8 +226,42 @@ open class SimpleDigitalClockTextView(clockCtx: ClockContext, attrs: AttributeSe
canvas.translate(-translation.x.toFloat(), -translation.y.toFloat())
}
+ override fun setVisibility(visibility: Int) {
+ if (visibility != this.visibility) {
+ logger.d({ "setVisibility(${str1 ?: int1})" }) {
+ int1 = visibility
+ str1 =
+ when (visibility) {
+ VISIBLE -> "VISIBLE"
+ INVISIBLE -> "INVISIBLE"
+ GONE -> "GONE"
+ else -> null
+ }
+ }
+ }
+
+ super.setVisibility(visibility)
+ }
+
+ private var loggedAlpha = 1000f
+
+ override fun setAlpha(alpha: Float) {
+ val delta = if (alpha <= 0f || alpha >= 1f) 0.001f else 0.5f
+ if (abs(loggedAlpha - alpha) >= delta) {
+ loggedAlpha = alpha
+ logger.d({ "setAlpha($double1)" }) { double1 = alpha.toDouble() }
+ }
+ super.setAlpha(alpha)
+ }
+
+ private val isDrawn: Boolean
+ get() = (mPrivateFlags and 0x20 /* PFLAG_DRAWN */) > 0
+
override fun invalidate() {
- logger.d("invalidate()")
+ if (isDrawn && visibility == VISIBLE) {
+ logger.d("invalidate()")
+ }
+
super.invalidate()
(parent as? FlexClockView)?.invalidate()
}
@@ -490,22 +529,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()