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 mStatusBarChipIcon; 33 @Nullable private final StatusBarIconView mShelfIcon; 34 @Nullable private final StatusBarIconView mAodIcon; 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, @Nullable StatusBarIconView statusBarChipIcon, @NonNull StatusBarIconView shelfIcon, @NonNull StatusBarIconView aodIcon, @Nullable IconPack source)52 public static IconPack buildPack( 53 @NonNull StatusBarIconView statusBarIcon, 54 @Nullable StatusBarIconView statusBarChipIcon, 55 @NonNull StatusBarIconView shelfIcon, 56 @NonNull StatusBarIconView aodIcon, 57 @Nullable IconPack source) { 58 return new IconPack(true, statusBarIcon, statusBarChipIcon, shelfIcon, aodIcon, source); 59 } 60 IconPack( boolean areIconsAvailable, @Nullable StatusBarIconView statusBarIcon, @Nullable StatusBarIconView statusBarChipIcon, @Nullable StatusBarIconView shelfIcon, @Nullable StatusBarIconView aodIcon, @Nullable IconPack source)61 private IconPack( 62 boolean areIconsAvailable, 63 @Nullable StatusBarIconView statusBarIcon, 64 @Nullable StatusBarIconView statusBarChipIcon, 65 @Nullable StatusBarIconView shelfIcon, 66 @Nullable StatusBarIconView aodIcon, 67 @Nullable IconPack source) { 68 mAreIconsAvailable = areIconsAvailable; 69 mStatusBarIcon = statusBarIcon; 70 mStatusBarChipIcon = statusBarChipIcon; 71 mShelfIcon = shelfIcon; 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 notification icon that appears inside a chip within the status bar. 86 * 87 * Separate from {@link #getStatusBarIcon()} so that we don't have to worry about detaching and 88 * re-attaching the same view when the chip appears and hides. 89 */ 90 @Nullable getStatusBarChipIcon()91 public StatusBarIconView getStatusBarChipIcon() { 92 return mStatusBarChipIcon; 93 } 94 95 /** 96 * The version of the icon that appears in the "shelf" at the bottom of the notification shade. 97 * In general, this icon also appears somewhere on the notification and is "sucked" into the 98 * shelf as the scrolls beyond it. 99 */ 100 @Nullable getShelfIcon()101 public StatusBarIconView getShelfIcon() { 102 return mShelfIcon; 103 } 104 105 /** The version of the icon that's shown when pulsing (in AOD). */ 106 @Nullable getAodIcon()107 public StatusBarIconView getAodIcon() { 108 return mAodIcon; 109 } 110 111 @Nullable getSmallIconDescriptor()112 StatusBarIcon getSmallIconDescriptor() { 113 return mSmallIconDescriptor; 114 } 115 setSmallIconDescriptor(@ullable StatusBarIcon smallIconDescriptor)116 void setSmallIconDescriptor(@Nullable StatusBarIcon smallIconDescriptor) { 117 mSmallIconDescriptor = smallIconDescriptor; 118 } 119 120 @Nullable getPeopleAvatarDescriptor()121 StatusBarIcon getPeopleAvatarDescriptor() { 122 return mPeopleAvatarDescriptor; 123 } 124 setPeopleAvatarDescriptor(@ullable StatusBarIcon peopleAvatarDescriptor)125 void setPeopleAvatarDescriptor(@Nullable StatusBarIcon peopleAvatarDescriptor) { 126 mPeopleAvatarDescriptor = peopleAvatarDescriptor; 127 } 128 isImportantConversation()129 boolean isImportantConversation() { 130 return mIsImportantConversation; 131 } 132 setImportantConversation(boolean importantConversation)133 void setImportantConversation(boolean importantConversation) { 134 mIsImportantConversation = importantConversation; 135 } 136 getAreIconsAvailable()137 public boolean getAreIconsAvailable() { 138 return mAreIconsAvailable; 139 } 140 } 141