1 /*
2  * Copyright (C) 2024 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.wm.shell.bubbles
18 
19 import java.util.function.Consumer
20 
21 /** Defines callbacks from [BubbleStackView] to its manager. */
22 interface BubbleStackViewManager {
23 
24     /** Notifies that all bubbles animated out. */
onAllBubblesAnimatedOutnull25     fun onAllBubblesAnimatedOut()
26 
27     /** Notifies whether backpress should be intercepted. */
28     fun updateWindowFlagsForBackpress(interceptBack: Boolean)
29 
30     /**
31      * Checks the current expansion state of the notification panel, and invokes [callback] with the
32      * result.
33      */
34     fun checkNotificationPanelExpandedState(callback: Consumer<Boolean>)
35 
36     /** Requests to hide the current input method. */
37     fun hideCurrentInputMethod()
38 
39     companion object {
40 
41         @JvmStatic
42         fun fromBubbleController(controller: BubbleController) = object : BubbleStackViewManager {
43             override fun onAllBubblesAnimatedOut() {
44                 controller.onAllBubblesAnimatedOut()
45             }
46 
47             override fun updateWindowFlagsForBackpress(interceptBack: Boolean) {
48                 controller.updateWindowFlagsForBackpress(interceptBack)
49             }
50 
51             override fun checkNotificationPanelExpandedState(callback: Consumer<Boolean>) {
52                 controller.isNotificationPanelExpanded(callback)
53             }
54 
55             override fun hideCurrentInputMethod() {
56                 controller.hideCurrentInputMethod()
57             }
58         }
59     }
60 }
61