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 package com.android.systemui.shade
17 
18 import android.view.ViewPropertyAnimator
19 import com.android.systemui.statusbar.GestureRecorder
20 import com.android.systemui.statusbar.NotificationShelfController
21 import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController
22 import com.android.systemui.statusbar.phone.CentralSurfaces
23 import com.android.systemui.statusbar.phone.HeadsUpManagerPhone
24 
25 /**
26  * Allows CentralSurfacesImpl to interact with the shade. Only CentralSurfacesImpl should reference
27  * this class. If any method in this class is needed outside of CentralSurfacesImpl, it must be
28  * pulled up into ShadeViewController.
29  */
30 interface ShadeSurface : ShadeViewController {
31     /** Initialize objects instead of injecting to avoid circular dependencies. */
32     fun initDependencies(
33         centralSurfaces: CentralSurfaces,
34         recorder: GestureRecorder,
35         hideExpandedRunnable: Runnable,
36         notificationShelfController: NotificationShelfController,
37         headsUpManager: HeadsUpManagerPhone
38     )
39 
40     /** Cancels any pending collapses. */
41     fun cancelPendingCollapse()
42 
43     /** Cancels the views current animation. */
44     fun cancelAnimation()
45 
46     /** Input focus transfer is about to happen. */
47     fun startWaitingForExpandGesture()
48 
49     /**
50      * Called when this view is no longer waiting for input focus transfer.
51      *
52      * There are two scenarios behind this function call. First, input focus transfer has
53      * successfully happened and this view already received synthetic DOWN event.
54      * (mExpectingSynthesizedDown == false). Do nothing.
55      *
56      * Second, before input focus transfer finished, user may have lifted finger in previous window
57      * and this window never received synthetic DOWN event. (mExpectingSynthesizedDown == true). In
58      * this case, we use the velocity to trigger fling event.
59      *
60      * @param velocity unit is in px / millis
61      */
62     fun stopWaitingForExpandGesture(cancel: Boolean, velocity: Float)
63 
64     /** Animates the view from its current alpha to zero then runs the runnable. */
65     fun fadeOut(startDelayMs: Long, durationMs: Long, endAction: Runnable): ViewPropertyAnimator
66 
67     /** Returns the NSSL controller. */
68     val notificationStackScrollLayoutController: NotificationStackScrollLayoutController
69 
70     /** Set whether the bouncer is showing. */
71     fun setBouncerShowing(bouncerShowing: Boolean)
72 
73     /**
74      * Sets whether the shade can handle touches and/or animate, canceling any touch handling or
75      * animations in progress.
76      */
77     fun setTouchAndAnimationDisabled(disabled: Boolean)
78 
79     /**
80      * Notify us that {@link NotificationWakeUpCoordinator} is going to play the doze wakeup
81      * animation after a delay. If so, we'll keep the clock centered until that animation starts.
82      */
83     fun setWillPlayDelayedDozeAmountAnimation(willPlay: Boolean)
84 
85     /**
86      * Sets the dozing state.
87      *
88      * @param dozing `true` when dozing.
89      * @param animate if transition should be animated.
90      */
91     fun setDozing(dozing: Boolean, animate: Boolean)
92 
93     /** @see view.setImportantForAccessibility */
94     fun setImportantForAccessibility(mode: Int)
95 
96     /** Sets the view's X translation to zero. */
97     fun resetTranslation()
98 
99     /** Sets the view's alpha to max. */
100     fun resetAlpha()
101 
102     /** Sets progress of the predictive back animation. */
103     fun onBackProgressed(progressFraction: Float)
104 
105     /** @see com.android.systemui.keyguard.ScreenLifecycle.Observer.onScreenTurningOn */
106     fun onScreenTurningOn()
107 
108     /**
109      * Called when the device's theme changes.
110      *
111      * TODO(b/274655539) delete?
112      */
113     fun onThemeChanged()
114 
115     /** Updates the shade expansion and [NotificationPanelView] visibility if necessary. */
116     fun updateExpansionAndVisibility()
117 
118     /** Updates all field values drawn from Resources. */
119     fun updateResources()
120 }
121