• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.icon;
18 
19 import androidx.annotation.NonNull;
20 import androidx.annotation.Nullable;
21 
22 import com.android.internal.statusbar.StatusBarIcon;
23 import com.android.systemui.statusbar.StatusBarIconView;
24 
25 /**
26  * Data class for storing icons associated with a notification
27  */
28 public final class IconPack {
29 
30     private final boolean mAreIconsAvailable;
31     @Nullable private final StatusBarIconView mStatusBarIcon;
32     @Nullable private final StatusBarIconView mShelfIcon;
33     @Nullable private final StatusBarIconView mAodIcon;
34     @Nullable private final StatusBarIconView mCenteredIcon;
35 
36     @Nullable private StatusBarIcon mSmallIconDescriptor;
37     @Nullable private StatusBarIcon mPeopleAvatarDescriptor;
38 
39     private boolean mIsImportantConversation;
40 
41     /**
42      * Builds an empty instance of IconPack that doesn't have any icons (because either they
43      * haven't been inflated yet or there was an error while inflating them).
44      */
buildEmptyPack(@ullable IconPack fromSource)45     public static IconPack buildEmptyPack(@Nullable IconPack fromSource) {
46         return new IconPack(false, null, null, null, null, fromSource);
47     }
48 
49     /**
50      * Builds an instance of an IconPack that contains successfully-inflated icons
51      */
buildPack( @onNull StatusBarIconView statusBarIcon, @NonNull StatusBarIconView shelfIcon, @NonNull StatusBarIconView aodIcon, @Nullable StatusBarIconView centeredIcon, @Nullable IconPack source)52     public static IconPack buildPack(
53             @NonNull StatusBarIconView statusBarIcon,
54             @NonNull StatusBarIconView shelfIcon,
55             @NonNull StatusBarIconView aodIcon,
56             @Nullable StatusBarIconView centeredIcon,
57             @Nullable IconPack source) {
58         return new IconPack(true, statusBarIcon, shelfIcon, aodIcon, centeredIcon, source);
59     }
60 
IconPack( boolean areIconsAvailable, @Nullable StatusBarIconView statusBarIcon, @Nullable StatusBarIconView shelfIcon, @Nullable StatusBarIconView aodIcon, @Nullable StatusBarIconView centeredIcon, @Nullable IconPack source)61     private IconPack(
62             boolean areIconsAvailable,
63             @Nullable StatusBarIconView statusBarIcon,
64             @Nullable StatusBarIconView shelfIcon,
65             @Nullable StatusBarIconView aodIcon,
66             @Nullable StatusBarIconView centeredIcon,
67             @Nullable IconPack source) {
68         mAreIconsAvailable = areIconsAvailable;
69         mStatusBarIcon = statusBarIcon;
70         mShelfIcon = shelfIcon;
71         mCenteredIcon = centeredIcon;
72         mAodIcon = aodIcon;
73         if (source != null) {
74             mIsImportantConversation = source.mIsImportantConversation;
75         }
76     }
77 
78     /** The version of the notification icon that appears in the status bar. */
79     @Nullable
getStatusBarIcon()80     public StatusBarIconView getStatusBarIcon() {
81         return mStatusBarIcon;
82     }
83 
84     /**
85      * The version of the icon that appears in the "shelf" at the bottom of the notification shade.
86      * In general, this icon also appears somewhere on the notification and is "sucked" into the
87      * shelf as the scrolls beyond it.
88      */
89     @Nullable
getShelfIcon()90     public StatusBarIconView getShelfIcon() {
91         return mShelfIcon;
92     }
93 
94     @Nullable
getCenteredIcon()95     public StatusBarIconView getCenteredIcon() {
96         return mCenteredIcon;
97     }
98 
99     /** The version of the icon that's shown when pulsing (in AOD). */
100     @Nullable
getAodIcon()101     public StatusBarIconView getAodIcon() {
102         return mAodIcon;
103     }
104 
105     @Nullable
getSmallIconDescriptor()106     StatusBarIcon getSmallIconDescriptor() {
107         return mSmallIconDescriptor;
108     }
109 
setSmallIconDescriptor(@ullable StatusBarIcon smallIconDescriptor)110     void setSmallIconDescriptor(@Nullable StatusBarIcon smallIconDescriptor) {
111         mSmallIconDescriptor = smallIconDescriptor;
112     }
113 
114     @Nullable
getPeopleAvatarDescriptor()115     StatusBarIcon getPeopleAvatarDescriptor() {
116         return mPeopleAvatarDescriptor;
117     }
118 
setPeopleAvatarDescriptor(@ullable StatusBarIcon peopleAvatarDescriptor)119     void setPeopleAvatarDescriptor(@Nullable StatusBarIcon peopleAvatarDescriptor) {
120         mPeopleAvatarDescriptor = peopleAvatarDescriptor;
121     }
122 
isImportantConversation()123     boolean isImportantConversation() {
124         return mIsImportantConversation;
125     }
126 
setImportantConversation(boolean importantConversation)127     void setImportantConversation(boolean importantConversation) {
128         mIsImportantConversation = importantConversation;
129     }
130 
getAreIconsAvailable()131     public boolean getAreIconsAvailable() {
132         return mAreIconsAvailable;
133     }
134 }
135