1 package com.android.systemui.statusbar.notification
2 
3 import android.util.MathUtils
4 import com.android.internal.annotations.VisibleForTesting
5 import com.android.systemui.animation.ActivityTransitionAnimator
6 import com.android.app.animation.Interpolators
7 import com.android.systemui.animation.TransitionAnimator
8 import kotlin.math.min
9 
10 /** Parameters for the notifications launch expanding animations. */
11 class LaunchAnimationParameters(
12     top: Int,
13     bottom: Int,
14     left: Int,
15     right: Int,
16 
17     topCornerRadius: Float = 0f,
18     bottomCornerRadius: Float = 0f
19 ) : TransitionAnimator.State(top, bottom, left, right, topCornerRadius, bottomCornerRadius) {
20     @VisibleForTesting
21     constructor() : this(
22         top = 0, bottom = 0, left = 0, right = 0, topCornerRadius = 0f, bottomCornerRadius = 0f
23     )
24 
25     var startTranslationZ = 0f
26 
27     /**
28      * The top position of the notification at the start of the animation. This is needed in order
29      * to keep the notification at its place when launching a notification that is clipped rounded.
30      * This value is in absolute screen coordinates.
31      */
32     var startNotificationTop = 0
33     var notificationParentTop = 0
34     var startClipTopAmount = 0
35     var parentStartClipTopAmount = 0
36     var progress = 0f
37     var linearProgress = 0f
38 
39     /**
40      * The rounded top clipping at the beginning.
41      */
42     var startRoundedTopClipping = 0
43 
44     /**
45      * The rounded top clipping of the parent notification at the start.
46      */
47     var parentStartRoundedTopClipping = 0
48 
49     override val topChange: Int
50         get() {
51             // We need this compensation to ensure that the QS moves in sync.
52             var clipTopAmountCompensation = 0
53             if (startClipTopAmount.toFloat() != 0.0f) {
54                 clipTopAmountCompensation = MathUtils.lerp(0f, startClipTopAmount.toFloat(),
55                         Interpolators.FAST_OUT_SLOW_IN.getInterpolation(linearProgress)).toInt()
56             }
57             return min(super.topChange - clipTopAmountCompensation, 0)
58         }
59 
getProgressnull60     fun getProgress(delay: Long, duration: Long): Float {
61         return TransitionAnimator.getProgress(
62             ActivityTransitionAnimator.TIMINGS,
63             linearProgress,
64             delay,
65             duration
66         )
67     }
68 }