summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Hawkwood <jglazier@google.com> 2025-03-21 17:18:36 +0000
committer Hawkwood <jglazier@google.com> 2025-03-21 17:32:00 +0000
commitd128dd02bec2240557247e6ba3ce0a9f060dbf3f (patch)
tree27738e56bb6c4a6703c0dd65f98a0db8dec35174
parent08e4029e106a8338f1504c04eb6d057df272034e (diff)
Ensure animator text bounds are up to date when lockscreen text bounds change
Bug: 404796728 Bug: 405171052 Test: Manually checked several edge cases Flag: com.android.systemui.shared.clock_reactive_variants Change-Id: Ic6e0d3dd90dcffe5736e0a5a1d16850ba0c46cbe
-rw-r--r--packages/SystemUI/customization/src/com/android/systemui/shared/clocks/view/SimpleDigitalClockTextView.kt32
1 files changed, 19 insertions, 13 deletions
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 05c9818f0c57..655b79c5b635 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
@@ -209,8 +209,7 @@ open class SimpleDigitalClockTextView(
lockScreenPaint.typeface = typefaceCache.getTypefaceForVariant(lsFontVariation)
typeface = lockScreenPaint.typeface
- textBounds = lockScreenPaint.getTextBounds(text)
- targetTextBounds = textBounds
+ updateTextBounds()
textAnimator.setTextStyle(
TextAnimator.Style(fVar = lsFontVariation),
@@ -253,9 +252,9 @@ open class SimpleDigitalClockTextView(
object : TextAnimatorListener {
override fun onInvalidate() = invalidate()
- override fun onRebased() = updateTextBounds()
+ override fun onRebased() = updateAnimationTextBounds()
- override fun onPaintModified() = updateTextBounds()
+ override fun onPaintModified() = updateAnimationTextBounds()
},
)
setInterpolatorPaint()
@@ -414,10 +413,7 @@ open class SimpleDigitalClockTextView(
}
fun refreshText() {
- textBounds = lockScreenPaint.getTextBounds(text)
- targetTextBounds =
- if (!this::textAnimator.isInitialized) textBounds
- else textAnimator.textInterpolator.targetPaint.getTextBounds(text)
+ updateTextBounds()
if (layout == null) {
requestLayout()
@@ -579,8 +575,7 @@ open class SimpleDigitalClockTextView(
if (fontSizePx > 0) {
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSizePx)
lockScreenPaint.textSize = textSize
- textBounds = lockScreenPaint.getTextBounds(text)
- targetTextBounds = textBounds
+ updateTextBounds()
}
if (!constrainedByHeight) {
val lastUnconstrainedHeight = textBounds.height + lockScreenPaint.strokeWidth * 2
@@ -624,15 +619,26 @@ open class SimpleDigitalClockTextView(
}
}
+ /** Updates both the lockscreen text bounds and animation text bounds */
+ private fun updateTextBounds() {
+ textBounds = lockScreenPaint.getTextBounds(text)
+ updateAnimationTextBounds()
+ }
+
/**
* Called after textAnimator.setTextStyle textAnimator.setTextStyle will update targetPaint, and
* rebase if previous animator is canceled so basePaint will store the state we transition from
* and targetPaint will store the state we transition to
*/
- private fun updateTextBounds() {
+ private fun updateAnimationTextBounds() {
drawnProgress = null
- prevTextBounds = textAnimator.textInterpolator.basePaint.getTextBounds(text)
- targetTextBounds = textAnimator.textInterpolator.targetPaint.getTextBounds(text)
+ if (this::textAnimator.isInitialized) {
+ prevTextBounds = textAnimator.textInterpolator.basePaint.getTextBounds(text)
+ targetTextBounds = textAnimator.textInterpolator.targetPaint.getTextBounds(text)
+ } else {
+ prevTextBounds = textBounds
+ targetTextBounds = textBounds
+ }
}
/**