diff options
10 files changed, 49 insertions, 36 deletions
diff --git a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/ComposedDigitalLayerController.kt b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/ComposedDigitalLayerController.kt index 5f71b19fbc3f..884666854ab4 100644 --- a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/ComposedDigitalLayerController.kt +++ b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/ComposedDigitalLayerController.kt @@ -111,10 +111,6 @@ class ComposedDigitalLayerController(private val clockCtx: ClockContext) : override fun onZenDataChanged(data: ZenData) {} - override fun onFontAxesChanged(axes: ClockAxisStyle) { - view.updateAxes(axes) - } - override var isReactiveTouchInteractionEnabled get() = view.isReactiveTouchInteractionEnabled set(value) { @@ -152,6 +148,13 @@ class ComposedDigitalLayerController(private val clockCtx: ClockContext) : override fun onFidgetTap(x: Float, y: Float) { view.animateFidget(x, y) } + + private var hasFontAxes = false + + override fun onFontAxesChanged(style: ClockAxisStyle) { + view.updateAxes(style, isAnimated = hasFontAxes) + hasFontAxes = true + } } override val faceEvents = diff --git a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockController.kt b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockController.kt index 3cfa78d17fe7..450cece8709a 100644 --- a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockController.kt +++ b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockController.kt @@ -231,8 +231,6 @@ class DefaultClockController( override fun onAlarmDataChanged(data: AlarmData) {} override fun onZenDataChanged(data: ZenData) {} - - override fun onFontAxesChanged(axes: ClockAxisStyle) {} } open inner class DefaultClockAnimations( @@ -285,6 +283,8 @@ class DefaultClockController( override fun onPositionUpdated(distance: Float, fraction: Float) {} override fun onFidgetTap(x: Float, y: Float) {} + + override fun onFontAxesChanged(style: ClockAxisStyle) {} } inner class LargeClockAnimations( 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 8744357a74c9..84f45fcc0532 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 @@ -99,12 +99,6 @@ class FlexClockController(private val clockCtx: ClockContext) : ClockController smallClock.events.onZenDataChanged(data) largeClock.events.onZenDataChanged(data) } - - override fun onFontAxesChanged(axes: ClockAxisStyle) { - val fontAxes = ClockAxisStyle(getDefaultAxes(clockCtx.settings).merge(axes)) - smallClock.events.onFontAxesChanged(fontAxes) - largeClock.events.onFontAxesChanged(fontAxes) - } } override fun initialize( @@ -113,10 +107,10 @@ class FlexClockController(private val clockCtx: ClockContext) : ClockController foldFraction: Float, clockListener: ClockEventListener?, ) { - events.onFontAxesChanged(clockCtx.settings.axes) smallClock.run { layerController.onViewBoundsChanged = { clockListener?.onBoundsChanged(it) } events.onThemeChanged(theme.copy(isDarkTheme = isDarkTheme)) + animations.onFontAxesChanged(clockCtx.settings.axes) animations.doze(dozeFraction) animations.fold(foldFraction) events.onTimeTick() @@ -125,6 +119,7 @@ class FlexClockController(private val clockCtx: ClockContext) : ClockController largeClock.run { layerController.onViewBoundsChanged = { clockListener?.onBoundsChanged(it) } events.onThemeChanged(theme.copy(isDarkTheme = isDarkTheme)) + animations.onFontAxesChanged(clockCtx.settings.axes) animations.doze(dozeFraction) animations.fold(foldFraction) events.onTimeTick() 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 171a68f72e20..ec7803d0c6d6 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 @@ -31,10 +31,12 @@ import com.android.systemui.plugins.clocks.ClockFaceConfig import com.android.systemui.plugins.clocks.ClockFaceController import com.android.systemui.plugins.clocks.ClockFaceEvents import com.android.systemui.plugins.clocks.ClockFaceLayout +import com.android.systemui.plugins.clocks.ClockFontAxis.Companion.merge import com.android.systemui.plugins.clocks.DefaultClockFaceLayout import com.android.systemui.plugins.clocks.ThemeConfig import com.android.systemui.plugins.clocks.WeatherData import com.android.systemui.plugins.clocks.ZenData +import com.android.systemui.shared.clocks.FlexClockController.Companion.getDefaultAxes import com.android.systemui.shared.clocks.FontUtils.get import com.android.systemui.shared.clocks.FontUtils.set import com.android.systemui.shared.clocks.ViewUtils.computeLayoutDiff @@ -131,15 +133,6 @@ class FlexClockFaceController(clockCtx: ClockContext, private val isLargeClock: layerController.faceEvents.onThemeChanged(theme) } - override fun onFontAxesChanged(settings: ClockAxisStyle) { - var axes = ClockAxisStyle(settings) - if (!isLargeClock && axes[GSFAxes.WIDTH] > SMALL_CLOCK_MAX_WDTH) { - axes[GSFAxes.WIDTH] = SMALL_CLOCK_MAX_WDTH - } - - layerController.events.onFontAxesChanged(axes) - } - /** * targetRegion passed to all customized clock applies counter translationY of Keyguard and * keyguard_large_clock_top_margin from default clock @@ -232,6 +225,15 @@ class FlexClockFaceController(clockCtx: ClockContext, private val isLargeClock: override fun onFidgetTap(x: Float, y: Float) { layerController.animations.onFidgetTap(x, y) } + + override fun onFontAxesChanged(style: ClockAxisStyle) { + var axes = ClockAxisStyle(getDefaultAxes(clockCtx.settings).merge(style)) + if (!isLargeClock && axes[GSFAxes.WIDTH] > SMALL_CLOCK_MAX_WDTH) { + axes[GSFAxes.WIDTH] = SMALL_CLOCK_MAX_WDTH + } + + layerController.animations.onFontAxesChanged(axes) + } } companion object { diff --git a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/SimpleDigitalHandLayerController.kt b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/SimpleDigitalHandLayerController.kt index 7be9a936cbd3..eef910c3bd27 100644 --- a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/SimpleDigitalHandLayerController.kt +++ b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/SimpleDigitalHandLayerController.kt @@ -171,10 +171,6 @@ open class SimpleDigitalHandLayerController( override fun onAlarmDataChanged(data: AlarmData) {} override fun onZenDataChanged(data: ZenData) {} - - override fun onFontAxesChanged(axes: ClockAxisStyle) { - view.updateAxes(axes) - } } override val animations = @@ -195,6 +191,13 @@ open class SimpleDigitalHandLayerController( view.dozeFraction = fraction } + private var hasFontAxes = false + + override fun onFontAxesChanged(style: ClockAxisStyle) { + view.updateAxes(style, isAnimated = hasFontAxes) + hasFontAxes = true + } + override fun fold(fraction: Float) { applyLayout() refreshTime() 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 4531aed0e83d..4a5532b6e462 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 @@ -272,8 +272,8 @@ class FlexClockView(clockCtx: ClockContext) : ViewGroup(clockCtx.context) { invalidate() } - fun updateAxes(axes: ClockAxisStyle) { - childViews.forEach { view -> view.updateAxes(axes) } + fun updateAxes(axes: ClockAxisStyle, isAnimated: Boolean) { + childViews.forEach { view -> view.updateAxes(axes, isAnimated) } 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 377a24c2899b..05c9818f0c57 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 @@ -200,11 +200,11 @@ open class SimpleDigitalClockTextView( invalidate() } - fun updateAxes(lsAxes: ClockAxisStyle) { + fun updateAxes(lsAxes: ClockAxisStyle, isAnimated: Boolean) { lsFontVariation = lsAxes.toFVar() aodFontVariation = lsAxes.copyWith(fixedAodAxes).toFVar() fidgetFontVariation = buildFidgetVariation(lsAxes).toFVar() - logger.updateAxes(lsFontVariation, aodFontVariation) + logger.updateAxes(lsFontVariation, aodFontVariation, isAnimated) lockScreenPaint.typeface = typefaceCache.getTypefaceForVariant(lsFontVariation) typeface = lockScreenPaint.typeface @@ -212,7 +212,15 @@ open class SimpleDigitalClockTextView( textBounds = lockScreenPaint.getTextBounds(text) targetTextBounds = textBounds - textAnimator.setTextStyle(TextAnimator.Style(fVar = lsFontVariation)) + textAnimator.setTextStyle( + TextAnimator.Style(fVar = lsFontVariation), + TextAnimator.Animation( + animate = isAnimated && isAnimationEnabled, + duration = AXIS_CHANGE_ANIMATION_DURATION, + interpolator = aodDozingInterpolator, + ), + ) + measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED) recomputeMaxSingleDigitSizes() requestLayout() @@ -651,6 +659,7 @@ open class SimpleDigitalClockTextView( .compose() val CHARGE_ANIMATION_DURATION = 500L + val AXIS_CHANGE_ANIMATION_DURATION = 400L val FIDGET_ANIMATION_DURATION = 250L val FIDGET_INTERPOLATOR = PathInterpolator(0.26873f, 0f, 0.45042f, 1f) val FIDGET_DISTS = diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockAnimations.kt b/packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockAnimations.kt index 77c18eac289c..894327690b5e 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockAnimations.kt +++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockAnimations.kt @@ -61,4 +61,7 @@ interface ClockAnimations { /** Runs when an animation when the view is tapped on the lockscreen */ fun onFidgetTap(x: Float, y: Float) + + /** Update reactive axes for this clock */ + fun onFontAxesChanged(style: ClockAxisStyle) } diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockEvents.kt b/packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockEvents.kt index 0fc3470716fe..7c0e4866b00d 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockEvents.kt +++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockEvents.kt @@ -42,7 +42,4 @@ interface ClockEvents { /** Call with zen/dnd information */ fun onZenDataChanged(data: ZenData) - - /** Update reactive axes for this clock */ - fun onFontAxesChanged(axes: ClockAxisStyle) } diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockLogger.kt b/packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockLogger.kt index 5b67edda73cc..4f04aaa33b24 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockLogger.kt +++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockLogger.kt @@ -90,10 +90,11 @@ class ClockLogger(private val view: View?, buffer: MessageBuffer, tag: String) : } } - fun updateAxes(lsFVar: String, aodFVar: String) { - i({ "updateAxes(LS = $str1, AOD = $str2)" }) { + fun updateAxes(lsFVar: String, aodFVar: String, isAnimated: Boolean) { + i({ "updateAxes(LS = $str1, AOD = $str2, isAnimated=$bool1)" }) { str1 = lsFVar str2 = aodFVar + bool1 = isAnimated } } |