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 /** 104 * Sets the maximum number of notifications to display. 105 * 106 * @param maxNotifications max number of notifications to display 107 */ setMaxDisplayedNotifications(int maxNotifications)108 void setMaxDisplayedNotifications(int maxNotifications); 109 110 /** 111 * Get the view parent for a notification entry. For example, NotificationStackScrollLayout. 112 * 113 * @param entry entry to get the view parent for 114 * @return the view parent for entry 115 */ getViewParentForNotification(NotificationEntry entry)116 ViewGroup getViewParentForNotification(NotificationEntry entry); 117 118 /** 119 * Resets the currently exposed menu view. 120 * 121 * @param animate whether to animate the closing/change of menu view 122 * @param force reset the menu view even if it looks like it is already reset 123 */ resetExposedMenuView(boolean animate, boolean force)124 void resetExposedMenuView(boolean animate, boolean force); 125 126 /** 127 * Returns the NotificationSwipeActionHelper for the NotificationListContainer. 128 * 129 * @return swipe action helper for the list container 130 */ getSwipeActionHelper()131 NotificationSwipeActionHelper getSwipeActionHelper(); 132 133 /** 134 * Called when a notification is removed from the shade. This cleans up the state for a 135 * given view. 136 * 137 * @param entry the entry whose view's view state needs to be cleaned up (say that 5 times fast) 138 */ cleanUpViewStateForEntry(NotificationEntry entry)139 void cleanUpViewStateForEntry(NotificationEntry entry); 140 141 142 /** 143 * Sets a listener to listen for changes in notification locations. 144 * 145 * @param listener listener to set 146 */ setChildLocationsChangedListener( NotificationLogger.OnChildLocationsChangedListener listener)147 void setChildLocationsChangedListener( 148 NotificationLogger.OnChildLocationsChangedListener listener); 149 150 /** 151 * Called when an update to the notification view hierarchy is completed. 152 */ onNotificationViewUpdateFinished()153 default void onNotificationViewUpdateFinished() {} 154 155 /** 156 * Returns true if there are pulsing notifications. 157 * 158 * @return true if has pulsing notifications 159 */ hasPulsingNotifications()160 boolean hasPulsingNotifications(); 161 162 /** 163 * Apply parameters of the expand animation to the layout 164 */ applyLaunchAnimationParams(LaunchAnimationParameters params)165 default void applyLaunchAnimationParams(LaunchAnimationParameters params) {} 166 setExpandingNotification(ExpandableNotificationRow row)167 default void setExpandingNotification(ExpandableNotificationRow row) {} 168 169 /** 170 * Bind a newly created row. 171 * 172 * @param row The notification to bind. 173 */ bindRow(ExpandableNotificationRow row)174 default void bindRow(ExpandableNotificationRow row) {} 175 176 /** 177 * @return the start location where we start clipping notifications. 178 */ getTopClippingStartLocation()179 default int getTopClippingStartLocation() { 180 return 0; 181 } 182 } 183