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