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 18 19 import com.android.systemui.statusbar.notification.collection.listbuilder.NotifSection 20 import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter 21 import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifPromoter 22 23 /** 24 * Stores the state that [ShadeListBuilder] assigns to this [ListEntry] 25 */ 26 data class ListAttachState private constructor( 27 /** 28 * Null if not attached to the current shade list. If top-level, then the shade list root. If 29 * part of a group, then that group's GroupEntry. 30 */ 31 var parent: GroupEntry?, 32 33 /** 34 * The section that this ListEntry was sorted into. If the child of the group, this will be the 35 * parent's section. Null if not attached to the list. 36 */ 37 var section: NotifSection?, 38 39 /** 40 * If a [NotifFilter] is excluding this entry from the list, then that filter. Always null for 41 * [GroupEntry]s. 42 */ 43 var excludingFilter: NotifFilter?, 44 45 /** 46 * The [NotifPromoter] promoting this entry to top-level, if any. Always null for [GroupEntry]s. 47 */ 48 var promoter: NotifPromoter?, 49 50 /** 51 * If the [VisualStabilityManager] is suppressing group or section changes for this entry, 52 * suppressedChanges will contain the new parent or section that we would have assigned to 53 * the entry had it not been suppressed by the VisualStabilityManager. 54 */ 55 var suppressedChanges: SuppressedAttachState 56 ) { 57 58 /** Copies the state of another instance. */ 59 fun clone(other: ListAttachState) { 60 parent = other.parent 61 section = other.section 62 excludingFilter = other.excludingFilter 63 promoter = other.promoter 64 suppressedChanges.clone(other.suppressedChanges) 65 } 66 67 /** Resets back to a "clean" state (the same as created by the factory method) */ 68 fun reset() { 69 parent = null 70 section = null 71 excludingFilter = null 72 promoter = null 73 suppressedChanges.reset() 74 } 75 76 companion object { 77 @JvmStatic 78 fun create(): ListAttachState { 79 return ListAttachState( 80 null, 81 null, 82 null, 83 null, 84 SuppressedAttachState.create()) 85 } 86 } 87 } 88