xref: /aosp_15_r20/frameworks/base/packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockAnimations.kt (revision d57664e9bc4670b3ecf6748a746a57c557b6bc9e)
1 /*
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5  * except in compliance with the License. You may obtain a copy of the License at
6  *
7  *      http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software distributed under the
10  * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11  * KIND, either express or implied. See the License for the specific language governing
12  * permissions and limitations under the License.
13  */
14 package com.android.systemui.plugins.clocks
15 
16 import android.view.View
17 import com.android.systemui.plugins.annotations.ProtectedInterface
18 
19 /** Methods which trigger various clock animations */
20 @ProtectedInterface
21 interface ClockAnimations {
22     /** Runs an enter animation (if any) */
enternull23     fun enter()
24 
25     /** Sets how far into AOD the device currently is. */
26     fun doze(fraction: Float)
27 
28     /** Sets how far into the folding animation the device is. */
29     fun fold(fraction: Float)
30 
31     /** Runs the battery animation (if any). */
32     fun charge()
33 
34     /**
35      * Runs when the clock's position changed during the move animation.
36      *
37      * @param fromLeft the [View.getLeft] position of the clock, before it started moving.
38      * @param direction the direction in which it is moving. A positive number means right, and
39      *   negative means left.
40      * @param fraction fraction of the clock movement. 0 means it is at the beginning, and 1 means
41      *   it finished moving.
42      * @deprecated use {@link #onPositionUpdated(float, float)} instead.
43      */
44     fun onPositionUpdated(fromLeft: Int, direction: Int, fraction: Float)
45 
46     /**
47      * Runs when the clock's position changed during the move animation.
48      *
49      * @param distance is the total distance in pixels to offset the glyphs when animation
50      *   completes. Negative distance means we are animating the position towards the center.
51      * @param fraction fraction of the clock movement. 0 means it is at the beginning, and 1 means
52      *   it finished moving.
53      */
54     fun onPositionUpdated(distance: Float, fraction: Float)
55 
56     /**
57      * Runs when swiping clock picker, swipingFraction: 1.0 -> clock is scaled up in the preview,
58      * 0.0 -> clock is scaled down in the shade; previewRatio is previewSize / screenSize
59      */
60     fun onPickerCarouselSwiping(swipingFraction: Float)
61 }
62