Loading packages/SystemUI/customization/src/com/android/systemui/shared/clocks/view/FlexClockView.kt +18 −6 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import com.android.systemui.shared.clocks.CanvasUtil.translate import com.android.systemui.shared.clocks.CanvasUtil.use import com.android.systemui.shared.clocks.ClockContext import com.android.systemui.shared.clocks.DigitTranslateAnimator import com.android.systemui.shared.clocks.VPoint import com.android.systemui.shared.clocks.VPointF import com.android.systemui.shared.clocks.VPointF.Companion.max import com.android.systemui.shared.clocks.VPointF.Companion.times Loading Loading @@ -109,13 +110,11 @@ class FlexClockView(clockCtx: ClockContext) : ViewGroup(clockCtx.context) { shouldMeasureChildren: Boolean, ): VPointF { maxChildSize = VPointF(-1, -1) fun SimpleDigitalClockTextView.getSize() = VPointF(measuredWidth, measuredHeight) childViews.forEach { textView -> if (shouldMeasureChildren) { textView.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED) } maxChildSize = max(maxChildSize, textView.getSize()) maxChildSize = max(maxChildSize, textView.measuredSize) } aodTranslate = VPointF.ZERO // TODO(b/364680879): Cleanup Loading Loading @@ -180,8 +179,8 @@ class FlexClockView(clockCtx: ClockContext) : ViewGroup(clockCtx.context) { ) private fun updateMeasuredSize( widthMeasureSpec: Int = measuredWidthAndState, heightMeasureSpec: Int = measuredHeightAndState, widthMeasureSpec: Int, heightMeasureSpec: Int, shouldMeasureChildren: Boolean, ) { val size = calculateSize(widthMeasureSpec, heightMeasureSpec, shouldMeasureChildren) Loading Loading @@ -357,7 +356,18 @@ class FlexClockView(clockCtx: ClockContext) : ViewGroup(clockCtx.context) { } fun animateFidget(x: Float, y: Float) { childViews.forEach { view -> view.animateFidget(x, y) } val touchPt = VPointF(x, y) val ints = intArrayOf(0, 0) childViews .sortedBy { view -> view.getLocationInWindow(ints) val loc = VPoint(ints[0], ints[1]) val center = loc + view.measuredSize / 2f (center - touchPt).length() } .forEachIndexed { i, view -> view.animateFidget(FIDGET_DELAYS[min(i, FIDGET_DELAYS.size - 1)]) } } private fun updateLocale(locale: Locale) { Loading Loading @@ -441,6 +451,8 @@ class FlexClockView(clockCtx: ClockContext) : ViewGroup(clockCtx.context) { val AOD_HORIZONTAL_TRANSLATE_RATIO = -0.15F val AOD_VERTICAL_TRANSLATE_RATIO = 0.075F val FIDGET_DELAYS = listOf(0L, 75L, 150L, 225L) // Delays. Each digit's animation should have a slight delay, so we get a nice // "stepping" effect. When moving right, the second digit of the hour should move first. // When moving left, the first digit of the hour should move first. The lists encode Loading packages/SystemUI/customization/src/com/android/systemui/shared/clocks/view/SimpleDigitalClockTextView.kt +8 −4 Original line number Diff line number Diff line Loading @@ -372,7 +372,9 @@ open class SimpleDigitalClockTextView( updateTextBoundsForTextAnimator() } fun animateFidget(x: Float, y: Float) { fun animateFidget(x: Float, y: Float) = animateFidget(0L) fun animateFidget(delay: Long) { if (!this::textAnimator.isInitialized || textAnimator.isRunning) { // Skip fidget animation if other animation is already playing. return Loading @@ -381,13 +383,13 @@ open class SimpleDigitalClockTextView( logger.animateFidget(x, y) clockCtx.vibrator?.vibrate(FIDGET_HAPTICS) // TODO(b/374306512): Delay each glyph's animation based on x/y position textAnimator.setTextStyle( TextAnimator.Style(fVar = fidgetFontVariation), TextAnimator.Animation( animate = isAnimationEnabled, duration = FIDGET_ANIMATION_DURATION, interpolator = FIDGET_INTERPOLATOR, startDelay = delay, onAnimationEnd = { textAnimator.setTextStyle( TextAnimator.Style(fVar = lsFontVariation), Loading Loading @@ -430,8 +432,10 @@ open class SimpleDigitalClockTextView( /** Returns the interpolated text bounding rect based on interpolation progress */ private fun getInterpolatedTextBounds(progress: Float = getInterpolatedProgress()): RectF { if (!textAnimator.isRunning || progress >= 1f) { return RectF(targetTextBounds) if (progress <= 0f) { return prevTextBounds } else if (!textAnimator.isRunning || progress >= 1f) { return targetTextBounds } return RectF().apply { Loading Loading
packages/SystemUI/customization/src/com/android/systemui/shared/clocks/view/FlexClockView.kt +18 −6 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import com.android.systemui.shared.clocks.CanvasUtil.translate import com.android.systemui.shared.clocks.CanvasUtil.use import com.android.systemui.shared.clocks.ClockContext import com.android.systemui.shared.clocks.DigitTranslateAnimator import com.android.systemui.shared.clocks.VPoint import com.android.systemui.shared.clocks.VPointF import com.android.systemui.shared.clocks.VPointF.Companion.max import com.android.systemui.shared.clocks.VPointF.Companion.times Loading Loading @@ -109,13 +110,11 @@ class FlexClockView(clockCtx: ClockContext) : ViewGroup(clockCtx.context) { shouldMeasureChildren: Boolean, ): VPointF { maxChildSize = VPointF(-1, -1) fun SimpleDigitalClockTextView.getSize() = VPointF(measuredWidth, measuredHeight) childViews.forEach { textView -> if (shouldMeasureChildren) { textView.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED) } maxChildSize = max(maxChildSize, textView.getSize()) maxChildSize = max(maxChildSize, textView.measuredSize) } aodTranslate = VPointF.ZERO // TODO(b/364680879): Cleanup Loading Loading @@ -180,8 +179,8 @@ class FlexClockView(clockCtx: ClockContext) : ViewGroup(clockCtx.context) { ) private fun updateMeasuredSize( widthMeasureSpec: Int = measuredWidthAndState, heightMeasureSpec: Int = measuredHeightAndState, widthMeasureSpec: Int, heightMeasureSpec: Int, shouldMeasureChildren: Boolean, ) { val size = calculateSize(widthMeasureSpec, heightMeasureSpec, shouldMeasureChildren) Loading Loading @@ -357,7 +356,18 @@ class FlexClockView(clockCtx: ClockContext) : ViewGroup(clockCtx.context) { } fun animateFidget(x: Float, y: Float) { childViews.forEach { view -> view.animateFidget(x, y) } val touchPt = VPointF(x, y) val ints = intArrayOf(0, 0) childViews .sortedBy { view -> view.getLocationInWindow(ints) val loc = VPoint(ints[0], ints[1]) val center = loc + view.measuredSize / 2f (center - touchPt).length() } .forEachIndexed { i, view -> view.animateFidget(FIDGET_DELAYS[min(i, FIDGET_DELAYS.size - 1)]) } } private fun updateLocale(locale: Locale) { Loading Loading @@ -441,6 +451,8 @@ class FlexClockView(clockCtx: ClockContext) : ViewGroup(clockCtx.context) { val AOD_HORIZONTAL_TRANSLATE_RATIO = -0.15F val AOD_VERTICAL_TRANSLATE_RATIO = 0.075F val FIDGET_DELAYS = listOf(0L, 75L, 150L, 225L) // Delays. Each digit's animation should have a slight delay, so we get a nice // "stepping" effect. When moving right, the second digit of the hour should move first. // When moving left, the first digit of the hour should move first. The lists encode Loading
packages/SystemUI/customization/src/com/android/systemui/shared/clocks/view/SimpleDigitalClockTextView.kt +8 −4 Original line number Diff line number Diff line Loading @@ -372,7 +372,9 @@ open class SimpleDigitalClockTextView( updateTextBoundsForTextAnimator() } fun animateFidget(x: Float, y: Float) { fun animateFidget(x: Float, y: Float) = animateFidget(0L) fun animateFidget(delay: Long) { if (!this::textAnimator.isInitialized || textAnimator.isRunning) { // Skip fidget animation if other animation is already playing. return Loading @@ -381,13 +383,13 @@ open class SimpleDigitalClockTextView( logger.animateFidget(x, y) clockCtx.vibrator?.vibrate(FIDGET_HAPTICS) // TODO(b/374306512): Delay each glyph's animation based on x/y position textAnimator.setTextStyle( TextAnimator.Style(fVar = fidgetFontVariation), TextAnimator.Animation( animate = isAnimationEnabled, duration = FIDGET_ANIMATION_DURATION, interpolator = FIDGET_INTERPOLATOR, startDelay = delay, onAnimationEnd = { textAnimator.setTextStyle( TextAnimator.Style(fVar = lsFontVariation), Loading Loading @@ -430,8 +432,10 @@ open class SimpleDigitalClockTextView( /** Returns the interpolated text bounding rect based on interpolation progress */ private fun getInterpolatedTextBounds(progress: Float = getInterpolatedProgress()): RectF { if (!textAnimator.isRunning || progress >= 1f) { return RectF(targetTextBounds) if (progress <= 0f) { return prevTextBounds } else if (!textAnimator.isRunning || progress >= 1f) { return targetTextBounds } return RectF().apply { Loading