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