Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 1 | package com.android.systemui.statusbar.phone; |
| 2 | |
| 3 | import android.content.Context; |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 4 | import android.content.res.Resources; |
| 5 | import android.graphics.Color; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 6 | import android.graphics.Rect; |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 7 | import android.view.LayoutInflater; |
| 8 | import android.view.View; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 9 | import android.view.ViewGroup; |
Selim Cinek | 0e8d77e | 2016-11-29 10:35:42 -0800 | [diff] [blame] | 10 | import android.widget.FrameLayout; |
Winson | c0d7058 | 2016-01-29 10:24:39 -0800 | [diff] [blame] | 11 | |
Beverly | 8fdb533 | 2019-02-04 14:29:49 -0500 | [diff] [blame] | 12 | import androidx.annotation.NonNull; |
| 13 | import androidx.collection.ArrayMap; |
| 14 | |
Selim Cinek | 72fc8db | 2017-06-06 18:07:47 -0700 | [diff] [blame] | 15 | import com.android.internal.statusbar.StatusBarIcon; |
Lucas Dupin | a291d19 | 2018-06-07 13:59:42 -0700 | [diff] [blame] | 16 | import com.android.internal.util.ContrastColorUtil; |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 17 | import com.android.settingslib.Utils; |
Selim Cinek | d03518c | 2018-03-15 12:13:51 -0700 | [diff] [blame] | 18 | import com.android.systemui.Dependency; |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 19 | import com.android.systemui.Interpolators; |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 20 | import com.android.systemui.R; |
Beverly | 1be62f4 | 2018-12-19 17:17:48 -0500 | [diff] [blame] | 21 | import com.android.systemui.plugins.DarkIconDispatcher; |
| 22 | import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver; |
Beverly | 8fdb533 | 2019-02-04 14:29:49 -0500 | [diff] [blame] | 23 | import com.android.systemui.plugins.statusbar.StatusBarStateController; |
Selim Cinek | 999230c | 2019-06-19 15:36:44 -0700 | [diff] [blame] | 24 | import com.android.systemui.statusbar.CrossFadeHelper; |
Lucas Dupin | 2040337 | 2019-02-14 19:59:18 -0800 | [diff] [blame] | 25 | import com.android.systemui.statusbar.NotificationMediaManager; |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 26 | import com.android.systemui.statusbar.NotificationShelf; |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 27 | import com.android.systemui.statusbar.StatusBarIconView; |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 28 | import com.android.systemui.statusbar.StatusBarState; |
Gus Prevas | 33619af | 2018-10-26 15:40:27 -0400 | [diff] [blame] | 29 | import com.android.systemui.statusbar.notification.NotificationEntryManager; |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 30 | import com.android.systemui.statusbar.notification.NotificationUtils; |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 31 | import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator; |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 32 | import com.android.systemui.statusbar.notification.collection.NotificationEntry; |
Gus Prevas | 33619af | 2018-10-26 15:40:27 -0400 | [diff] [blame] | 33 | import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 34 | |
| 35 | import java.util.ArrayList; |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 36 | import java.util.Objects; |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 37 | import java.util.function.Function; |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 38 | |
| 39 | /** |
| 40 | * A controller for the space in the status bar to the left of the system icons. This area is |
| 41 | * normally reserved for notifications. |
| 42 | */ |
Lucas Dupin | 7fc9dc1 | 2019-01-03 09:19:43 -0800 | [diff] [blame] | 43 | public class NotificationIconAreaController implements DarkReceiver, |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 44 | StatusBarStateController.StateListener, |
| 45 | NotificationWakeUpCoordinator.WakeUpListener { |
Gus Prevas | 33619af | 2018-10-26 15:40:27 -0400 | [diff] [blame] | 46 | |
Selim Cinek | da330ff | 2019-06-11 15:41:28 -0700 | [diff] [blame] | 47 | public static final String HIGH_PRIORITY = "high_priority"; |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 48 | private static final long AOD_ICONS_APPEAR_DURATION = 200; |
Gus Prevas | 33619af | 2018-10-26 15:40:27 -0400 | [diff] [blame] | 49 | |
Lucas Dupin | a291d19 | 2018-06-07 13:59:42 -0700 | [diff] [blame] | 50 | private final ContrastColorUtil mContrastColorUtil; |
Selim Cinek | d03518c | 2018-03-15 12:13:51 -0700 | [diff] [blame] | 51 | private final NotificationEntryManager mEntryManager; |
| 52 | private final Runnable mUpdateStatusBarIcons = this::updateStatusBarIcons; |
Lucas Dupin | 7fc9dc1 | 2019-01-03 09:19:43 -0800 | [diff] [blame] | 53 | private final StatusBarStateController mStatusBarStateController; |
Lucas Dupin | 2040337 | 2019-02-14 19:59:18 -0800 | [diff] [blame] | 54 | private final NotificationMediaManager mMediaManager; |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 55 | private final NotificationWakeUpCoordinator mWakeUpCoordinator; |
| 56 | private final KeyguardBypassController mBypassController; |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 57 | private final DozeParameters mDozeParameters; |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 58 | |
| 59 | private int mIconSize; |
| 60 | private int mIconHPadding; |
| 61 | private int mIconTint = Color.WHITE; |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 62 | private int mCenteredIconTint = Color.WHITE; |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 63 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 64 | private StatusBar mStatusBar; |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 65 | protected View mNotificationIconArea; |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 66 | private NotificationIconContainer mNotificationIcons; |
Selim Cinek | 5b5beb01 | 2016-11-08 18:11:58 -0800 | [diff] [blame] | 67 | private NotificationIconContainer mShelfIcons; |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 68 | protected View mCenteredIconArea; |
| 69 | private NotificationIconContainer mCenteredIcon; |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 70 | private NotificationIconContainer mAodIcons; |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 71 | private StatusBarIconView mCenteredIconView; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 72 | private final Rect mTintArea = new Rect(); |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 73 | private ViewGroup mNotificationScrollLayout; |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 74 | private Context mContext; |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 75 | private int mAodIconAppearTranslation; |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 76 | |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 77 | private boolean mAnimationsEnabled; |
| 78 | private int mAodIconTint; |
| 79 | private boolean mFullyHidden; |
Selim Cinek | 999230c | 2019-06-19 15:36:44 -0700 | [diff] [blame] | 80 | private boolean mAodIconsVisible; |
Selim Cinek | 65c96f2 | 2019-07-25 20:09:04 -0700 | [diff] [blame] | 81 | private boolean mIsPulsing; |
Lucas Dupin | 23a8d3b | 2018-10-08 20:57:35 -0700 | [diff] [blame] | 82 | |
Lucas Dupin | 7fc9dc1 | 2019-01-03 09:19:43 -0800 | [diff] [blame] | 83 | public NotificationIconAreaController(Context context, StatusBar statusBar, |
Julia Reynolds | 12ad7ca | 2019-01-28 09:29:16 -0500 | [diff] [blame] | 84 | StatusBarStateController statusBarStateController, |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 85 | NotificationWakeUpCoordinator wakeUpCoordinator, |
| 86 | KeyguardBypassController keyguardBypassController, |
Lucas Dupin | 2040337 | 2019-02-14 19:59:18 -0800 | [diff] [blame] | 87 | NotificationMediaManager notificationMediaManager) { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 88 | mStatusBar = statusBar; |
Lucas Dupin | a291d19 | 2018-06-07 13:59:42 -0700 | [diff] [blame] | 89 | mContrastColorUtil = ContrastColorUtil.getInstance(context); |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 90 | mContext = context; |
Selim Cinek | d03518c | 2018-03-15 12:13:51 -0700 | [diff] [blame] | 91 | mEntryManager = Dependency.get(NotificationEntryManager.class); |
Lucas Dupin | 7fc9dc1 | 2019-01-03 09:19:43 -0800 | [diff] [blame] | 92 | mStatusBarStateController = statusBarStateController; |
| 93 | mStatusBarStateController.addCallback(this); |
Lucas Dupin | 2040337 | 2019-02-14 19:59:18 -0800 | [diff] [blame] | 94 | mMediaManager = notificationMediaManager; |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 95 | mDozeParameters = DozeParameters.getInstance(mContext); |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 96 | mWakeUpCoordinator = wakeUpCoordinator; |
| 97 | wakeUpCoordinator.addListener(this); |
| 98 | mBypassController = keyguardBypassController; |
Gus Prevas | 33619af | 2018-10-26 15:40:27 -0400 | [diff] [blame] | 99 | |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 100 | initializeNotificationAreaViews(context); |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 101 | reloadAodColor(); |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 102 | } |
| 103 | |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 104 | protected View inflateIconArea(LayoutInflater inflater) { |
| 105 | return inflater.inflate(R.layout.notification_icon_area, null); |
| 106 | } |
| 107 | |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 108 | /** |
| 109 | * Initializes the views that will represent the notification area. |
| 110 | */ |
| 111 | protected void initializeNotificationAreaViews(Context context) { |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 112 | reloadDimens(context); |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 113 | |
| 114 | LayoutInflater layoutInflater = LayoutInflater.from(context); |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 115 | mNotificationIconArea = inflateIconArea(layoutInflater); |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 116 | mNotificationIcons = mNotificationIconArea.findViewById(R.id.notificationIcons); |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 117 | |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 118 | mNotificationScrollLayout = mStatusBar.getNotificationScrollLayout(); |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 119 | |
| 120 | mCenteredIconArea = layoutInflater.inflate(R.layout.center_icon_area, null); |
| 121 | mCenteredIcon = mCenteredIconArea.findViewById(R.id.centeredIcon); |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 122 | |
| 123 | initAodIcons(); |
| 124 | } |
| 125 | |
| 126 | public void initAodIcons() { |
| 127 | boolean changed = mAodIcons != null; |
| 128 | if (changed) { |
| 129 | mAodIcons.setAnimationsEnabled(false); |
| 130 | mAodIcons.removeAllViews(); |
| 131 | } |
| 132 | mAodIcons = mStatusBar.getStatusBarWindow().findViewById( |
| 133 | R.id.clock_notification_icon_container); |
| 134 | mAodIcons.setOnLockScreen(true); |
Selim Cinek | 999230c | 2019-06-19 15:36:44 -0700 | [diff] [blame] | 135 | updateAodIconsVisibility(false /* animate */); |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 136 | updateAnimations(); |
| 137 | if (changed) { |
Selim Cinek | 999230c | 2019-06-19 15:36:44 -0700 | [diff] [blame] | 138 | updateAodNotificationIcons(); |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 139 | } |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | public void setupShelf(NotificationShelf shelf) { |
Selim Cinek | 5b5beb01 | 2016-11-08 18:11:58 -0800 | [diff] [blame] | 143 | mShelfIcons = shelf.getShelfIcons(); |
Selim Cinek | 49014f8 | 2016-11-04 14:55:30 -0700 | [diff] [blame] | 144 | shelf.setCollapsedIcons(mNotificationIcons); |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 145 | } |
| 146 | |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 147 | public void onDensityOrFontScaleChanged(Context context) { |
| 148 | reloadDimens(context); |
Selim Cinek | 0e8d77e | 2016-11-29 10:35:42 -0800 | [diff] [blame] | 149 | final FrameLayout.LayoutParams params = generateIconLayoutParams(); |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 150 | for (int i = 0; i < mNotificationIcons.getChildCount(); i++) { |
| 151 | View child = mNotificationIcons.getChildAt(i); |
| 152 | child.setLayoutParams(params); |
Selim Cinek | 9ef119c | 2017-03-01 15:13:36 -0800 | [diff] [blame] | 153 | } |
| 154 | for (int i = 0; i < mShelfIcons.getChildCount(); i++) { |
| 155 | View child = mShelfIcons.getChildAt(i); |
Selim Cinek | 0e8d77e | 2016-11-29 10:35:42 -0800 | [diff] [blame] | 156 | child.setLayoutParams(params); |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 157 | } |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 158 | for (int i = 0; i < mCenteredIcon.getChildCount(); i++) { |
| 159 | View child = mCenteredIcon.getChildAt(i); |
| 160 | child.setLayoutParams(params); |
| 161 | } |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 162 | for (int i = 0; i < mAodIcons.getChildCount(); i++) { |
| 163 | View child = mAodIcons.getChildAt(i); |
| 164 | child.setLayoutParams(params); |
| 165 | } |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | @NonNull |
Selim Cinek | 0e8d77e | 2016-11-29 10:35:42 -0800 | [diff] [blame] | 169 | private FrameLayout.LayoutParams generateIconLayoutParams() { |
| 170 | return new FrameLayout.LayoutParams( |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 171 | mIconSize + 2 * mIconHPadding, getHeight()); |
| 172 | } |
| 173 | |
| 174 | private void reloadDimens(Context context) { |
| 175 | Resources res = context.getResources(); |
| 176 | mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size); |
| 177 | mIconHPadding = res.getDimensionPixelSize(R.dimen.status_bar_icon_padding); |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 178 | mAodIconAppearTranslation = res.getDimensionPixelSize( |
| 179 | R.dimen.shelf_appear_translation); |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 180 | } |
| 181 | |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 182 | /** |
| 183 | * Returns the view that represents the notification area. |
| 184 | */ |
| 185 | public View getNotificationInnerAreaView() { |
| 186 | return mNotificationIconArea; |
| 187 | } |
| 188 | |
| 189 | /** |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 190 | * Returns the view that represents the centered notification area. |
| 191 | */ |
| 192 | public View getCenteredNotificationAreaView() { |
| 193 | return mCenteredIconArea; |
| 194 | } |
| 195 | |
| 196 | /** |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 197 | * See {@link com.android.systemui.statusbar.policy.DarkIconDispatcher#setIconsDarkArea}. |
| 198 | * Sets the color that should be used to tint any icons in the notification area. |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 199 | * |
| 200 | * @param tintArea the area in which to tint the icons, specified in screen coordinates |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 201 | * @param darkIntensity |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 202 | */ |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 203 | public void onDarkChanged(Rect tintArea, float darkIntensity, int iconTint) { |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 204 | if (tintArea == null) { |
| 205 | mTintArea.setEmpty(); |
| 206 | } else { |
| 207 | mTintArea.set(tintArea); |
| 208 | } |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 209 | |
Evan Laird | dbeefe3 | 2018-04-03 16:52:41 -0400 | [diff] [blame] | 210 | if (mNotificationIconArea != null) { |
| 211 | if (DarkIconDispatcher.isInArea(tintArea, mNotificationIconArea)) { |
| 212 | mIconTint = iconTint; |
| 213 | } |
| 214 | } else { |
| 215 | mIconTint = iconTint; |
| 216 | } |
| 217 | |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 218 | if (mCenteredIconArea != null) { |
| 219 | if (DarkIconDispatcher.isInArea(tintArea, mCenteredIconArea)) { |
| 220 | mCenteredIconTint = iconTint; |
| 221 | } |
| 222 | } else { |
| 223 | mCenteredIconTint = iconTint; |
| 224 | } |
| 225 | |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 226 | applyNotificationIconsTint(); |
| 227 | } |
| 228 | |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 229 | protected int getHeight() { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 230 | return mStatusBar.getStatusBarHeight(); |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 231 | } |
| 232 | |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 233 | protected boolean shouldShowNotificationIcon(NotificationEntry entry, |
Selim Cinek | 31ebb40 | 2019-07-19 18:29:56 -0700 | [diff] [blame] | 234 | boolean showAmbient, boolean hideDismissed, |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 235 | boolean hideRepliedMessages, boolean hideCurrentMedia, boolean hideCenteredIcon, |
Beverly | fd3b1dca | 2019-06-25 16:21:00 -0400 | [diff] [blame] | 236 | boolean hidePulsing, boolean onlyShowCenteredIcon) { |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 237 | |
Beverly | fd3b1dca | 2019-06-25 16:21:00 -0400 | [diff] [blame] | 238 | final boolean isCenteredNotificationIcon = mCenteredIconView != null |
| 239 | && entry.centeredIcon != null |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 240 | && Objects.equals(entry.centeredIcon, mCenteredIconView); |
Beverly | fd3b1dca | 2019-06-25 16:21:00 -0400 | [diff] [blame] | 241 | if (onlyShowCenteredIcon) { |
| 242 | return isCenteredNotificationIcon; |
| 243 | } |
Selim Cinek | e3c6e46 | 2019-06-24 19:37:06 -0700 | [diff] [blame] | 244 | if (hideCenteredIcon && isCenteredNotificationIcon && !entry.isRowHeadsUp()) { |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 245 | return false; |
| 246 | } |
Selim Cinek | d03518c | 2018-03-15 12:13:51 -0700 | [diff] [blame] | 247 | if (mEntryManager.getNotificationData().isAmbient(entry.key) && !showAmbient) { |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 248 | return false; |
| 249 | } |
Lucas Dupin | 2040337 | 2019-02-14 19:59:18 -0800 | [diff] [blame] | 250 | if (hideCurrentMedia && entry.key.equals(mMediaManager.getMediaNotificationKey())) { |
| 251 | return false; |
| 252 | } |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 253 | if (!entry.isTopLevelChild()) { |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 254 | return false; |
| 255 | } |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 256 | if (entry.getRow().getVisibility() == View.GONE) { |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 257 | return false; |
| 258 | } |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 259 | if (entry.isRowDismissed() && hideDismissed) { |
Selim Cinek | d03518c | 2018-03-15 12:13:51 -0700 | [diff] [blame] | 260 | return false; |
| 261 | } |
Selim Cinek | b0dc61b | 2018-05-22 18:49:36 -0700 | [diff] [blame] | 262 | if (hideRepliedMessages && entry.isLastMessageFromReply()) { |
| 263 | return false; |
| 264 | } |
Julia Reynolds | c861a3d | 2018-02-15 10:34:49 -0500 | [diff] [blame] | 265 | // showAmbient == show in shade but not shelf |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 266 | if (!showAmbient && entry.shouldSuppressStatusBar()) { |
Julia Reynolds | c861a3d | 2018-02-15 10:34:49 -0500 | [diff] [blame] | 267 | return false; |
| 268 | } |
Selim Cinek | 65c96f2 | 2019-07-25 20:09:04 -0700 | [diff] [blame] | 269 | if (hidePulsing && entry.showingPulsing() |
| 270 | && (!mWakeUpCoordinator.getNotificationsFullyHidden() |
| 271 | || !entry.isPulseSuppressed())) { |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 272 | return false; |
| 273 | } |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 274 | return true; |
| 275 | } |
| 276 | |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 277 | /** |
| 278 | * Updates the notifications with the given list of notifications to display. |
| 279 | */ |
Selim Cinek | d03518c | 2018-03-15 12:13:51 -0700 | [diff] [blame] | 280 | public void updateNotificationIcons() { |
Selim Cinek | d03518c | 2018-03-15 12:13:51 -0700 | [diff] [blame] | 281 | updateStatusBarIcons(); |
Selim Cinek | 9bfc7a5 | 2018-06-11 16:09:00 -0700 | [diff] [blame] | 282 | updateShelfIcons(); |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 283 | updateCenterIcon(); |
Selim Cinek | 999230c | 2019-06-19 15:36:44 -0700 | [diff] [blame] | 284 | updateAodNotificationIcons(); |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 285 | |
| 286 | applyNotificationIconsTint(); |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 287 | } |
| 288 | |
Selim Cinek | 9bfc7a5 | 2018-06-11 16:09:00 -0700 | [diff] [blame] | 289 | private void updateShelfIcons() { |
| 290 | updateIconsForLayout(entry -> entry.expandedIcon, mShelfIcons, |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 291 | true /* showAmbient */, |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 292 | false /* hideDismissed */, |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 293 | false /* hideRepliedMessages */, |
| 294 | false /* hideCurrentMedia */, |
Beverly | fd3b1dca | 2019-06-25 16:21:00 -0400 | [diff] [blame] | 295 | false /* hide centered icon */, |
| 296 | false /* hidePulsing */, |
| 297 | false /* onlyShowCenteredIcon */); |
Selim Cinek | 9bfc7a5 | 2018-06-11 16:09:00 -0700 | [diff] [blame] | 298 | } |
| 299 | |
Selim Cinek | b0dc61b | 2018-05-22 18:49:36 -0700 | [diff] [blame] | 300 | public void updateStatusBarIcons() { |
Selim Cinek | d03518c | 2018-03-15 12:13:51 -0700 | [diff] [blame] | 301 | updateIconsForLayout(entry -> entry.icon, mNotificationIcons, |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 302 | false /* showAmbient */, |
Gus Prevas | dddef39 | 2018-11-02 15:41:43 -0400 | [diff] [blame] | 303 | true /* hideDismissed */, |
Lucas Dupin | 2040337 | 2019-02-14 19:59:18 -0800 | [diff] [blame] | 304 | true /* hideRepliedMessages */, |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 305 | false /* hideCurrentMedia */, |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 306 | true /* hide centered icon */, |
Beverly | fd3b1dca | 2019-06-25 16:21:00 -0400 | [diff] [blame] | 307 | false /* hidePulsing */, |
| 308 | false /* onlyShowCenteredIcon */); |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | private void updateCenterIcon() { |
| 312 | updateIconsForLayout(entry -> entry.centeredIcon, mCenteredIcon, |
| 313 | false /* showAmbient */, |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 314 | false /* hideDismissed */, |
| 315 | false /* hideRepliedMessages */, |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 316 | false /* hideCurrentMedia */, |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 317 | false /* hide centered icon */, |
Beverly | fd3b1dca | 2019-06-25 16:21:00 -0400 | [diff] [blame] | 318 | false /* hidePulsing */, |
| 319 | true/* onlyShowCenteredIcon */); |
Selim Cinek | d03518c | 2018-03-15 12:13:51 -0700 | [diff] [blame] | 320 | } |
| 321 | |
Selim Cinek | 999230c | 2019-06-19 15:36:44 -0700 | [diff] [blame] | 322 | public void updateAodNotificationIcons() { |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 323 | updateIconsForLayout(entry -> entry.aodIcon, mAodIcons, |
| 324 | false /* showAmbient */, |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 325 | true /* hideDismissed */, |
| 326 | true /* hideRepliedMessages */, |
| 327 | true /* hideCurrentMedia */, |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 328 | true /* hide centered icon */, |
Beverly | fd3b1dca | 2019-06-25 16:21:00 -0400 | [diff] [blame] | 329 | mBypassController.getBypassEnabled() /* hidePulsing */, |
| 330 | false /* onlyShowCenteredIcon */); |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 331 | } |
| 332 | |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 333 | /** |
| 334 | * Updates the notification icons for a host layout. This will ensure that the notification |
| 335 | * host layout will have the same icons like the ones in here. |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 336 | * @param function A function to look up an icon view based on an entry |
| 337 | * @param hostLayout which layout should be updated |
Selim Cinek | 17e1b69 | 2016-12-02 18:19:11 -0800 | [diff] [blame] | 338 | * @param showAmbient should ambient notification icons be shown |
Selim Cinek | d03518c | 2018-03-15 12:13:51 -0700 | [diff] [blame] | 339 | * @param hideDismissed should dismissed icons be hidden |
Selim Cinek | b0dc61b | 2018-05-22 18:49:36 -0700 | [diff] [blame] | 340 | * @param hideRepliedMessages should messages that have been replied to be hidden |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 341 | * @param hidePulsing should pulsing notifications be hidden |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 342 | */ |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 343 | private void updateIconsForLayout(Function<NotificationEntry, StatusBarIconView> function, |
Selim Cinek | 31ebb40 | 2019-07-19 18:29:56 -0700 | [diff] [blame] | 344 | NotificationIconContainer hostLayout, boolean showAmbient, |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 345 | boolean hideDismissed, boolean hideRepliedMessages, boolean hideCurrentMedia, |
Beverly | fd3b1dca | 2019-06-25 16:21:00 -0400 | [diff] [blame] | 346 | boolean hideCenteredIcon, boolean hidePulsing, boolean onlyShowCenteredIcon) { |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 347 | ArrayList<StatusBarIconView> toShow = new ArrayList<>( |
| 348 | mNotificationScrollLayout.getChildCount()); |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 349 | |
| 350 | // Filter out ambient notifications and notification children. |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 351 | for (int i = 0; i < mNotificationScrollLayout.getChildCount(); i++) { |
| 352 | View view = mNotificationScrollLayout.getChildAt(i); |
| 353 | if (view instanceof ExpandableNotificationRow) { |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 354 | NotificationEntry ent = ((ExpandableNotificationRow) view).getEntry(); |
Selim Cinek | 31ebb40 | 2019-07-19 18:29:56 -0700 | [diff] [blame] | 355 | if (shouldShowNotificationIcon(ent, showAmbient, hideDismissed, |
Beverly | fd3b1dca | 2019-06-25 16:21:00 -0400 | [diff] [blame] | 356 | hideRepliedMessages, hideCurrentMedia, hideCenteredIcon, hidePulsing, |
| 357 | onlyShowCenteredIcon)) { |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 358 | StatusBarIconView iconView = function.apply(ent); |
| 359 | if (iconView != null) { |
| 360 | toShow.add(iconView); |
| 361 | } |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 362 | } |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 363 | } |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 364 | } |
| 365 | |
Selim Cinek | 72fc8db | 2017-06-06 18:07:47 -0700 | [diff] [blame] | 366 | // In case we are changing the suppression of a group, the replacement shouldn't flicker |
| 367 | // and it should just be replaced instead. We therefore look for notifications that were |
| 368 | // just replaced by the child or vice-versa to suppress this. |
Selim Cinek | 49014f8 | 2016-11-04 14:55:30 -0700 | [diff] [blame] | 369 | |
Selim Cinek | 72fc8db | 2017-06-06 18:07:47 -0700 | [diff] [blame] | 370 | ArrayMap<String, ArrayList<StatusBarIcon>> replacingIcons = new ArrayMap<>(); |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 371 | ArrayList<View> toRemove = new ArrayList<>(); |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 372 | for (int i = 0; i < hostLayout.getChildCount(); i++) { |
| 373 | View child = hostLayout.getChildAt(i); |
Selim Cinek | 72fc8db | 2017-06-06 18:07:47 -0700 | [diff] [blame] | 374 | if (!(child instanceof StatusBarIconView)) { |
| 375 | continue; |
| 376 | } |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 377 | if (!toShow.contains(child)) { |
Selim Cinek | 72fc8db | 2017-06-06 18:07:47 -0700 | [diff] [blame] | 378 | boolean iconWasReplaced = false; |
| 379 | StatusBarIconView removedIcon = (StatusBarIconView) child; |
| 380 | String removedGroupKey = removedIcon.getNotification().getGroupKey(); |
| 381 | for (int j = 0; j < toShow.size(); j++) { |
| 382 | StatusBarIconView candidate = toShow.get(j); |
| 383 | if (candidate.getSourceIcon().sameAs((removedIcon.getSourceIcon())) |
| 384 | && candidate.getNotification().getGroupKey().equals(removedGroupKey)) { |
| 385 | if (!iconWasReplaced) { |
| 386 | iconWasReplaced = true; |
| 387 | } else { |
| 388 | iconWasReplaced = false; |
| 389 | break; |
| 390 | } |
| 391 | } |
| 392 | } |
| 393 | if (iconWasReplaced) { |
| 394 | ArrayList<StatusBarIcon> statusBarIcons = replacingIcons.get(removedGroupKey); |
| 395 | if (statusBarIcons == null) { |
| 396 | statusBarIcons = new ArrayList<>(); |
| 397 | replacingIcons.put(removedGroupKey, statusBarIcons); |
| 398 | } |
| 399 | statusBarIcons.add(removedIcon.getStatusBarIcon()); |
| 400 | } |
| 401 | toRemove.add(removedIcon); |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 402 | } |
| 403 | } |
Selim Cinek | 72fc8db | 2017-06-06 18:07:47 -0700 | [diff] [blame] | 404 | // removing all duplicates |
| 405 | ArrayList<String> duplicates = new ArrayList<>(); |
| 406 | for (String key : replacingIcons.keySet()) { |
| 407 | ArrayList<StatusBarIcon> statusBarIcons = replacingIcons.get(key); |
| 408 | if (statusBarIcons.size() != 1) { |
| 409 | duplicates.add(key); |
| 410 | } |
| 411 | } |
| 412 | replacingIcons.removeAll(duplicates); |
| 413 | hostLayout.setReplacingIcons(replacingIcons); |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 414 | |
| 415 | final int toRemoveCount = toRemove.size(); |
| 416 | for (int i = 0; i < toRemoveCount; i++) { |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 417 | hostLayout.removeView(toRemove.get(i)); |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 418 | } |
| 419 | |
Selim Cinek | 0e8d77e | 2016-11-29 10:35:42 -0800 | [diff] [blame] | 420 | final FrameLayout.LayoutParams params = generateIconLayoutParams(); |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 421 | for (int i = 0; i < toShow.size(); i++) { |
Selim Cinek | d03518c | 2018-03-15 12:13:51 -0700 | [diff] [blame] | 422 | StatusBarIconView v = toShow.get(i); |
Selim Cinek | 5b5beb01 | 2016-11-08 18:11:58 -0800 | [diff] [blame] | 423 | // The view might still be transiently added if it was just removed and added again |
| 424 | hostLayout.removeTransientView(v); |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 425 | if (v.getParent() == null) { |
Selim Cinek | d03518c | 2018-03-15 12:13:51 -0700 | [diff] [blame] | 426 | if (hideDismissed) { |
| 427 | v.setOnDismissListener(mUpdateStatusBarIcons); |
| 428 | } |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 429 | hostLayout.addView(v, i, params); |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 430 | } |
| 431 | } |
| 432 | |
Selim Cinek | 5b5beb01 | 2016-11-08 18:11:58 -0800 | [diff] [blame] | 433 | hostLayout.setChangingViewPositions(true); |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 434 | // Re-sort notification icons |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 435 | final int childCount = hostLayout.getChildCount(); |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 436 | for (int i = 0; i < childCount; i++) { |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 437 | View actual = hostLayout.getChildAt(i); |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 438 | StatusBarIconView expected = toShow.get(i); |
| 439 | if (actual == expected) { |
| 440 | continue; |
| 441 | } |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 442 | hostLayout.removeView(expected); |
| 443 | hostLayout.addView(expected, i); |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 444 | } |
Selim Cinek | 5b5beb01 | 2016-11-08 18:11:58 -0800 | [diff] [blame] | 445 | hostLayout.setChangingViewPositions(false); |
Selim Cinek | 72fc8db | 2017-06-06 18:07:47 -0700 | [diff] [blame] | 446 | hostLayout.setReplacingIcons(null); |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 447 | } |
| 448 | |
| 449 | /** |
| 450 | * Applies {@link #mIconTint} to the notification icons. |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 451 | * Applies {@link #mCenteredIconTint} to the center notification icon. |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 452 | */ |
| 453 | private void applyNotificationIconsTint() { |
| 454 | for (int i = 0; i < mNotificationIcons.getChildCount(); i++) { |
Selim Cinek | 887da3c | 2017-10-06 13:37:32 -0700 | [diff] [blame] | 455 | final StatusBarIconView iv = (StatusBarIconView) mNotificationIcons.getChildAt(i); |
| 456 | if (iv.getWidth() != 0) { |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 457 | updateTintForIcon(iv, mIconTint); |
Selim Cinek | 887da3c | 2017-10-06 13:37:32 -0700 | [diff] [blame] | 458 | } else { |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 459 | iv.executeOnLayout(() -> updateTintForIcon(iv, mIconTint)); |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | for (int i = 0; i < mCenteredIcon.getChildCount(); i++) { |
| 464 | final StatusBarIconView iv = (StatusBarIconView) mCenteredIcon.getChildAt(i); |
| 465 | if (iv.getWidth() != 0) { |
| 466 | updateTintForIcon(iv, mCenteredIconTint); |
| 467 | } else { |
| 468 | iv.executeOnLayout(() -> updateTintForIcon(iv, mCenteredIconTint)); |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 469 | } |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 470 | } |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 471 | |
| 472 | updateAodIconColors(); |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 473 | } |
Lucas Dupin | 987f193 | 2017-05-13 21:02:52 -0700 | [diff] [blame] | 474 | |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 475 | private void updateTintForIcon(StatusBarIconView v, int tint) { |
Selim Cinek | 887da3c | 2017-10-06 13:37:32 -0700 | [diff] [blame] | 476 | boolean isPreL = Boolean.TRUE.equals(v.getTag(R.id.icon_is_pre_L)); |
| 477 | int color = StatusBarIconView.NO_COLOR; |
Lucas Dupin | a291d19 | 2018-06-07 13:59:42 -0700 | [diff] [blame] | 478 | boolean colorize = !isPreL || NotificationUtils.isGrayscale(v, mContrastColorUtil); |
Selim Cinek | 887da3c | 2017-10-06 13:37:32 -0700 | [diff] [blame] | 479 | if (colorize) { |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 480 | color = DarkIconDispatcher.getTint(mTintArea, v, tint); |
Selim Cinek | 887da3c | 2017-10-06 13:37:32 -0700 | [diff] [blame] | 481 | } |
| 482 | v.setStaticDrawableColor(color); |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 483 | v.setDecorColor(tint); |
Selim Cinek | 887da3c | 2017-10-06 13:37:32 -0700 | [diff] [blame] | 484 | } |
| 485 | |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 486 | /** |
| 487 | * Shows the icon view given in the center. |
| 488 | */ |
| 489 | public void showIconCentered(NotificationEntry entry) { |
| 490 | StatusBarIconView icon = entry == null ? null : entry.centeredIcon; |
| 491 | if (!Objects.equals(mCenteredIconView, icon)) { |
| 492 | mCenteredIconView = icon; |
| 493 | updateNotificationIcons(); |
| 494 | } |
Lucas Dupin | 987f193 | 2017-05-13 21:02:52 -0700 | [diff] [blame] | 495 | } |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 496 | |
Selim Cinek | 332c23f | 2018-03-16 17:37:50 -0700 | [diff] [blame] | 497 | public void showIconIsolated(StatusBarIconView icon, boolean animated) { |
| 498 | mNotificationIcons.showIconIsolated(icon, animated); |
| 499 | } |
| 500 | |
| 501 | public void setIsolatedIconLocation(Rect iconDrawingRect, boolean requireStateUpdate) { |
| 502 | mNotificationIcons.setIsolatedIconLocation(iconDrawingRect, requireStateUpdate); |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 503 | } |
Lucas Dupin | 23a8d3b | 2018-10-08 20:57:35 -0700 | [diff] [blame] | 504 | |
Lucas Dupin | 7fc9dc1 | 2019-01-03 09:19:43 -0800 | [diff] [blame] | 505 | @Override |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 506 | public void onDozingChanged(boolean isDozing) { |
| 507 | boolean animate = mDozeParameters.getAlwaysOn() |
| 508 | && !mDozeParameters.getDisplayNeedsBlanking(); |
| 509 | mAodIcons.setDozing(isDozing, animate, 0); |
| 510 | } |
| 511 | |
| 512 | public void setAnimationsEnabled(boolean enabled) { |
| 513 | mAnimationsEnabled = enabled; |
| 514 | updateAnimations(); |
| 515 | } |
| 516 | |
| 517 | @Override |
| 518 | public void onStateChanged(int newState) { |
Selim Cinek | 999230c | 2019-06-19 15:36:44 -0700 | [diff] [blame] | 519 | updateAodIconsVisibility(false /* animate */); |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 520 | updateAnimations(); |
| 521 | } |
| 522 | |
| 523 | private void updateAnimations() { |
| 524 | boolean inShade = mStatusBarStateController.getState() == StatusBarState.SHADE; |
| 525 | mAodIcons.setAnimationsEnabled(mAnimationsEnabled && !inShade); |
| 526 | mCenteredIcon.setAnimationsEnabled(mAnimationsEnabled && inShade); |
| 527 | mNotificationIcons.setAnimationsEnabled(mAnimationsEnabled && inShade); |
| 528 | } |
| 529 | |
| 530 | public void onThemeChanged() { |
| 531 | reloadAodColor(); |
| 532 | updateAodIconColors(); |
| 533 | } |
| 534 | |
| 535 | public void appearAodIcons() { |
| 536 | DozeParameters dozeParameters = DozeParameters.getInstance(mContext); |
| 537 | if (dozeParameters.shouldControlScreenOff()) { |
| 538 | mAodIcons.setTranslationY(-mAodIconAppearTranslation); |
| 539 | mAodIcons.setAlpha(0); |
| 540 | mAodIcons.animate() |
| 541 | .setInterpolator(Interpolators.DECELERATE_QUINT) |
| 542 | .translationY(0) |
| 543 | .setDuration(AOD_ICONS_APPEAR_DURATION) |
| 544 | .start(); |
| 545 | mAodIcons.animate() |
| 546 | .alpha(1) |
| 547 | .setInterpolator(Interpolators.LINEAR) |
| 548 | .setDuration(AOD_ICONS_APPEAR_DURATION) |
| 549 | .start(); |
Lucas Dupin | 7fc9dc1 | 2019-01-03 09:19:43 -0800 | [diff] [blame] | 550 | } |
Lucas Dupin | 23a8d3b | 2018-10-08 20:57:35 -0700 | [diff] [blame] | 551 | } |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 552 | |
| 553 | private void reloadAodColor() { |
| 554 | mAodIconTint = Utils.getColorAttrDefaultColor(mContext, |
| 555 | R.attr.wallpaperTextColor); |
| 556 | } |
| 557 | private void updateAodIconColors() { |
| 558 | for (int i = 0; i < mAodIcons.getChildCount(); i++) { |
| 559 | final StatusBarIconView iv = (StatusBarIconView) mAodIcons.getChildAt(i); |
| 560 | if (iv.getWidth() != 0) { |
| 561 | updateTintForIcon(iv, mAodIconTint); |
| 562 | } else { |
| 563 | iv.executeOnLayout(() -> updateTintForIcon(iv, mAodIconTint)); |
| 564 | } |
| 565 | } |
| 566 | } |
| 567 | |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 568 | @Override |
| 569 | public void onFullyHiddenChanged(boolean fullyHidden) { |
Selim Cinek | 999230c | 2019-06-19 15:36:44 -0700 | [diff] [blame] | 570 | boolean animate = true; |
| 571 | if (!mBypassController.getBypassEnabled()) { |
| 572 | animate = mDozeParameters.getAlwaysOn() && !mDozeParameters.getDisplayNeedsBlanking(); |
| 573 | // We only want the appear animations to happen when the notifications get fully hidden, |
| 574 | // since otherwise the unhide animation overlaps |
| 575 | animate &= fullyHidden; |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 576 | } |
Selim Cinek | 999230c | 2019-06-19 15:36:44 -0700 | [diff] [blame] | 577 | updateAodIconsVisibility(animate); |
| 578 | updateAodNotificationIcons(); |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 579 | } |
| 580 | |
| 581 | @Override |
| 582 | public void onPulseExpansionChanged(boolean expandingChanged) { |
| 583 | if (expandingChanged) { |
Selim Cinek | 999230c | 2019-06-19 15:36:44 -0700 | [diff] [blame] | 584 | updateAodIconsVisibility(true /* animate */); |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 585 | } |
| 586 | } |
| 587 | |
Selim Cinek | 999230c | 2019-06-19 15:36:44 -0700 | [diff] [blame] | 588 | private void updateAodIconsVisibility(boolean animate) { |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 589 | boolean visible = mBypassController.getBypassEnabled() |
| 590 | || mWakeUpCoordinator.getNotificationsFullyHidden(); |
| 591 | if (mStatusBarStateController.getState() != StatusBarState.KEYGUARD) { |
| 592 | visible = false; |
| 593 | } |
| 594 | if (visible && mWakeUpCoordinator.isPulseExpanding()) { |
| 595 | visible = false; |
| 596 | } |
Selim Cinek | 999230c | 2019-06-19 15:36:44 -0700 | [diff] [blame] | 597 | if (mAodIconsVisible != visible) { |
| 598 | mAodIconsVisible = visible; |
| 599 | mAodIcons.animate().cancel(); |
| 600 | if (animate) { |
| 601 | boolean wasFullyInvisible = mAodIcons.getVisibility() != View.VISIBLE; |
| 602 | if (mAodIconsVisible) { |
| 603 | if (wasFullyInvisible) { |
| 604 | // No fading here, let's just appear the icons instead! |
| 605 | mAodIcons.setVisibility(View.VISIBLE); |
| 606 | mAodIcons.setAlpha(1.0f); |
| 607 | appearAodIcons(); |
| 608 | } else { |
| 609 | // We were fading out, let's fade in instead |
| 610 | CrossFadeHelper.fadeIn(mAodIcons); |
| 611 | } |
| 612 | } else { |
| 613 | CrossFadeHelper.fadeOut(mAodIcons); |
| 614 | } |
| 615 | } else { |
| 616 | mAodIcons.setAlpha(1.0f); |
| 617 | mAodIcons.setVisibility(visible ? View.VISIBLE : View.INVISIBLE); |
| 618 | } |
| 619 | } |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 620 | } |
Anthony Chen | 83092c6 | 2016-01-11 17:00:36 -0800 | [diff] [blame] | 621 | } |