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 35 @Nullable private StatusBarIcon mSmallIconDescriptor; 36 @Nullable private StatusBarIcon mAppIconDescriptor; 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, 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 IconPack source)52 public static IconPack buildPack( 53 @NonNull StatusBarIconView statusBarIcon, 54 @NonNull StatusBarIconView shelfIcon, 55 @NonNull StatusBarIconView aodIcon, 56 @Nullable IconPack source) { 57 return new IconPack(true, statusBarIcon, shelfIcon, aodIcon, source); 58 } 59 IconPack( boolean areIconsAvailable, @Nullable StatusBarIconView statusBarIcon, @Nullable StatusBarIconView shelfIcon, @Nullable StatusBarIconView aodIcon, @Nullable IconPack source)60 private IconPack( 61 boolean areIconsAvailable, 62 @Nullable StatusBarIconView statusBarIcon, 63 @Nullable StatusBarIconView shelfIcon, 64 @Nullable StatusBarIconView aodIcon, 65 @Nullable IconPack source) { 66 mAreIconsAvailable = areIconsAvailable; 67 mStatusBarIcon = statusBarIcon; 68 mShelfIcon = shelfIcon; 69 mAodIcon = aodIcon; 70 if (source != null) { 71 mIsImportantConversation = source.mIsImportantConversation; 72 } 73 } 74 75 /** The version of the notification icon that appears in the status bar. */ 76 @Nullable getStatusBarIcon()77 public StatusBarIconView getStatusBarIcon() { 78 return mStatusBarIcon; 79 } 80 81 /** 82 * The version of the icon that appears in the "shelf" at the bottom of the notification shade. 83 * In general, this icon also appears somewhere on the notification and is "sucked" into the 84 * shelf as the scrolls beyond it. 85 */ 86 @Nullable getShelfIcon()87 public StatusBarIconView getShelfIcon() { 88 return mShelfIcon; 89 } 90 91 /** The version of the icon that's shown when pulsing (in AOD). */ 92 @Nullable getAodIcon()93 public StatusBarIconView getAodIcon() { 94 return mAodIcon; 95 } 96 97 @Nullable getSmallIconDescriptor()98 StatusBarIcon getSmallIconDescriptor() { 99 return mSmallIconDescriptor; 100 } 101 setSmallIconDescriptor(@ullable StatusBarIcon smallIconDescriptor)102 void setSmallIconDescriptor(@Nullable StatusBarIcon smallIconDescriptor) { 103 mSmallIconDescriptor = smallIconDescriptor; 104 } 105 106 @Nullable getPeopleAvatarDescriptor()107 StatusBarIcon getPeopleAvatarDescriptor() { 108 return mPeopleAvatarDescriptor; 109 } 110 setPeopleAvatarDescriptor(@ullable StatusBarIcon peopleAvatarDescriptor)111 void setPeopleAvatarDescriptor(@Nullable StatusBarIcon peopleAvatarDescriptor) { 112 mPeopleAvatarDescriptor = peopleAvatarDescriptor; 113 } 114 115 @Nullable getAppIconDescriptor()116 StatusBarIcon getAppIconDescriptor() { 117 return mAppIconDescriptor; 118 } 119 setAppIconDescriptor(@ullable StatusBarIcon appIconDescriptor)120 void setAppIconDescriptor(@Nullable StatusBarIcon appIconDescriptor) { 121 mAppIconDescriptor = appIconDescriptor; 122 } 123 isImportantConversation()124 boolean isImportantConversation() { 125 return mIsImportantConversation; 126 } 127 setImportantConversation(boolean importantConversation)128 void setImportantConversation(boolean importantConversation) { 129 mIsImportantConversation = importantConversation; 130 } 131 getAreIconsAvailable()132 public boolean getAreIconsAvailable() { 133 return mAreIconsAvailable; 134 } 135 } 136