• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 com.android.wm.shell.shared.bubbles.BubbleBarLocation
20 
21 /** Manager interface for bubble expanded views. */
22 interface BubbleExpandedViewManager {
23 
24     val overflowBubbles: List<Bubble>
setOverflowListenernull25     fun setOverflowListener(listener: BubbleData.Listener)
26     fun collapseStack()
27     fun updateWindowFlagsForBackpress(intercept: Boolean)
28     fun promoteBubbleFromOverflow(bubble: Bubble)
29     fun removeBubble(key: String, reason: Int)
30     fun dismissBubble(bubble: Bubble, reason: Int)
31     fun setNoteBubbleTaskId(key: String, taskId: Int)
32     fun isStackExpanded(): Boolean
33     fun isShowingAsBubbleBar(): Boolean
34     fun hideCurrentInputMethod()
35     fun updateBubbleBarLocation(
36         location: BubbleBarLocation,
37         @BubbleBarLocation.UpdateSource source: Int,
38     )
39 
40     companion object {
41         /**
42          * Convenience function for creating a [BubbleExpandedViewManager] that delegates to the
43          * given `controller`.
44          */
45         @JvmStatic
46         fun fromBubbleController(controller: BubbleController): BubbleExpandedViewManager {
47             return object : BubbleExpandedViewManager {
48 
49                 override val overflowBubbles: List<Bubble>
50                     get() = controller.overflowBubbles
51 
52                 override fun setOverflowListener(listener: BubbleData.Listener) {
53                     controller.setOverflowListener(listener)
54                 }
55 
56                 override fun collapseStack() {
57                     controller.collapseStack()
58                 }
59 
60                 override fun updateWindowFlagsForBackpress(intercept: Boolean) {
61                     controller.updateWindowFlagsForBackpress(intercept)
62                 }
63 
64                 override fun promoteBubbleFromOverflow(bubble: Bubble) {
65                     controller.promoteBubbleFromOverflow(bubble)
66                 }
67 
68                 override fun removeBubble(key: String, reason: Int) {
69                     controller.removeBubble(key, reason)
70                 }
71 
72                 override fun dismissBubble(bubble: Bubble, reason: Int) {
73                     controller.dismissBubble(bubble, reason)
74                 }
75 
76                 override fun setNoteBubbleTaskId(key: String, taskId: Int) {
77                     controller.setNoteBubbleTaskId(key, taskId)
78                 }
79 
80                 override fun isStackExpanded(): Boolean = controller.isStackExpanded
81 
82                 override fun isShowingAsBubbleBar(): Boolean = controller.isShowingAsBubbleBar
83 
84                 override fun hideCurrentInputMethod() {
85                     controller.hideCurrentInputMethod(null)
86                 }
87 
88                 override fun updateBubbleBarLocation(
89                     location: BubbleBarLocation,
90                     @BubbleBarLocation.UpdateSource source: Int,
91                 ) {
92                     controller.setBubbleBarLocation(location, source)
93                 }
94             }
95         }
96     }
97 }
98