From 0681a81f4eb9d6a6f88788f1a615775b2c7d4d49 Mon Sep 17 00:00:00 2001 From: Lucas Silva Date: Tue, 29 Mar 2022 13:16:26 -0400 Subject: [PATCH] Implement dream complication motion/fade when transitionting to bouncer. The top complications will move first, and then the bottom complications. Test: locally on device Test: atest ComplicationLayoutEngineTest Bug: 220307939 Change-Id: I0d88caa2c2eb3eb03294379a9356e7ffd8856c30 --- packages/SystemUI/res/values/dimens.xml | 2 + .../BouncerPanelExpansionCalculator.kt | 20 ++++++ .../DreamOverlayContainerViewController.java | 56 +++++++++++---- .../ComplicationHostViewController.java | 8 +++ .../ComplicationLayoutEngine.java | 26 +++++++ ...eamOverlayContainerViewControllerTest.java | 5 +- .../ComplicationLayoutEngineTest.java | 69 +++++++++++++++++++ 7 files changed, 171 insertions(+), 15 deletions(-) diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 7702724cec16e..851c6ddc2f862 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -1429,6 +1429,8 @@ 0dp + 80dp + 0dp diff --git a/packages/SystemUI/src/com/android/keyguard/BouncerPanelExpansionCalculator.kt b/packages/SystemUI/src/com/android/keyguard/BouncerPanelExpansionCalculator.kt index 497d81f6bdc5c..1b2ea3b257abb 100644 --- a/packages/SystemUI/src/com/android/keyguard/BouncerPanelExpansionCalculator.kt +++ b/packages/SystemUI/src/com/android/keyguard/BouncerPanelExpansionCalculator.kt @@ -46,4 +46,24 @@ object BouncerPanelExpansionCalculator { fun getKeyguardClockScaledExpansion(fraction: Float): Float { return MathUtils.constrain((fraction - 0.7f) / 0.3f, 0f, 1f) } + + /** + * Scale the position of the dream complications. + */ + @JvmStatic + fun getDreamYPositionScaledExpansion(fraction: Float): Float { + return when { + fraction >= 0.98f -> 1f + fraction < 0.93 -> 0f + else -> (fraction - 0.93f) / 0.05f + } + } + + /** + * Scale the alpha of the dream complications. + */ + @JvmStatic + fun getDreamAlphaScaledExpansion(fraction: Float): Float { + return MathUtils.constrain((fraction - 0.94f) / 0.06f, 0f, 1f) + } } \ No newline at end of file diff --git a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayContainerViewController.java b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayContainerViewController.java index 456119068b93d..fb1af8b66b913 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayContainerViewController.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayContainerViewController.java @@ -16,14 +16,21 @@ package com.android.systemui.dreams; +import static com.android.keyguard.BouncerPanelExpansionCalculator.getBackScrimScaledExpansion; +import static com.android.keyguard.BouncerPanelExpansionCalculator.getDreamAlphaScaledExpansion; +import static com.android.keyguard.BouncerPanelExpansionCalculator.getDreamYPositionScaledExpansion; import static com.android.systemui.doze.util.BurnInHelperKt.getBurnInOffset; +import static com.android.systemui.dreams.complication.ComplicationLayoutParams.POSITION_BOTTOM; +import static com.android.systemui.dreams.complication.ComplicationLayoutParams.POSITION_TOP; +import android.content.res.Resources; import android.os.Handler; import android.util.MathUtils; import android.view.View; import android.view.ViewGroup; -import com.android.keyguard.BouncerPanelExpansionCalculator; +import com.android.systemui.R; +import com.android.systemui.animation.Interpolators; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dreams.complication.ComplicationHostViewController; import com.android.systemui.dreams.dagger.DreamOverlayComponent; @@ -33,6 +40,8 @@ import com.android.systemui.statusbar.phone.KeyguardBouncer; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.util.ViewController; +import java.util.Arrays; + import javax.inject.Inject; import javax.inject.Named; @@ -63,6 +72,7 @@ public class DreamOverlayContainerViewController extends ViewController