Loading packages/SystemUI/customization/src/com/android/systemui/shared/clocks/view/SimpleDigitalClockTextView.kt +19 −13 Original line number Diff line number Diff line Loading @@ -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), Loading Loading @@ -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() Loading Loading @@ -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() Loading Loading @@ -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 Loading Loading @@ -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 if (this::textAnimator.isInitialized) { prevTextBounds = textAnimator.textInterpolator.basePaint.getTextBounds(text) targetTextBounds = textAnimator.textInterpolator.targetPaint.getTextBounds(text) } else { prevTextBounds = textBounds targetTextBounds = textBounds } } /** Loading Loading
packages/SystemUI/customization/src/com/android/systemui/shared/clocks/view/SimpleDigitalClockTextView.kt +19 −13 Original line number Diff line number Diff line Loading @@ -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), Loading Loading @@ -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() Loading Loading @@ -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() Loading Loading @@ -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 Loading Loading @@ -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 if (this::textAnimator.isInitialized) { prevTextBounds = textAnimator.textInterpolator.basePaint.getTextBounds(text) targetTextBounds = textAnimator.textInterpolator.targetPaint.getTextBounds(text) } else { prevTextBounds = textBounds targetTextBounds = textBounds } } /** Loading