1 /* 2 * Copyright (C) 2020 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.collection.listbuilder.pluggable; 18 19 import android.annotation.Nullable; 20 21 import com.android.systemui.statusbar.notification.collection.ListEntry; 22 import com.android.systemui.statusbar.notification.collection.ShadeListBuilder; 23 import com.android.systemui.statusbar.notification.collection.render.NodeController; 24 import com.android.systemui.statusbar.notification.collection.render.NodeSpec; 25 import com.android.systemui.statusbar.notification.stack.PriorityBucket; 26 27 import java.util.List; 28 29 /** 30 * Pluggable for participating in notif sectioning. See {@link ShadeListBuilder#setSectioners}. 31 */ 32 public abstract class NotifSectioner extends Pluggable<NotifSectioner> { 33 @PriorityBucket 34 private final int mBucket; 35 NotifSectioner(String name, @PriorityBucket int bucket)36 protected NotifSectioner(String name, @PriorityBucket int bucket) { 37 super(name); 38 mBucket = bucket; 39 } 40 41 /** 42 * @return the "bucket" value to apply to entries in this section 43 */ 44 @PriorityBucket getBucket()45 public final int getBucket() { 46 return mBucket; 47 } 48 49 /** 50 * If returns true, this notification is considered within this section. 51 * Sectioning is performed on each top level notification each time the pipeline is run. 52 * However, this doesn't necessarily mean that your section will get called on each top-level 53 * notification. The first section to return true determines the section of the notification. 54 */ isInSection(ListEntry entry)55 public abstract boolean isInSection(ListEntry entry); 56 57 /** 58 * Returns an optional {@link NotifComparator} to sort entries only in this section. 59 * {@link ListEntry} instances passed to this comparator are guaranteed to have this section, 60 * and this ordering will take precedence over any global comparators supplied to {@link 61 * com.android.systemui.statusbar.notification.collection.NotifPipeline#setComparators(List)}. 62 * 63 * NOTE: this method is only called once when the Sectioner is attached. 64 */ getComparator()65 public @Nullable NotifComparator getComparator() { 66 return null; 67 } 68 69 /** 70 * Returns an optional {@link NodeSpec} for the section header. If {@code null}, no header will 71 * be used for the section. 72 * 73 * NOTE: this method is only called once when the Sectioner is attached. 74 */ getHeaderNodeController()75 public @Nullable NodeController getHeaderNodeController() { 76 return null; 77 } 78 79 /** 80 * Notify of children of this section being updated 81 * @param entries of this section that are borrowed (must clone to store) 82 */ onEntriesUpdated(List<ListEntry> entries)83 public void onEntriesUpdated(List<ListEntry> entries) {} 84 } 85