1 /*
2  * Copyright (C) 2017 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.stack;
18 
19 import static com.android.systemui.statusbar.notification.ActivityLaunchAnimator.ExpandAnimationParameters;
20 
21 import android.view.View;
22 import android.view.ViewGroup;
23 
24 import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper;
25 import com.android.systemui.statusbar.notification.VisibilityLocationProvider;
26 import com.android.systemui.statusbar.notification.collection.NotificationEntry;
27 import com.android.systemui.statusbar.notification.logging.NotificationLogger;
28 import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
29 import com.android.systemui.statusbar.notification.row.ExpandableView;
30 
31 /**
32  * Interface representing the entity that contains notifications. It can have
33  * notification views added and removed from it, and will manage displaying them to the user.
34  */
35 public interface NotificationListContainer extends ExpandableView.OnHeightChangedListener,
36         VisibilityLocationProvider {
37 
38     /**
39      * Called when a child is being transferred.
40      *
41      * @param childTransferInProgress whether child transfer is in progress
42      */
setChildTransferInProgress(boolean childTransferInProgress)43     void setChildTransferInProgress(boolean childTransferInProgress);
44 
45     /**
46      * Change the position of child to a new location
47      *  @param child the view to change the position for
48      * @param newIndex the new index
49      */
changeViewPosition(ExpandableView child, int newIndex)50     void changeViewPosition(ExpandableView child, int newIndex);
51 
52     /**
53      * Called when a child was added to a group.
54      *
55      * @param row row of the group child that was added
56      */
notifyGroupChildAdded(ExpandableView row)57     void notifyGroupChildAdded(ExpandableView row);
58 
59     /**
60      * Called when a child was removed from a group.
61      *  @param row row of the child that was removed
62      * @param childrenContainer ViewGroup of the group that the child was removed from
63      */
notifyGroupChildRemoved(ExpandableView row, ViewGroup childrenContainer)64     void notifyGroupChildRemoved(ExpandableView row, ViewGroup childrenContainer);
65 
66     /**
67      * Generate an animation for an added child view.
68      *  @param child The view to be added.
69      * @param fromMoreCard Whether this add is coming from the "more" card on lockscreen.
70      */
generateAddAnimation(ExpandableView child, boolean fromMoreCard)71     void generateAddAnimation(ExpandableView child, boolean fromMoreCard);
72 
73     /**
74      * Generate a child order changed event.
75      */
generateChildOrderChangedEvent()76     void generateChildOrderChangedEvent();
77 
78     /**
79      * Returns the number of children in the NotificationListContainer.
80      *
81      * @return the number of children in the NotificationListContainer
82      */
getContainerChildCount()83     int getContainerChildCount();
84 
85     /**
86      * Gets the ith child in the NotificationListContainer.
87      *
88      * @param i ith child to get
89      * @return the ith child in the list container
90      */
getContainerChildAt(int i)91     View getContainerChildAt(int i);
92 
93     /**
94      * Remove a view from the container
95      *
96      * @param v view to remove
97      */
removeContainerView(View v)98     void removeContainerView(View v);
99 
100     /**
101      * Add a view to the container
102      *
103      * @param v view to add
104      */
addContainerView(View v)105     void addContainerView(View v);
106 
107     /**
108      * Sets the maximum number of notifications to display.
109      *
110      * @param maxNotifications max number of notifications to display
111      */
setMaxDisplayedNotifications(int maxNotifications)112     void setMaxDisplayedNotifications(int maxNotifications);
113 
114     /**
115      * Get the view parent for a notification entry. For example, NotificationStackScrollLayout.
116      *
117      * @param entry entry to get the view parent for
118      * @return the view parent for entry
119      */
getViewParentForNotification(NotificationEntry entry)120     ViewGroup getViewParentForNotification(NotificationEntry entry);
121 
122     /**
123      * Resets the currently exposed menu view.
124      *
125      * @param animate whether to animate the closing/change of menu view
126      * @param force reset the menu view even if it looks like it is already reset
127      */
resetExposedMenuView(boolean animate, boolean force)128     void resetExposedMenuView(boolean animate, boolean force);
129 
130     /**
131      * Returns the NotificationSwipeActionHelper for the NotificationListContainer.
132      *
133      * @return swipe action helper for the list container
134      */
getSwipeActionHelper()135     NotificationSwipeActionHelper getSwipeActionHelper();
136 
137     /**
138      * Called when a notification is removed from the shade. This cleans up the state for a
139      * given view.
140      *
141      * @param entry the entry whose view's view state needs to be cleaned up (say that 5 times fast)
142      */
cleanUpViewStateForEntry(NotificationEntry entry)143     void cleanUpViewStateForEntry(NotificationEntry entry);
144 
145 
146     /**
147      * Sets a listener to listen for changes in notification locations.
148      *
149      * @param listener listener to set
150      */
setChildLocationsChangedListener( NotificationLogger.OnChildLocationsChangedListener listener)151     void setChildLocationsChangedListener(
152             NotificationLogger.OnChildLocationsChangedListener listener);
153 
154     /**
155      * Called when an update to the notification view hierarchy is completed.
156      */
onNotificationViewUpdateFinished()157     default void onNotificationViewUpdateFinished() {}
158 
159     /**
160      * Returns true if there are pulsing notifications.
161      *
162      * @return true if has pulsing notifications
163      */
hasPulsingNotifications()164     boolean hasPulsingNotifications();
165 
166     /**
167      * Apply parameters of the expand animation to the layout
168      */
applyExpandAnimationParams(ExpandAnimationParameters params)169     default void applyExpandAnimationParams(ExpandAnimationParameters params) {}
170 
setExpandingNotification(ExpandableNotificationRow row)171     default void setExpandingNotification(ExpandableNotificationRow row) {}
172 
173     /**
174      * Bind a newly created row.
175      *
176      * @param row The notification to bind.
177      */
bindRow(ExpandableNotificationRow row)178     default void bindRow(ExpandableNotificationRow row) {}
179 
180     /**
181      * Does this list contain a given view. True by default is fine, since we only ask this if the
182      * view has a parent.
183      */
containsView(View v)184     default boolean containsView(View v) {
185         return true;
186     }
187 
setWillExpand(boolean willExpand)188     default void setWillExpand(boolean willExpand) {};
189 }
190