Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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.stack; |
| 18 | |
Eliot Courtney | 5d3d2d0 | 2018-01-18 15:59:03 +0900 | [diff] [blame] | 19 | import android.annotation.Nullable; |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 20 | import android.content.Context; |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 21 | import android.view.View; |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 22 | |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 23 | import com.android.systemui.R; |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 24 | import com.android.systemui.statusbar.ActivatableNotificationView; |
Selim Cinek | ebf4234 | 2017-07-13 15:46:10 +0200 | [diff] [blame] | 25 | import com.android.systemui.statusbar.ExpandableNotificationRow; |
| 26 | import com.android.systemui.statusbar.ExpandableView; |
| 27 | import com.android.systemui.statusbar.NotificationData; |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 28 | import com.android.systemui.statusbar.NotificationShelf; |
Selim Cinek | 355652a | 2016-12-07 13:32:12 -0800 | [diff] [blame] | 29 | import com.android.systemui.statusbar.StatusBarState; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 30 | import com.android.systemui.statusbar.policy.HeadsUpManager; |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 31 | |
| 32 | import java.util.ArrayList; |
Selim Cinek | ebf4234 | 2017-07-13 15:46:10 +0200 | [diff] [blame] | 33 | import java.util.Collection; |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 34 | |
| 35 | /** |
| 36 | * A global state to track all input states for the algorithm. |
| 37 | */ |
| 38 | public class AmbientState { |
| 39 | private ArrayList<View> mDraggedViews = new ArrayList<View>(); |
| 40 | private int mScrollY; |
| 41 | private boolean mDimmed; |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 42 | private ActivatableNotificationView mActivatedChild; |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 43 | private float mOverScrollTopAmount; |
| 44 | private float mOverScrollBottomAmount; |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 45 | private int mSpeedBumpIndex = -1; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 46 | private boolean mDark; |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 47 | private boolean mHideSensitive; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 48 | private HeadsUpManager mHeadsUpManager; |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 49 | private float mStackTranslation; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 50 | private int mLayoutHeight; |
| 51 | private int mTopPadding; |
| 52 | private boolean mShadeExpanded; |
| 53 | private float mMaxHeadsUpTranslation; |
Selim Cinek | 9c17b77 | 2015-07-07 20:37:09 -0700 | [diff] [blame] | 54 | private boolean mDismissAllInProgress; |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 55 | private int mLayoutMinHeight; |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 56 | private NotificationShelf mShelf; |
| 57 | private int mZDistanceBetweenElements; |
| 58 | private int mBaseZHeight; |
Selim Cinek | 91d4cba | 2016-11-10 19:59:48 -0800 | [diff] [blame] | 59 | private int mMaxLayoutHeight; |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 60 | private ActivatableNotificationView mLastVisibleBackgroundChild; |
Selim Cinek | 727903c | 2016-12-06 17:28:10 -0800 | [diff] [blame] | 61 | private float mCurrentScrollVelocity; |
Selim Cinek | 355652a | 2016-12-07 13:32:12 -0800 | [diff] [blame] | 62 | private int mStatusBarState; |
Selim Cinek | d5ab645 | 2016-12-08 16:34:00 -0800 | [diff] [blame] | 63 | private float mExpandingVelocity; |
| 64 | private boolean mPanelTracking; |
| 65 | private boolean mExpansionChanging; |
Selim Cinek | fcff4c6 | 2016-12-27 14:26:06 +0100 | [diff] [blame] | 66 | private boolean mPanelFullWidth; |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 67 | private boolean mPulsing; |
Selim Cinek | ec29d34 | 2017-05-05 18:31:49 -0700 | [diff] [blame] | 68 | private boolean mUnlockHintRunning; |
Selim Cinek | 5cf1d05 | 2017-06-01 17:36:46 -0700 | [diff] [blame] | 69 | private boolean mQsCustomizerShowing; |
Selim Cinek | 1f62495 | 2017-06-08 19:11:50 -0700 | [diff] [blame] | 70 | private int mIntrinsicPadding; |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 71 | private int mExpandAnimationTopChange; |
| 72 | private ExpandableNotificationRow mExpandingNotification; |
Lucas Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame^] | 73 | private boolean mFullyDark; |
| 74 | private int mDarkTopPadding; |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 75 | |
| 76 | public AmbientState(Context context) { |
| 77 | reload(context); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Reload the dimens e.g. if the density changed. |
| 82 | */ |
| 83 | public void reload(Context context) { |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 84 | mZDistanceBetweenElements = getZDistanceBetweenElements(context); |
| 85 | mBaseZHeight = getBaseHeight(mZDistanceBetweenElements); |
| 86 | } |
| 87 | |
| 88 | private static int getZDistanceBetweenElements(Context context) { |
| 89 | return Math.max(1, context.getResources() |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 90 | .getDimensionPixelSize(R.dimen.z_distance_between_notifications)); |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | private static int getBaseHeight(int zdistanceBetweenElements) { |
| 94 | return 4 * zdistanceBetweenElements; |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * @return the launch height for notifications that are launched |
| 99 | */ |
| 100 | public static int getNotificationLaunchHeight(Context context) { |
| 101 | int zDistance = getZDistanceBetweenElements(context); |
| 102 | return getBaseHeight(zDistance) * 2; |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | /** |
| 106 | * @return the basic Z height on which notifications remain. |
| 107 | */ |
| 108 | public int getBaseZHeight() { |
| 109 | return mBaseZHeight; |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * @return the distance in Z between two overlaying notifications. |
| 114 | */ |
| 115 | public int getZDistanceBetweenElements() { |
| 116 | return mZDistanceBetweenElements; |
| 117 | } |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 118 | |
| 119 | public int getScrollY() { |
| 120 | return mScrollY; |
| 121 | } |
| 122 | |
| 123 | public void setScrollY(int scrollY) { |
| 124 | this.mScrollY = scrollY; |
| 125 | } |
| 126 | |
| 127 | public void onBeginDrag(View view) { |
| 128 | mDraggedViews.add(view); |
| 129 | } |
| 130 | |
| 131 | public void onDragFinished(View view) { |
| 132 | mDraggedViews.remove(view); |
| 133 | } |
| 134 | |
| 135 | public ArrayList<View> getDraggedViews() { |
| 136 | return mDraggedViews; |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * @param dimmed Whether we are in a dimmed state (on the lockscreen), where the backgrounds are |
| 141 | * translucent and everything is scaled back a bit. |
| 142 | */ |
| 143 | public void setDimmed(boolean dimmed) { |
| 144 | mDimmed = dimmed; |
| 145 | } |
| 146 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 147 | /** In dark mode, we draw as little as possible, assuming a black background */ |
| 148 | public void setDark(boolean dark) { |
| 149 | mDark = dark; |
| 150 | } |
| 151 | |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 152 | public void setHideSensitive(boolean hideSensitive) { |
| 153 | mHideSensitive = hideSensitive; |
| 154 | } |
| 155 | |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 156 | /** |
| 157 | * In dimmed mode, a child can be activated, which happens on the first tap of the double-tap |
| 158 | * interaction. This child is then scaled normally and its background is fully opaque. |
| 159 | */ |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 160 | public void setActivatedChild(ActivatableNotificationView activatedChild) { |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 161 | mActivatedChild = activatedChild; |
| 162 | } |
| 163 | |
| 164 | public boolean isDimmed() { |
| 165 | return mDimmed; |
| 166 | } |
| 167 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 168 | public boolean isDark() { |
| 169 | return mDark; |
| 170 | } |
| 171 | |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 172 | public boolean isHideSensitive() { |
| 173 | return mHideSensitive; |
| 174 | } |
| 175 | |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 176 | public ActivatableNotificationView getActivatedChild() { |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 177 | return mActivatedChild; |
| 178 | } |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 179 | |
| 180 | public void setOverScrollAmount(float amount, boolean onTop) { |
| 181 | if (onTop) { |
| 182 | mOverScrollTopAmount = amount; |
| 183 | } else { |
| 184 | mOverScrollBottomAmount = amount; |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | public float getOverScrollAmount(boolean top) { |
| 189 | return top ? mOverScrollTopAmount : mOverScrollBottomAmount; |
| 190 | } |
Selim Cinek | c27437b | 2014-05-14 10:23:33 +0200 | [diff] [blame] | 191 | |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 192 | public int getSpeedBumpIndex() { |
| 193 | return mSpeedBumpIndex; |
Selim Cinek | c27437b | 2014-05-14 10:23:33 +0200 | [diff] [blame] | 194 | } |
| 195 | |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 196 | public void setSpeedBumpIndex(int shelfIndex) { |
| 197 | mSpeedBumpIndex = shelfIndex; |
Selim Cinek | c27437b | 2014-05-14 10:23:33 +0200 | [diff] [blame] | 198 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 199 | |
| 200 | public void setHeadsUpManager(HeadsUpManager headsUpManager) { |
| 201 | mHeadsUpManager = headsUpManager; |
| 202 | } |
| 203 | |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 204 | public float getStackTranslation() { |
| 205 | return mStackTranslation; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 206 | } |
| 207 | |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 208 | public void setStackTranslation(float stackTranslation) { |
| 209 | mStackTranslation = stackTranslation; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 210 | } |
| 211 | |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 212 | public void setLayoutHeight(int layoutHeight) { |
| 213 | mLayoutHeight = layoutHeight; |
| 214 | } |
| 215 | |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 216 | public float getTopPadding() { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 217 | return mTopPadding; |
| 218 | } |
| 219 | |
| 220 | public void setTopPadding(int topPadding) { |
| 221 | mTopPadding = topPadding; |
| 222 | } |
| 223 | |
| 224 | public int getInnerHeight() { |
Selim Cinek | c25989e | 2018-02-16 16:42:14 -0800 | [diff] [blame] | 225 | return Math.max(Math.min(mLayoutHeight, mMaxLayoutHeight) - mTopPadding, mLayoutMinHeight); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | public boolean isShadeExpanded() { |
| 229 | return mShadeExpanded; |
| 230 | } |
| 231 | |
| 232 | public void setShadeExpanded(boolean shadeExpanded) { |
| 233 | mShadeExpanded = shadeExpanded; |
| 234 | } |
| 235 | |
| 236 | public void setMaxHeadsUpTranslation(float maxHeadsUpTranslation) { |
| 237 | mMaxHeadsUpTranslation = maxHeadsUpTranslation; |
| 238 | } |
| 239 | |
| 240 | public float getMaxHeadsUpTranslation() { |
| 241 | return mMaxHeadsUpTranslation; |
| 242 | } |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 243 | |
Selim Cinek | 9c17b77 | 2015-07-07 20:37:09 -0700 | [diff] [blame] | 244 | public void setDismissAllInProgress(boolean dismissAllInProgress) { |
| 245 | mDismissAllInProgress = dismissAllInProgress; |
| 246 | } |
| 247 | |
| 248 | public boolean isDismissAllInProgress() { |
| 249 | return mDismissAllInProgress; |
| 250 | } |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 251 | |
| 252 | public void setLayoutMinHeight(int layoutMinHeight) { |
| 253 | mLayoutMinHeight = layoutMinHeight; |
| 254 | } |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 255 | |
| 256 | public void setShelf(NotificationShelf shelf) { |
| 257 | mShelf = shelf; |
| 258 | } |
| 259 | |
Eliot Courtney | 5d3d2d0 | 2018-01-18 15:59:03 +0900 | [diff] [blame] | 260 | @Nullable |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 261 | public NotificationShelf getShelf() { |
| 262 | return mShelf; |
| 263 | } |
Selim Cinek | 91d4cba | 2016-11-10 19:59:48 -0800 | [diff] [blame] | 264 | |
| 265 | public void setLayoutMaxHeight(int maxLayoutHeight) { |
| 266 | mMaxLayoutHeight = maxLayoutHeight; |
| 267 | } |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 268 | |
| 269 | /** |
| 270 | * Sets the last visible view of the host layout, that has a background, i.e the very last |
| 271 | * view in the shade, without the clear all button. |
| 272 | */ |
| 273 | public void setLastVisibleBackgroundChild( |
| 274 | ActivatableNotificationView lastVisibleBackgroundChild) { |
| 275 | mLastVisibleBackgroundChild = lastVisibleBackgroundChild; |
| 276 | } |
| 277 | |
| 278 | public ActivatableNotificationView getLastVisibleBackgroundChild() { |
| 279 | return mLastVisibleBackgroundChild; |
| 280 | } |
Selim Cinek | 727903c | 2016-12-06 17:28:10 -0800 | [diff] [blame] | 281 | |
| 282 | public void setCurrentScrollVelocity(float currentScrollVelocity) { |
| 283 | mCurrentScrollVelocity = currentScrollVelocity; |
| 284 | } |
| 285 | |
| 286 | public float getCurrentScrollVelocity() { |
| 287 | return mCurrentScrollVelocity; |
| 288 | } |
Selim Cinek | 355652a | 2016-12-07 13:32:12 -0800 | [diff] [blame] | 289 | |
| 290 | public boolean isOnKeyguard() { |
| 291 | return mStatusBarState == StatusBarState.KEYGUARD; |
| 292 | } |
| 293 | |
| 294 | public void setStatusBarState(int statusBarState) { |
| 295 | mStatusBarState = statusBarState; |
| 296 | } |
Selim Cinek | d5ab645 | 2016-12-08 16:34:00 -0800 | [diff] [blame] | 297 | |
| 298 | public void setExpandingVelocity(float expandingVelocity) { |
| 299 | mExpandingVelocity = expandingVelocity; |
| 300 | } |
| 301 | |
| 302 | public void setExpansionChanging(boolean expansionChanging) { |
| 303 | mExpansionChanging = expansionChanging; |
| 304 | } |
| 305 | |
| 306 | public boolean isExpansionChanging() { |
| 307 | return mExpansionChanging; |
| 308 | } |
| 309 | |
| 310 | public float getExpandingVelocity() { |
| 311 | return mExpandingVelocity; |
| 312 | } |
| 313 | |
| 314 | public void setPanelTracking(boolean panelTracking) { |
| 315 | mPanelTracking = panelTracking; |
| 316 | } |
| 317 | |
Selim Cinek | be2c443 | 2017-05-30 12:11:09 -0700 | [diff] [blame] | 318 | public boolean hasPulsingNotifications() { |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 319 | return mPulsing; |
Adrian Roos | d83e999 | 2017-03-16 15:17:57 -0700 | [diff] [blame] | 320 | } |
| 321 | |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 322 | public void setPulsing(boolean hasPulsing) { |
Selim Cinek | ebf4234 | 2017-07-13 15:46:10 +0200 | [diff] [blame] | 323 | mPulsing = hasPulsing; |
| 324 | } |
| 325 | |
| 326 | public boolean isPulsing(NotificationData.Entry entry) { |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 327 | if (!mPulsing || mHeadsUpManager == null) { |
Selim Cinek | ebf4234 | 2017-07-13 15:46:10 +0200 | [diff] [blame] | 328 | return false; |
| 329 | } |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 330 | return mHeadsUpManager.getAllEntries().anyMatch(e -> (e == entry)); |
Adrian Roos | d83e999 | 2017-03-16 15:17:57 -0700 | [diff] [blame] | 331 | } |
| 332 | |
Selim Cinek | d5ab645 | 2016-12-08 16:34:00 -0800 | [diff] [blame] | 333 | public boolean isPanelTracking() { |
| 334 | return mPanelTracking; |
| 335 | } |
Selim Cinek | fcff4c6 | 2016-12-27 14:26:06 +0100 | [diff] [blame] | 336 | |
| 337 | public boolean isPanelFullWidth() { |
| 338 | return mPanelFullWidth; |
| 339 | } |
| 340 | |
| 341 | public void setPanelFullWidth(boolean panelFullWidth) { |
| 342 | mPanelFullWidth = panelFullWidth; |
| 343 | } |
Selim Cinek | ec29d34 | 2017-05-05 18:31:49 -0700 | [diff] [blame] | 344 | |
| 345 | public void setUnlockHintRunning(boolean unlockHintRunning) { |
| 346 | mUnlockHintRunning = unlockHintRunning; |
| 347 | } |
| 348 | |
| 349 | public boolean isUnlockHintRunning() { |
| 350 | return mUnlockHintRunning; |
| 351 | } |
Selim Cinek | 5cf1d05 | 2017-06-01 17:36:46 -0700 | [diff] [blame] | 352 | |
| 353 | public boolean isQsCustomizerShowing() { |
| 354 | return mQsCustomizerShowing; |
| 355 | } |
| 356 | |
| 357 | public void setQsCustomizerShowing(boolean qsCustomizerShowing) { |
| 358 | mQsCustomizerShowing = qsCustomizerShowing; |
| 359 | } |
Selim Cinek | 1f62495 | 2017-06-08 19:11:50 -0700 | [diff] [blame] | 360 | |
| 361 | public void setIntrinsicPadding(int intrinsicPadding) { |
| 362 | mIntrinsicPadding = intrinsicPadding; |
| 363 | } |
| 364 | |
| 365 | public int getIntrinsicPadding() { |
| 366 | return mIntrinsicPadding; |
| 367 | } |
Selim Cinek | ebf4234 | 2017-07-13 15:46:10 +0200 | [diff] [blame] | 368 | |
| 369 | /** |
| 370 | * Similar to the normal is above shelf logic but doesn't allow it to be above in AOD1. |
| 371 | * |
| 372 | * @param expandableView the view to check |
| 373 | */ |
| 374 | public boolean isAboveShelf(ExpandableView expandableView) { |
| 375 | if (!(expandableView instanceof ExpandableNotificationRow)) { |
| 376 | return expandableView.isAboveShelf(); |
| 377 | } |
| 378 | ExpandableNotificationRow row = (ExpandableNotificationRow) expandableView; |
| 379 | return row.isAboveShelf() && !isDozingAndNotPulsing(row); |
| 380 | } |
| 381 | |
| 382 | /** |
| 383 | * @return whether a view is dozing and not pulsing right now |
| 384 | */ |
| 385 | public boolean isDozingAndNotPulsing(ExpandableView view) { |
| 386 | if (view instanceof ExpandableNotificationRow) { |
| 387 | return isDozingAndNotPulsing((ExpandableNotificationRow) view); |
| 388 | } |
| 389 | return false; |
| 390 | } |
| 391 | |
| 392 | /** |
| 393 | * @return whether a row is dozing and not pulsing right now |
| 394 | */ |
| 395 | public boolean isDozingAndNotPulsing(ExpandableNotificationRow row) { |
| 396 | return isDark() && !isPulsing(row.getEntry()); |
| 397 | } |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 398 | |
| 399 | public void setExpandAnimationTopChange(int expandAnimationTopChange) { |
| 400 | mExpandAnimationTopChange = expandAnimationTopChange; |
| 401 | } |
| 402 | |
| 403 | public void setExpandingNotification(ExpandableNotificationRow row) { |
| 404 | mExpandingNotification = row; |
| 405 | } |
| 406 | |
| 407 | public ExpandableNotificationRow getExpandingNotification() { |
| 408 | return mExpandingNotification; |
| 409 | } |
| 410 | |
| 411 | public int getExpandAnimationTopChange() { |
| 412 | return mExpandAnimationTopChange; |
| 413 | } |
Lucas Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame^] | 414 | |
| 415 | /** |
| 416 | * {@see isFullyDark} |
| 417 | */ |
| 418 | public void setFullyDark(boolean fullyDark) { |
| 419 | mFullyDark = fullyDark; |
| 420 | } |
| 421 | |
| 422 | /** |
| 423 | * @return {@code true } when shade is completely dark: in AOD or ambient display. |
| 424 | */ |
| 425 | public boolean isFullyDark() { |
| 426 | return mFullyDark; |
| 427 | } |
| 428 | |
| 429 | public void setDarkTopPadding(int darkTopPadding) { |
| 430 | mDarkTopPadding = darkTopPadding; |
| 431 | } |
| 432 | |
| 433 | public int getDarkTopPadding() { |
| 434 | return mDarkTopPadding; |
| 435 | } |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 436 | } |