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