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.pluggable.NotifFilter
20 import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifPromoter
21 import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSection
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     var sectionIndex: Int,
39 
40     /**
41      * If a [NotifFilter] is excluding this entry from the list, then that filter. Always null for
42      * [GroupEntry]s.
43      */
44     var excludingFilter: NotifFilter?,
45 
46     /**
47      * The [NotifPromoter] promoting this entry to top-level, if any. Always null for [GroupEntry]s.
48      */
49     var promoter: NotifPromoter?
50 ) {
51 
52     /** Copies the state of another instance. */
clonenull53     fun clone(other: ListAttachState) {
54         parent = other.parent
55         section = other.section
56         sectionIndex = other.sectionIndex
57         excludingFilter = other.excludingFilter
58         promoter = other.promoter
59     }
60 
61     /** Resets back to a "clean" state (the same as created by the factory method) */
resetnull62     fun reset() {
63         parent = null
64         section = null
65         sectionIndex = -1
66         excludingFilter = null
67         promoter = null
68     }
69 
70     companion object {
71         @JvmStatic
createnull72         fun create(): ListAttachState {
73             return ListAttachState(
74                     null,
75                     null,
76                     -1,
77                     null,
78                     null)
79         }
80     }
81 }
82