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 int mDarkTopPadding; |
Lucas Dupin | b561eda | 2018-04-09 17:25:04 -0700 | [diff] [blame] | 74 | private float mDarkAmount; |
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 | |
Lucas Dupin | b561eda | 2018-04-09 17:25:04 -0700 | [diff] [blame] | 152 | /** Dark ratio of the status bar **/ |
| 153 | public void setDarkAmount(float darkAmount) { |
| 154 | mDarkAmount = darkAmount; |
| 155 | } |
| 156 | |
| 157 | /** Returns the dark ratio of the status bar */ |
| 158 | public float getDarkAmount() { |
| 159 | return mDarkAmount; |
| 160 | } |
| 161 | |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 162 | public void setHideSensitive(boolean hideSensitive) { |
| 163 | mHideSensitive = hideSensitive; |
| 164 | } |
| 165 | |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 166 | /** |
| 167 | * In dimmed mode, a child can be activated, which happens on the first tap of the double-tap |
| 168 | * interaction. This child is then scaled normally and its background is fully opaque. |
| 169 | */ |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 170 | public void setActivatedChild(ActivatableNotificationView activatedChild) { |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 171 | mActivatedChild = activatedChild; |
| 172 | } |
| 173 | |
| 174 | public boolean isDimmed() { |
| 175 | return mDimmed; |
| 176 | } |
| 177 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 178 | public boolean isDark() { |
| 179 | return mDark; |
| 180 | } |
| 181 | |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 182 | public boolean isHideSensitive() { |
| 183 | return mHideSensitive; |
| 184 | } |
| 185 | |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 186 | public ActivatableNotificationView getActivatedChild() { |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 187 | return mActivatedChild; |
| 188 | } |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 189 | |
| 190 | public void setOverScrollAmount(float amount, boolean onTop) { |
| 191 | if (onTop) { |
| 192 | mOverScrollTopAmount = amount; |
| 193 | } else { |
| 194 | mOverScrollBottomAmount = amount; |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | public float getOverScrollAmount(boolean top) { |
| 199 | return top ? mOverScrollTopAmount : mOverScrollBottomAmount; |
| 200 | } |
Selim Cinek | c27437b | 2014-05-14 10:23:33 +0200 | [diff] [blame] | 201 | |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 202 | public int getSpeedBumpIndex() { |
| 203 | return mSpeedBumpIndex; |
Selim Cinek | c27437b | 2014-05-14 10:23:33 +0200 | [diff] [blame] | 204 | } |
| 205 | |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 206 | public void setSpeedBumpIndex(int shelfIndex) { |
| 207 | mSpeedBumpIndex = shelfIndex; |
Selim Cinek | c27437b | 2014-05-14 10:23:33 +0200 | [diff] [blame] | 208 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 209 | |
| 210 | public void setHeadsUpManager(HeadsUpManager headsUpManager) { |
| 211 | mHeadsUpManager = headsUpManager; |
| 212 | } |
| 213 | |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 214 | public float getStackTranslation() { |
| 215 | return mStackTranslation; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 216 | } |
| 217 | |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 218 | public void setStackTranslation(float stackTranslation) { |
| 219 | mStackTranslation = stackTranslation; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 220 | } |
| 221 | |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 222 | public void setLayoutHeight(int layoutHeight) { |
| 223 | mLayoutHeight = layoutHeight; |
| 224 | } |
| 225 | |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 226 | public float getTopPadding() { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 227 | return mTopPadding; |
| 228 | } |
| 229 | |
| 230 | public void setTopPadding(int topPadding) { |
| 231 | mTopPadding = topPadding; |
| 232 | } |
| 233 | |
| 234 | public int getInnerHeight() { |
Selim Cinek | c25989e | 2018-02-16 16:42:14 -0800 | [diff] [blame] | 235 | return Math.max(Math.min(mLayoutHeight, mMaxLayoutHeight) - mTopPadding, mLayoutMinHeight); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | public boolean isShadeExpanded() { |
| 239 | return mShadeExpanded; |
| 240 | } |
| 241 | |
| 242 | public void setShadeExpanded(boolean shadeExpanded) { |
| 243 | mShadeExpanded = shadeExpanded; |
| 244 | } |
| 245 | |
| 246 | public void setMaxHeadsUpTranslation(float maxHeadsUpTranslation) { |
| 247 | mMaxHeadsUpTranslation = maxHeadsUpTranslation; |
| 248 | } |
| 249 | |
| 250 | public float getMaxHeadsUpTranslation() { |
| 251 | return mMaxHeadsUpTranslation; |
| 252 | } |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 253 | |
Selim Cinek | 9c17b77 | 2015-07-07 20:37:09 -0700 | [diff] [blame] | 254 | public void setDismissAllInProgress(boolean dismissAllInProgress) { |
| 255 | mDismissAllInProgress = dismissAllInProgress; |
| 256 | } |
| 257 | |
| 258 | public boolean isDismissAllInProgress() { |
| 259 | return mDismissAllInProgress; |
| 260 | } |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 261 | |
| 262 | public void setLayoutMinHeight(int layoutMinHeight) { |
| 263 | mLayoutMinHeight = layoutMinHeight; |
| 264 | } |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 265 | |
| 266 | public void setShelf(NotificationShelf shelf) { |
| 267 | mShelf = shelf; |
| 268 | } |
| 269 | |
Eliot Courtney | 5d3d2d0 | 2018-01-18 15:59:03 +0900 | [diff] [blame] | 270 | @Nullable |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 271 | public NotificationShelf getShelf() { |
| 272 | return mShelf; |
| 273 | } |
Selim Cinek | 91d4cba | 2016-11-10 19:59:48 -0800 | [diff] [blame] | 274 | |
| 275 | public void setLayoutMaxHeight(int maxLayoutHeight) { |
| 276 | mMaxLayoutHeight = maxLayoutHeight; |
| 277 | } |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 278 | |
| 279 | /** |
| 280 | * Sets the last visible view of the host layout, that has a background, i.e the very last |
| 281 | * view in the shade, without the clear all button. |
| 282 | */ |
| 283 | public void setLastVisibleBackgroundChild( |
| 284 | ActivatableNotificationView lastVisibleBackgroundChild) { |
| 285 | mLastVisibleBackgroundChild = lastVisibleBackgroundChild; |
| 286 | } |
| 287 | |
| 288 | public ActivatableNotificationView getLastVisibleBackgroundChild() { |
| 289 | return mLastVisibleBackgroundChild; |
| 290 | } |
Selim Cinek | 727903c | 2016-12-06 17:28:10 -0800 | [diff] [blame] | 291 | |
| 292 | public void setCurrentScrollVelocity(float currentScrollVelocity) { |
| 293 | mCurrentScrollVelocity = currentScrollVelocity; |
| 294 | } |
| 295 | |
| 296 | public float getCurrentScrollVelocity() { |
| 297 | return mCurrentScrollVelocity; |
| 298 | } |
Selim Cinek | 355652a | 2016-12-07 13:32:12 -0800 | [diff] [blame] | 299 | |
| 300 | public boolean isOnKeyguard() { |
| 301 | return mStatusBarState == StatusBarState.KEYGUARD; |
| 302 | } |
| 303 | |
| 304 | public void setStatusBarState(int statusBarState) { |
| 305 | mStatusBarState = statusBarState; |
| 306 | } |
Selim Cinek | d5ab645 | 2016-12-08 16:34:00 -0800 | [diff] [blame] | 307 | |
| 308 | public void setExpandingVelocity(float expandingVelocity) { |
| 309 | mExpandingVelocity = expandingVelocity; |
| 310 | } |
| 311 | |
| 312 | public void setExpansionChanging(boolean expansionChanging) { |
| 313 | mExpansionChanging = expansionChanging; |
| 314 | } |
| 315 | |
| 316 | public boolean isExpansionChanging() { |
| 317 | return mExpansionChanging; |
| 318 | } |
| 319 | |
| 320 | public float getExpandingVelocity() { |
| 321 | return mExpandingVelocity; |
| 322 | } |
| 323 | |
| 324 | public void setPanelTracking(boolean panelTracking) { |
| 325 | mPanelTracking = panelTracking; |
| 326 | } |
| 327 | |
Selim Cinek | be2c443 | 2017-05-30 12:11:09 -0700 | [diff] [blame] | 328 | public boolean hasPulsingNotifications() { |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 329 | return mPulsing; |
Adrian Roos | d83e999 | 2017-03-16 15:17:57 -0700 | [diff] [blame] | 330 | } |
| 331 | |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 332 | public void setPulsing(boolean hasPulsing) { |
Selim Cinek | ebf4234 | 2017-07-13 15:46:10 +0200 | [diff] [blame] | 333 | mPulsing = hasPulsing; |
| 334 | } |
| 335 | |
| 336 | public boolean isPulsing(NotificationData.Entry entry) { |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 337 | if (!mPulsing || mHeadsUpManager == null) { |
Selim Cinek | ebf4234 | 2017-07-13 15:46:10 +0200 | [diff] [blame] | 338 | return false; |
| 339 | } |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 340 | return mHeadsUpManager.getAllEntries().anyMatch(e -> (e == entry)); |
Adrian Roos | d83e999 | 2017-03-16 15:17:57 -0700 | [diff] [blame] | 341 | } |
| 342 | |
Selim Cinek | d5ab645 | 2016-12-08 16:34:00 -0800 | [diff] [blame] | 343 | public boolean isPanelTracking() { |
| 344 | return mPanelTracking; |
| 345 | } |
Selim Cinek | fcff4c6 | 2016-12-27 14:26:06 +0100 | [diff] [blame] | 346 | |
| 347 | public boolean isPanelFullWidth() { |
| 348 | return mPanelFullWidth; |
| 349 | } |
| 350 | |
| 351 | public void setPanelFullWidth(boolean panelFullWidth) { |
| 352 | mPanelFullWidth = panelFullWidth; |
| 353 | } |
Selim Cinek | ec29d34 | 2017-05-05 18:31:49 -0700 | [diff] [blame] | 354 | |
| 355 | public void setUnlockHintRunning(boolean unlockHintRunning) { |
| 356 | mUnlockHintRunning = unlockHintRunning; |
| 357 | } |
| 358 | |
| 359 | public boolean isUnlockHintRunning() { |
| 360 | return mUnlockHintRunning; |
| 361 | } |
Selim Cinek | 5cf1d05 | 2017-06-01 17:36:46 -0700 | [diff] [blame] | 362 | |
| 363 | public boolean isQsCustomizerShowing() { |
| 364 | return mQsCustomizerShowing; |
| 365 | } |
| 366 | |
| 367 | public void setQsCustomizerShowing(boolean qsCustomizerShowing) { |
| 368 | mQsCustomizerShowing = qsCustomizerShowing; |
| 369 | } |
Selim Cinek | 1f62495 | 2017-06-08 19:11:50 -0700 | [diff] [blame] | 370 | |
| 371 | public void setIntrinsicPadding(int intrinsicPadding) { |
| 372 | mIntrinsicPadding = intrinsicPadding; |
| 373 | } |
| 374 | |
| 375 | public int getIntrinsicPadding() { |
| 376 | return mIntrinsicPadding; |
| 377 | } |
Selim Cinek | ebf4234 | 2017-07-13 15:46:10 +0200 | [diff] [blame] | 378 | |
| 379 | /** |
| 380 | * Similar to the normal is above shelf logic but doesn't allow it to be above in AOD1. |
| 381 | * |
| 382 | * @param expandableView the view to check |
| 383 | */ |
| 384 | public boolean isAboveShelf(ExpandableView expandableView) { |
| 385 | if (!(expandableView instanceof ExpandableNotificationRow)) { |
| 386 | return expandableView.isAboveShelf(); |
| 387 | } |
| 388 | ExpandableNotificationRow row = (ExpandableNotificationRow) expandableView; |
| 389 | return row.isAboveShelf() && !isDozingAndNotPulsing(row); |
| 390 | } |
| 391 | |
| 392 | /** |
| 393 | * @return whether a view is dozing and not pulsing right now |
| 394 | */ |
| 395 | public boolean isDozingAndNotPulsing(ExpandableView view) { |
| 396 | if (view instanceof ExpandableNotificationRow) { |
| 397 | return isDozingAndNotPulsing((ExpandableNotificationRow) view); |
| 398 | } |
| 399 | return false; |
| 400 | } |
| 401 | |
| 402 | /** |
| 403 | * @return whether a row is dozing and not pulsing right now |
| 404 | */ |
| 405 | public boolean isDozingAndNotPulsing(ExpandableNotificationRow row) { |
| 406 | return isDark() && !isPulsing(row.getEntry()); |
| 407 | } |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 408 | |
| 409 | public void setExpandAnimationTopChange(int expandAnimationTopChange) { |
| 410 | mExpandAnimationTopChange = expandAnimationTopChange; |
| 411 | } |
| 412 | |
| 413 | public void setExpandingNotification(ExpandableNotificationRow row) { |
| 414 | mExpandingNotification = row; |
| 415 | } |
| 416 | |
| 417 | public ExpandableNotificationRow getExpandingNotification() { |
| 418 | return mExpandingNotification; |
| 419 | } |
| 420 | |
| 421 | public int getExpandAnimationTopChange() { |
| 422 | return mExpandAnimationTopChange; |
| 423 | } |
Lucas Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame] | 424 | |
| 425 | /** |
Lucas Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame] | 426 | * @return {@code true } when shade is completely dark: in AOD or ambient display. |
| 427 | */ |
| 428 | public boolean isFullyDark() { |
Lucas Dupin | b561eda | 2018-04-09 17:25:04 -0700 | [diff] [blame] | 429 | return mDarkAmount == 1; |
Lucas Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame] | 430 | } |
| 431 | |
| 432 | public void setDarkTopPadding(int darkTopPadding) { |
| 433 | mDarkTopPadding = darkTopPadding; |
| 434 | } |
| 435 | |
| 436 | public int getDarkTopPadding() { |
| 437 | return mDarkTopPadding; |
| 438 | } |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 439 | } |