1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.systemui.keyguard.shared.model
18 
19 /**
20  * Models the appearance of the surface behind the keyguard, and (optionally) how it should be
21  * animating.
22  *
23  * This is intended to be an atomic, high-level description of the surface's appearance and related
24  * animations, which we can derive from the STARTED/FINISHED transition states rather than the
25  * individual TransitionSteps.
26  *
27  * For example, if we're transitioning from LOCKSCREEN to GONE, that means we should be
28  * animatingFromAlpha 0f -> 1f and animatingFromTranslationY 500f -> 0f.
29  * KeyguardSurfaceBehindAnimator can decide how best to implement this, depending on previously
30  * running animations, spring momentum, and other state.
31  */
32 data class KeyguardSurfaceBehindModel(
33     val alpha: Float = 1f,
34 
35     /**
36      * If provided, animate from this value to [alpha] unless an animation is already running, in
37      * which case we'll animate from the current value to [alpha].
38      */
39     val animateFromAlpha: Float = alpha,
40     val translationY: Float = 0f,
41 
42     /**
43      * If provided, animate from this value to [translationY] unless an animation is already
44      * running, in which case we'll animate from the current value to [translationY].
45      */
46     val animateFromTranslationY: Float = translationY,
47 
48     /** Velocity with which to start the Y-translation spring animation. */
49     val startVelocity: Float = 0f,
50 ) {
willAnimateAlphanull51     fun willAnimateAlpha(): Boolean {
52         return animateFromAlpha != alpha
53     }
54 
willAnimateTranslationYnull55     fun willAnimateTranslationY(): Boolean {
56         return animateFromTranslationY != translationY
57     }
58 }
59