From 9ac8c9a74d37d49aadbea34c9cdd68c9bb246daf Mon Sep 17 00:00:00 2001 From: Jamie Garside Date: Tue, 13 Sep 2022 00:15:13 +0100 Subject: Add large screen clock motion - method 2. When the clock moves on a large screen (e.g. when locking/unlocking the device), this adds a subtle offset for each digit of the clock. This hooks a new transition in to the existing clock move transition, which just forwards progress through to the actual clock. This also adds a feature flag (210) to enable/disable this, since it needs a little more polish yet. As above, this needs more polish (tweaking the time and/or easing), but this at least gets something moving to start with :). Bug: 199051139 Test: Manually verified. Change-Id: Icec0bcfdb431d24b9405c5dfe8993016f687cac5 Merged-In: Icec0bcfdb431d24b9405c5dfe8993016f687cac5 --- .../com/android/systemui/animation/TextAnimator.kt | 5 + .../android/systemui/animation/TextInterpolator.kt | 6 +- .../systemui/plugins/ClockProviderPlugin.kt | 12 ++ .../res-keyguard/layout/keyguard_clock_switch.xml | 1 + .../systemui/shared/clocks/AnimatableClockView.kt | 175 ++++++++++++++++++++- .../shared/clocks/DefaultClockController.kt | 12 ++ .../keyguard/KeyguardClockSwitchController.java | 6 + .../keyguard/KeyguardStatusViewController.java | 6 + .../src/com/android/systemui/flags/Flags.java | 6 + .../shade/NotificationPanelViewController.java | 150 ++++++++++++++---- .../KeyguardClockSwitchControllerTest.java | 15 ++ .../keyguard/KeyguardStatusViewControllerTest.java | 16 ++ .../shared/clocks/AnimatableClockViewTest.kt | 5 +- 13 files changed, 376 insertions(+), 39 deletions(-) diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/TextAnimator.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/TextAnimator.kt index f79b328190dd..5f1bb83715c2 100644 --- a/packages/SystemUI/animation/src/com/android/systemui/animation/TextAnimator.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/animation/TextAnimator.kt @@ -88,6 +88,11 @@ class TextAnimator( */ var y: Float = 0f + /** + * The current line of text being drawn, in a multi-line TextView. + */ + var lineNo: Int = 0 + /** * Mutable text size of the glyph in pixels. */ diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/TextInterpolator.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/TextInterpolator.kt index d427a57f3b87..0448c818f765 100644 --- a/packages/SystemUI/animation/src/com/android/systemui/animation/TextInterpolator.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/animation/TextInterpolator.kt @@ -244,7 +244,7 @@ class TextInterpolator( canvas.translate(origin, layout.getLineBaseline(lineNo).toFloat()) run.fontRuns.forEach { fontRun -> - drawFontRun(canvas, run, fontRun, tmpPaint) + drawFontRun(canvas, run, fontRun, lineNo, tmpPaint) } } finally { canvas.restore() @@ -349,7 +349,7 @@ class TextInterpolator( var glyphFilter: GlyphCallback? = null // Draws single font run. - private fun drawFontRun(c: Canvas, line: Run, run: FontRun, paint: Paint) { + private fun drawFontRun(c: Canvas, line: Run, run: FontRun, lineNo: Int, paint: Paint) { var arrayIndex = 0 val font = fontInterpolator.lerp(run.baseFont, run.targetFont, progress) @@ -368,11 +368,13 @@ class TextInterpolator( tmpGlyph.font = font tmpGlyph.runStart = run.start tmpGlyph.runLength = run.end - run.start + tmpGlyph.lineNo = lineNo tmpPaintForGlyph.set(paint) var prevStart = run.start for (i in run.start until run.end) { + tmpGlyph.glyphIndex = i tmpGlyph.glyphId = line.glyphIds[i] tmpGlyph.x = MathUtils.lerp(line.baseX[i], line.targetX[i], progress) tmpGlyph.y = MathUtils.lerp(line.baseY[i], line.targetY[i], progress) diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/ClockProviderPlugin.kt b/packages/SystemUI/plugin/src/com/android/systemui/plugins/ClockProviderPlugin.kt index 1e74c3d68efc..dabb43b6074d 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/ClockProviderPlugin.kt +++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/ClockProviderPlugin.kt @@ -14,6 +14,7 @@ package com.android.systemui.plugins import android.content.res.Resources +import android.graphics.Rect import android.graphics.drawable.Drawable import android.view.View import com.android.systemui.plugins.annotations.ProvidesInterface @@ -114,6 +115,17 @@ interface ClockAnimations { /** Runs the battery animation (if any). */ fun charge() { } + + /** Move the clock, for example, if the notification tray appears in split-shade mode. */ + fun onPositionUpdated(fromRect: Rect, toRect: Rect, fraction: Float) { } + + /** + * Whether this clock has a custom position update animation. If true, the keyguard will call + * `onPositionUpdated` to notify the clock of a position update animation. If false, a default + * animation will be used (e.g. a simple translation). + */ + val hasCustomPositionUpdatedAnimation + get() = false } /** Events that have specific data about the related face */ diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml b/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml index 3ad7c8c4369c..d64587dcf362 100644 --- a/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml +++ b/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml @@ -37,6 +37,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="@dimen/keyguard_large_clock_top_margin" + android:clipChildren="false" android:visibility="gone" />