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 android.view.View; 20 import android.view.ViewGroup; 21 22 import androidx.annotation.Nullable; 23 24 import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper; 25 import com.android.systemui.statusbar.notification.ExpandAnimationParameters; 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.logging.NotificationLogger; 30 import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; 31 import com.android.systemui.statusbar.notification.row.ExpandableView; 32 33 /** 34 * Interface representing the entity that contains notifications. It can have 35 * notification views added and removed from it, and will manage displaying them to the user. 36 */ 37 public interface NotificationListContainer extends 38 ExpandableView.OnHeightChangedListener, 39 VisibilityLocationProvider { 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 */ 94 @Nullable getContainerChildAt(int i)95 View getContainerChildAt(int i); 96 97 /** 98 * Remove a view from the container 99 * 100 * @param v view to remove 101 */ removeContainerView(View v)102 void removeContainerView(View v); 103 104 /** 105 * Add a view to the container 106 * 107 * @param v view to add 108 */ addContainerView(View v)109 void addContainerView(View v); 110 111 /** 112 * Add a view to the container at a particular index 113 */ addContainerViewAt(View v, int index)114 void addContainerViewAt(View v, int index); 115 116 /** 117 * Sets the maximum number of notifications to display. 118 * 119 * @param maxNotifications max number of notifications to display 120 */ setMaxDisplayedNotifications(int maxNotifications)121 void setMaxDisplayedNotifications(int maxNotifications); 122 123 /** 124 * Get the view parent for a notification entry. For example, NotificationStackScrollLayout. 125 * 126 * @param entry entry to get the view parent for 127 * @return the view parent for entry 128 */ getViewParentForNotification(NotificationEntry entry)129 ViewGroup getViewParentForNotification(NotificationEntry entry); 130 131 /** 132 * Resets the currently exposed menu view. 133 * 134 * @param animate whether to animate the closing/change of menu view 135 * @param force reset the menu view even if it looks like it is already reset 136 */ resetExposedMenuView(boolean animate, boolean force)137 void resetExposedMenuView(boolean animate, boolean force); 138 139 /** 140 * Returns the NotificationSwipeActionHelper for the NotificationListContainer. 141 * 142 * @return swipe action helper for the list container 143 */ getSwipeActionHelper()144 NotificationSwipeActionHelper getSwipeActionHelper(); 145 146 /** 147 * Called when a notification is removed from the shade. This cleans up the state for a 148 * given view. 149 * 150 * @param entry the entry whose view's view state needs to be cleaned up (say that 5 times fast) 151 */ cleanUpViewStateForEntry(NotificationEntry entry)152 void cleanUpViewStateForEntry(NotificationEntry entry); 153 154 155 /** 156 * Sets a listener to listen for changes in notification locations. 157 * 158 * @param listener listener to set 159 */ setChildLocationsChangedListener( NotificationLogger.OnChildLocationsChangedListener listener)160 void setChildLocationsChangedListener( 161 NotificationLogger.OnChildLocationsChangedListener listener); 162 163 /** 164 * Called when an update to the notification view hierarchy is completed. 165 */ onNotificationViewUpdateFinished()166 default void onNotificationViewUpdateFinished() {} 167 168 /** 169 * Returns true if there are pulsing notifications. 170 * 171 * @return true if has pulsing notifications 172 */ hasPulsingNotifications()173 boolean hasPulsingNotifications(); 174 175 /** 176 * Apply parameters of the expand animation to the layout 177 */ applyExpandAnimationParams(ExpandAnimationParameters params)178 default void applyExpandAnimationParams(ExpandAnimationParameters params) {} 179 setExpandingNotification(ExpandableNotificationRow row)180 default void setExpandingNotification(ExpandableNotificationRow row) {} 181 182 /** 183 * Bind a newly created row. 184 * 185 * @param row The notification to bind. 186 */ bindRow(ExpandableNotificationRow row)187 default void bindRow(ExpandableNotificationRow row) {} 188 189 /** 190 * Does this list contain a given view. True by default is fine, since we only ask this if the 191 * view has a parent. 192 */ containsView(View v)193 default boolean containsView(View v) { 194 return true; 195 } 196 197 /** 198 * Tells the container that an animation is about to expand it. 199 */ setWillExpand(boolean willExpand)200 default void setWillExpand(boolean willExpand) {} 201 setNotificationActivityStarter(NotificationActivityStarter notificationActivityStarter)202 void setNotificationActivityStarter(NotificationActivityStarter notificationActivityStarter); 203 204 /** 205 * @return the start location where we start clipping notifications. 206 */ getTopClippingStartLocation()207 default int getTopClippingStartLocation() { 208 return 0; 209 } 210 } 211