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