Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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.phone; |
| 18 | |
felkachang | 3d00f35 | 2018-05-22 12:53:50 +0800 | [diff] [blame] | 19 | import android.graphics.Point; |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 20 | import android.graphics.Rect; |
felkachang | 7749c9a | 2018-06-11 15:56:15 +0800 | [diff] [blame] | 21 | import android.view.DisplayCutout; |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 22 | import android.view.View; |
felkachang | 3d00f35 | 2018-05-22 12:53:50 +0800 | [diff] [blame] | 23 | import android.view.WindowInsets; |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 24 | |
| 25 | import com.android.internal.annotations.VisibleForTesting; |
| 26 | import com.android.systemui.Dependency; |
| 27 | import com.android.systemui.R; |
Selim Cinek | d03518c | 2018-03-15 12:13:51 -0700 | [diff] [blame] | 28 | import com.android.systemui.statusbar.CrossFadeHelper; |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 29 | import com.android.systemui.statusbar.ExpandableNotificationRow; |
| 30 | import com.android.systemui.statusbar.HeadsUpStatusBarView; |
| 31 | import com.android.systemui.statusbar.NotificationData; |
| 32 | import com.android.systemui.statusbar.policy.DarkIconDispatcher; |
| 33 | import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener; |
| 34 | import com.android.systemui.statusbar.stack.NotificationStackScrollLayout; |
| 35 | |
Selim Cinek | 60ffea6 | 2018-03-22 13:16:44 -0700 | [diff] [blame] | 36 | import java.util.function.BiConsumer; |
| 37 | import java.util.function.Consumer; |
| 38 | |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 39 | /** |
| 40 | * Controls the appearance of heads up notifications in the icon area and the header itself. |
| 41 | */ |
Selim Cinek | f0c79e1 | 2018-05-14 17:17:31 -0700 | [diff] [blame] | 42 | public class HeadsUpAppearanceController implements OnHeadsUpChangedListener, |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 43 | DarkIconDispatcher.DarkReceiver { |
Selim Cinek | d03518c | 2018-03-15 12:13:51 -0700 | [diff] [blame] | 44 | public static final int CONTENT_FADE_DURATION = 110; |
| 45 | public static final int CONTENT_FADE_DELAY = 100; |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 46 | private final NotificationIconAreaController mNotificationIconAreaController; |
| 47 | private final HeadsUpManagerPhone mHeadsUpManager; |
| 48 | private final NotificationStackScrollLayout mStackScroller; |
| 49 | private final HeadsUpStatusBarView mHeadsUpStatusBarView; |
| 50 | private final View mClockView; |
Tetsutoki Shiozawa | f1e0f7a | 2018-09-05 13:17:01 +0900 | [diff] [blame] | 51 | private final View mOperatorNameView; |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 52 | private final DarkIconDispatcher mDarkIconDispatcher; |
Selim Cinek | 60ffea6 | 2018-03-22 13:16:44 -0700 | [diff] [blame] | 53 | private final NotificationPanelView mPanelView; |
| 54 | private final Consumer<ExpandableNotificationRow> |
| 55 | mSetTrackingHeadsUp = this::setTrackingHeadsUp; |
| 56 | private final Runnable mUpdatePanelTranslation = this::updatePanelTranslation; |
| 57 | private final BiConsumer<Float, Float> mSetExpandedHeight = this::setExpandedHeight; |
felkachang | 0857955 | 2018-05-24 15:38:04 +0800 | [diff] [blame] | 58 | @VisibleForTesting |
| 59 | float mExpandedHeight; |
| 60 | @VisibleForTesting |
| 61 | boolean mIsExpanded; |
| 62 | @VisibleForTesting |
| 63 | float mExpandFraction; |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 64 | private ExpandableNotificationRow mTrackedChild; |
| 65 | private boolean mShown; |
Selim Cinek | 60ffea6 | 2018-03-22 13:16:44 -0700 | [diff] [blame] | 66 | private final View.OnLayoutChangeListener mStackScrollLayoutChangeListener = |
| 67 | (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) |
| 68 | -> updatePanelTranslation(); |
Tetsutoki Shiozawa | f1e0f7a | 2018-09-05 13:17:01 +0900 | [diff] [blame] | 69 | private boolean mAnimationsEnabled = true; |
felkachang | 3d00f35 | 2018-05-22 12:53:50 +0800 | [diff] [blame] | 70 | Point mPoint; |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 71 | |
Tetsutoki Shiozawa | f1e0f7a | 2018-09-05 13:17:01 +0900 | [diff] [blame] | 72 | |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 73 | public HeadsUpAppearanceController( |
| 74 | NotificationIconAreaController notificationIconAreaController, |
| 75 | HeadsUpManagerPhone headsUpManager, |
| 76 | View statusbarView) { |
| 77 | this(notificationIconAreaController, headsUpManager, |
| 78 | statusbarView.findViewById(R.id.heads_up_status_bar_view), |
| 79 | statusbarView.findViewById(R.id.notification_stack_scroller), |
| 80 | statusbarView.findViewById(R.id.notification_panel), |
Tetsutoki Shiozawa | f1e0f7a | 2018-09-05 13:17:01 +0900 | [diff] [blame] | 81 | statusbarView.findViewById(R.id.clock), |
| 82 | statusbarView.findViewById(R.id.operator_name_frame)); |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | @VisibleForTesting |
| 86 | public HeadsUpAppearanceController( |
| 87 | NotificationIconAreaController notificationIconAreaController, |
| 88 | HeadsUpManagerPhone headsUpManager, |
| 89 | HeadsUpStatusBarView headsUpStatusBarView, |
| 90 | NotificationStackScrollLayout stackScroller, |
| 91 | NotificationPanelView panelView, |
Tetsutoki Shiozawa | f1e0f7a | 2018-09-05 13:17:01 +0900 | [diff] [blame] | 92 | View clockView, |
| 93 | View operatorNameView) { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 94 | mNotificationIconAreaController = notificationIconAreaController; |
| 95 | mHeadsUpManager = headsUpManager; |
| 96 | mHeadsUpManager.addListener(this); |
| 97 | mHeadsUpStatusBarView = headsUpStatusBarView; |
Selim Cinek | 332c23f | 2018-03-16 17:37:50 -0700 | [diff] [blame] | 98 | headsUpStatusBarView.setOnDrawingRectChangedListener( |
| 99 | () -> updateIsolatedIconLocation(true /* requireUpdate */)); |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 100 | mStackScroller = stackScroller; |
Selim Cinek | 60ffea6 | 2018-03-22 13:16:44 -0700 | [diff] [blame] | 101 | mPanelView = panelView; |
| 102 | panelView.addTrackingHeadsUpListener(mSetTrackingHeadsUp); |
| 103 | panelView.addVerticalTranslationListener(mUpdatePanelTranslation); |
Selim Cinek | 332c23f | 2018-03-16 17:37:50 -0700 | [diff] [blame] | 104 | panelView.setHeadsUpAppearanceController(this); |
Selim Cinek | 60ffea6 | 2018-03-22 13:16:44 -0700 | [diff] [blame] | 105 | mStackScroller.addOnExpandedHeightListener(mSetExpandedHeight); |
| 106 | mStackScroller.addOnLayoutChangeListener(mStackScrollLayoutChangeListener); |
Selim Cinek | f0c79e1 | 2018-05-14 17:17:31 -0700 | [diff] [blame] | 107 | mStackScroller.setHeadsUpAppearanceController(this); |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 108 | mClockView = clockView; |
Tetsutoki Shiozawa | f1e0f7a | 2018-09-05 13:17:01 +0900 | [diff] [blame] | 109 | mOperatorNameView = operatorNameView; |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 110 | mDarkIconDispatcher = Dependency.get(DarkIconDispatcher.class); |
| 111 | mDarkIconDispatcher.addDarkReceiver(this); |
felkachang | 0857955 | 2018-05-24 15:38:04 +0800 | [diff] [blame] | 112 | |
| 113 | mHeadsUpStatusBarView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { |
| 114 | @Override |
| 115 | public void onLayoutChange(View v, int left, int top, int right, int bottom, |
| 116 | int oldLeft, int oldTop, int oldRight, int oldBottom) { |
| 117 | if (shouldBeVisible()) { |
| 118 | updateTopEntry(); |
| 119 | |
| 120 | // trigger scroller to notify the latest panel translation |
| 121 | mStackScroller.requestLayout(); |
| 122 | } |
| 123 | mHeadsUpStatusBarView.removeOnLayoutChangeListener(this); |
| 124 | } |
| 125 | }); |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 126 | } |
| 127 | |
Selim Cinek | 60ffea6 | 2018-03-22 13:16:44 -0700 | [diff] [blame] | 128 | |
| 129 | public void destroy() { |
| 130 | mHeadsUpManager.removeListener(this); |
| 131 | mHeadsUpStatusBarView.setOnDrawingRectChangedListener(null); |
| 132 | mPanelView.removeTrackingHeadsUpListener(mSetTrackingHeadsUp); |
| 133 | mPanelView.removeVerticalTranslationListener(mUpdatePanelTranslation); |
| 134 | mPanelView.setHeadsUpAppearanceController(null); |
| 135 | mStackScroller.removeOnExpandedHeightListener(mSetExpandedHeight); |
| 136 | mStackScroller.removeOnLayoutChangeListener(mStackScrollLayoutChangeListener); |
| 137 | mDarkIconDispatcher.removeDarkReceiver(this); |
| 138 | } |
| 139 | |
Selim Cinek | 332c23f | 2018-03-16 17:37:50 -0700 | [diff] [blame] | 140 | private void updateIsolatedIconLocation(boolean requireStateUpdate) { |
| 141 | mNotificationIconAreaController.setIsolatedIconLocation( |
| 142 | mHeadsUpStatusBarView.getIconDrawingRect(), requireStateUpdate); |
| 143 | } |
| 144 | |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 145 | @Override |
| 146 | public void onHeadsUpPinned(ExpandableNotificationRow headsUp) { |
| 147 | updateTopEntry(); |
| 148 | updateHeader(headsUp.getEntry()); |
| 149 | } |
| 150 | |
felkachang | 3d00f35 | 2018-05-22 12:53:50 +0800 | [diff] [blame] | 151 | /** To count the distance from the window right boundary to scroller right boundary. The |
| 152 | * distance formula is the following: |
| 153 | * Y = screenSize - (SystemWindow's width + Scroller.getRight()) |
| 154 | * There are four modes MUST to be considered in Cut Out of RTL. |
| 155 | * No Cut Out: |
| 156 | * Scroller + NB |
| 157 | * NB + Scroller |
| 158 | * => SystemWindow = NavigationBar's width |
| 159 | * => Y = screenSize - (SystemWindow's width + Scroller.getRight()) |
| 160 | * Corner Cut Out or Tall Cut Out: |
| 161 | * cut out + Scroller + NB |
| 162 | * NB + Scroller + cut out |
| 163 | * => SystemWindow = NavigationBar's width |
| 164 | * => Y = screenSize - (SystemWindow's width + Scroller.getRight()) |
| 165 | * Double Cut Out: |
| 166 | * cut out left + Scroller + (NB + cut out right) |
| 167 | * SystemWindow = NavigationBar's width + cut out right width |
| 168 | * => Y = screenSize - (SystemWindow's width + Scroller.getRight()) |
| 169 | * (cut out left + NB) + Scroller + cut out right |
| 170 | * SystemWindow = NavigationBar's width + cut out left width |
| 171 | * => Y = screenSize - (SystemWindow's width + Scroller.getRight()) |
| 172 | * @return the translation X value for RTL. In theory, it should be negative. i.e. -Y |
| 173 | */ |
| 174 | private int getRtlTranslation() { |
felkachang | 3d00f35 | 2018-05-22 12:53:50 +0800 | [diff] [blame] | 175 | if (mPoint == null) { |
| 176 | mPoint = new Point(); |
| 177 | } |
| 178 | |
| 179 | int realDisplaySize = 0; |
| 180 | if (mStackScroller.getDisplay() != null) { |
| 181 | mStackScroller.getDisplay().getRealSize(mPoint); |
| 182 | realDisplaySize = mPoint.x; |
| 183 | } |
| 184 | |
| 185 | WindowInsets windowInset = mStackScroller.getRootWindowInsets(); |
felkachang | 7749c9a | 2018-06-11 15:56:15 +0800 | [diff] [blame] | 186 | DisplayCutout cutout = (windowInset != null) ? windowInset.getDisplayCutout() : null; |
| 187 | int sysWinLeft = (windowInset != null) ? windowInset.getStableInsetLeft() : 0; |
| 188 | int sysWinRight = (windowInset != null) ? windowInset.getStableInsetRight() : 0; |
| 189 | int cutoutLeft = (cutout != null) ? cutout.getSafeInsetLeft() : 0; |
| 190 | int cutoutRight = (cutout != null) ? cutout.getSafeInsetRight() : 0; |
| 191 | int leftInset = Math.max(sysWinLeft, cutoutLeft); |
| 192 | int rightInset = Math.max(sysWinRight, cutoutRight); |
| 193 | |
| 194 | return leftInset + mStackScroller.getRight() + rightInset - realDisplaySize; |
felkachang | 3d00f35 | 2018-05-22 12:53:50 +0800 | [diff] [blame] | 195 | } |
| 196 | |
Selim Cinek | 332c23f | 2018-03-16 17:37:50 -0700 | [diff] [blame] | 197 | public void updatePanelTranslation() { |
felkachang | 3d00f35 | 2018-05-22 12:53:50 +0800 | [diff] [blame] | 198 | float newTranslation; |
| 199 | if (mStackScroller.isLayoutRtl()) { |
| 200 | newTranslation = getRtlTranslation(); |
| 201 | } else { |
| 202 | newTranslation = mStackScroller.getLeft(); |
| 203 | } |
| 204 | newTranslation += mStackScroller.getTranslationX(); |
felkachang | e8a3536 | 2018-05-18 20:11:38 +0800 | [diff] [blame] | 205 | mHeadsUpStatusBarView.setPanelTranslation(newTranslation); |
Selim Cinek | 332c23f | 2018-03-16 17:37:50 -0700 | [diff] [blame] | 206 | } |
| 207 | |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 208 | private void updateTopEntry() { |
| 209 | NotificationData.Entry newEntry = null; |
| 210 | if (!mIsExpanded && mHeadsUpManager.hasPinnedHeadsUp()) { |
| 211 | newEntry = mHeadsUpManager.getTopEntry(); |
| 212 | } |
| 213 | NotificationData.Entry previousEntry = mHeadsUpStatusBarView.getShowingEntry(); |
| 214 | mHeadsUpStatusBarView.setEntry(newEntry); |
| 215 | if (newEntry != previousEntry) { |
Selim Cinek | d03518c | 2018-03-15 12:13:51 -0700 | [diff] [blame] | 216 | boolean animateIsolation = false; |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 217 | if (newEntry == null) { |
| 218 | // no heads up anymore, lets start the disappear animation |
| 219 | |
| 220 | setShown(false); |
Selim Cinek | d03518c | 2018-03-15 12:13:51 -0700 | [diff] [blame] | 221 | animateIsolation = !mIsExpanded; |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 222 | } else if (previousEntry == null) { |
| 223 | // We now have a headsUp and didn't have one before. Let's start the disappear |
| 224 | // animation |
| 225 | setShown(true); |
Selim Cinek | 332c23f | 2018-03-16 17:37:50 -0700 | [diff] [blame] | 226 | animateIsolation = !mIsExpanded; |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 227 | } |
Selim Cinek | 332c23f | 2018-03-16 17:37:50 -0700 | [diff] [blame] | 228 | updateIsolatedIconLocation(false /* requireUpdate */); |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 229 | mNotificationIconAreaController.showIconIsolated(newEntry == null ? null |
Selim Cinek | 332c23f | 2018-03-16 17:37:50 -0700 | [diff] [blame] | 230 | : newEntry.icon, animateIsolation); |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 231 | } |
| 232 | } |
| 233 | |
| 234 | private void setShown(boolean isShown) { |
Selim Cinek | d03518c | 2018-03-15 12:13:51 -0700 | [diff] [blame] | 235 | if (mShown != isShown) { |
| 236 | mShown = isShown; |
| 237 | if (isShown) { |
| 238 | mHeadsUpStatusBarView.setVisibility(View.VISIBLE); |
Tetsutoki Shiozawa | f1e0f7a | 2018-09-05 13:17:01 +0900 | [diff] [blame] | 239 | show(mHeadsUpStatusBarView); |
| 240 | hide(mClockView, View.INVISIBLE); |
| 241 | if (mOperatorNameView != null) { |
| 242 | hide(mOperatorNameView, View.INVISIBLE); |
| 243 | } |
Selim Cinek | d03518c | 2018-03-15 12:13:51 -0700 | [diff] [blame] | 244 | } else { |
Tetsutoki Shiozawa | f1e0f7a | 2018-09-05 13:17:01 +0900 | [diff] [blame] | 245 | show(mClockView); |
| 246 | if (mOperatorNameView != null) { |
| 247 | show(mOperatorNameView); |
| 248 | } |
| 249 | hide(mHeadsUpStatusBarView, View.GONE); |
Selim Cinek | d03518c | 2018-03-15 12:13:51 -0700 | [diff] [blame] | 250 | } |
| 251 | } |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 252 | } |
| 253 | |
Tetsutoki Shiozawa | f1e0f7a | 2018-09-05 13:17:01 +0900 | [diff] [blame] | 254 | /** |
| 255 | * Hides the view and sets the state to endState when finished. |
| 256 | * |
| 257 | * @param view The view to hide. |
| 258 | * @param endState One of {@link View#INVISIBLE} or {@link View#GONE}. |
| 259 | * @see View#setVisibility(int) |
| 260 | * |
| 261 | */ |
| 262 | private void hide(View view, int endState) { |
| 263 | if (mAnimationsEnabled) { |
| 264 | CrossFadeHelper.fadeOut(view, CONTENT_FADE_DURATION /* duration */, |
| 265 | 0 /* delay */, () -> view.setVisibility(endState)); |
| 266 | } else { |
| 267 | view.setVisibility(endState); |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | private void show(View view) { |
| 272 | if (mAnimationsEnabled) { |
| 273 | CrossFadeHelper.fadeIn(view, CONTENT_FADE_DURATION /* duration */, |
| 274 | CONTENT_FADE_DELAY /* delay */); |
| 275 | } else { |
| 276 | view.setVisibility(View.VISIBLE); |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | @VisibleForTesting |
| 281 | void setAnimationsEnabled(boolean enabled) { |
| 282 | mAnimationsEnabled = enabled; |
| 283 | } |
| 284 | |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 285 | @VisibleForTesting |
| 286 | public boolean isShown() { |
| 287 | return mShown; |
| 288 | } |
| 289 | |
Selim Cinek | 332c23f | 2018-03-16 17:37:50 -0700 | [diff] [blame] | 290 | /** |
| 291 | * Should the headsup status bar view be visible right now? This may be different from isShown, |
| 292 | * since the headsUp manager might not have notified us yet of the state change. |
| 293 | * |
| 294 | * @return if the heads up status bar view should be shown |
| 295 | */ |
| 296 | public boolean shouldBeVisible() { |
| 297 | return !mIsExpanded && mHeadsUpManager.hasPinnedHeadsUp(); |
| 298 | } |
| 299 | |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 300 | @Override |
| 301 | public void onHeadsUpUnPinned(ExpandableNotificationRow headsUp) { |
| 302 | updateTopEntry(); |
| 303 | updateHeader(headsUp.getEntry()); |
| 304 | } |
| 305 | |
| 306 | public void setExpandedHeight(float expandedHeight, float appearFraction) { |
| 307 | boolean changedHeight = expandedHeight != mExpandedHeight; |
| 308 | mExpandedHeight = expandedHeight; |
| 309 | mExpandFraction = appearFraction; |
| 310 | boolean isExpanded = expandedHeight > 0; |
| 311 | if (changedHeight) { |
| 312 | updateHeadsUpHeaders(); |
| 313 | } |
| 314 | if (isExpanded != mIsExpanded) { |
| 315 | mIsExpanded = isExpanded; |
| 316 | updateTopEntry(); |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | /** |
| 321 | * Set a headsUp to be tracked, meaning that it is currently being pulled down after being |
| 322 | * in a pinned state on the top. The expand animation is different in that case and we need |
| 323 | * to update the header constantly afterwards. |
| 324 | * |
| 325 | * @param trackedChild the tracked headsUp or null if it's not tracking anymore. |
| 326 | */ |
| 327 | public void setTrackingHeadsUp(ExpandableNotificationRow trackedChild) { |
| 328 | ExpandableNotificationRow previousTracked = mTrackedChild; |
| 329 | mTrackedChild = trackedChild; |
| 330 | if (previousTracked != null) { |
| 331 | updateHeader(previousTracked.getEntry()); |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | private void updateHeadsUpHeaders() { |
| 336 | mHeadsUpManager.getAllEntries().forEach(entry -> { |
| 337 | updateHeader(entry); |
| 338 | }); |
| 339 | } |
| 340 | |
Selim Cinek | f0c79e1 | 2018-05-14 17:17:31 -0700 | [diff] [blame] | 341 | public void updateHeader(NotificationData.Entry entry) { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 342 | ExpandableNotificationRow row = entry.row; |
| 343 | float headerVisibleAmount = 1.0f; |
Selim Cinek | f0c79e1 | 2018-05-14 17:17:31 -0700 | [diff] [blame] | 344 | if (row.isPinned() || row.isHeadsUpAnimatingAway() || row == mTrackedChild) { |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 345 | headerVisibleAmount = mExpandFraction; |
| 346 | } |
| 347 | row.setHeaderVisibleAmount(headerVisibleAmount); |
| 348 | } |
| 349 | |
| 350 | @Override |
| 351 | public void onDarkChanged(Rect area, float darkIntensity, int tint) { |
| 352 | mHeadsUpStatusBarView.onDarkChanged(area, darkIntensity, tint); |
| 353 | } |
| 354 | |
| 355 | public void setPublicMode(boolean publicMode) { |
| 356 | mHeadsUpStatusBarView.setPublicMode(publicMode); |
| 357 | updateTopEntry(); |
| 358 | } |
felkachang | 0857955 | 2018-05-24 15:38:04 +0800 | [diff] [blame] | 359 | |
| 360 | void readFrom(HeadsUpAppearanceController oldController) { |
| 361 | if (oldController != null) { |
| 362 | mTrackedChild = oldController.mTrackedChild; |
| 363 | mExpandedHeight = oldController.mExpandedHeight; |
| 364 | mIsExpanded = oldController.mIsExpanded; |
| 365 | mExpandFraction = oldController.mExpandFraction; |
| 366 | } |
| 367 | } |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 368 | } |