1 /*
2  * Copyright (C) 2020 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.statusbar.notification.collection.render;
18 
19 import com.android.systemui.statusbar.notification.collection.NotificationEntry;
20 import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
21 
22 /**
23  * Tracks expanded notification states for groups. This expanded state should not be confused by the
24  * expanded/collapsed state of a single notification which is tracked within each
25  * ExpandableNotificationRow.
26  */
27 public interface GroupExpansionManager {
28 
29     /**
30      * Register a listener for group expansion changes
31      */
registerGroupExpansionChangeListener(OnGroupExpansionChangeListener listener)32     void registerGroupExpansionChangeListener(OnGroupExpansionChangeListener listener);
33 
34     /**
35      * Whether the group associated with this notification is expanded.
36      * If this notification is not part of a group, it will always return false.
37      */
isGroupExpanded(NotificationEntry entry)38     boolean isGroupExpanded(NotificationEntry entry);
39 
40     /**
41      * Set whether the group associated with this notification is expanded or not.
42      */
setGroupExpanded(NotificationEntry entry, boolean expanded)43     void setGroupExpanded(NotificationEntry entry, boolean expanded);
44 
45     /** @return group expansion state after toggling. */
toggleGroupExpansion(NotificationEntry entry)46     boolean toggleGroupExpansion(NotificationEntry entry);
47 
48     /**
49      * Set expanded=false for all groups
50      */
collapseGroups()51     void collapseGroups();
52 
53     /**
54      * Listener for group expansion changes.
55      */
56     interface OnGroupExpansionChangeListener {
57         /**
58          * The expansion of a group has changed.
59          *
60          * @param changedRow the row for which the expansion has changed, which is also the summary
61          * @param expanded a boolean indicating the new expanded state
62          */
onGroupExpansionChange(ExpandableNotificationRow changedRow, boolean expanded)63         void onGroupExpansionChange(ExpandableNotificationRow changedRow, boolean expanded);
64     }
65 }
66