blob: f3d068a9d610db5cc1a8af64476b608bf4bdfe77 [file] [log] [blame]
Jorim Jaggid552d9d2014-05-07 19:41:13 +02001/*
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 Shah20790b82018-07-02 17:21:04 -070017package com.android.systemui.statusbar.notification.stack;
Jorim Jaggid552d9d2014-05-07 19:41:13 +020018
Ned Burns9eb06332019-04-23 16:02:12 -040019import android.annotation.NonNull;
Eliot Courtney5d3d2d02018-01-18 15:59:03 +090020import android.annotation.Nullable;
Selim Cinek281c2022016-10-13 19:14:43 -070021import android.content.Context;
Selim Cinek3d6ae232019-01-04 14:14:33 -080022import android.util.MathUtils;
Jorim Jaggid552d9d2014-05-07 19:41:13 +020023import android.view.View;
Selim Cineka59ecc32015-04-07 10:51:49 -070024
Kevina97ea052018-09-11 13:53:18 -070025import com.android.systemui.Dependency;
Selim Cinek281c2022016-10-13 19:14:43 -070026import com.android.systemui.R;
Gus Prevase2d6f042018-10-17 15:25:30 -040027import com.android.systemui.statusbar.NotificationShelf;
28import com.android.systemui.statusbar.StatusBarState;
Ned Burnsf81c4c42019-01-07 14:10:43 -050029import com.android.systemui.statusbar.notification.collection.NotificationEntry;
Rohan Shah20790b82018-07-02 17:21:04 -070030import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
31import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
32import com.android.systemui.statusbar.notification.row.ExpandableView;
Ned Burns9eb06332019-04-23 16:02:12 -040033import com.android.systemui.statusbar.notification.stack.StackScrollAlgorithm.SectionProvider;
Selim Cinekc3fec682019-06-06 18:11:07 -070034import com.android.systemui.statusbar.policy.HeadsUpManager;
Jorim Jaggid552d9d2014-05-07 19:41:13 +020035
36import java.util.ArrayList;
37
38/**
39 * A global state to track all input states for the algorithm.
40 */
41public class AmbientState {
Gus Prevase2d6f042018-10-17 15:25:30 -040042
Selim Cinek5040f2e2019-02-14 18:22:42 -080043 private static final float MAX_PULSE_HEIGHT = 100000f;
Gus Prevase2d6f042018-10-17 15:25:30 -040044
Ned Burns9eb06332019-04-23 16:02:12 -040045 private final SectionProvider mSectionProvider;
Dave Mankoffa4d195d2018-11-16 13:33:27 -050046 private ArrayList<ExpandableView> mDraggedViews = new ArrayList<>();
Jorim Jaggid552d9d2014-05-07 19:41:13 +020047 private int mScrollY;
Gus Prevas0fa58d62019-01-11 13:58:40 -050048 private int mAnchorViewIndex;
49 private int mAnchorViewY;
Jorim Jaggid552d9d2014-05-07 19:41:13 +020050 private boolean mDimmed;
Selim Cineka32ab602014-06-11 15:06:01 +020051 private ActivatableNotificationView mActivatedChild;
Selim Cinek8d9ff9c2014-05-12 15:13:04 +020052 private float mOverScrollTopAmount;
53 private float mOverScrollBottomAmount;
Selim Cinekdb167372016-11-17 15:41:17 -080054 private int mSpeedBumpIndex = -1;
Selim Cinekc1d9ab22019-05-21 18:08:30 -070055 private boolean mDozing;
Jorim Jaggiae441282014-08-01 02:45:18 +020056 private boolean mHideSensitive;
Selim Cineka59ecc32015-04-07 10:51:49 -070057 private float mStackTranslation;
Selim Cinekb8f09cf2015-03-16 17:09:28 -070058 private int mLayoutHeight;
59 private int mTopPadding;
60 private boolean mShadeExpanded;
61 private float mMaxHeadsUpTranslation;
Selim Cinek9c17b772015-07-07 20:37:09 -070062 private boolean mDismissAllInProgress;
Selim Cinekbc243a92016-09-27 16:35:13 -070063 private int mLayoutMinHeight;
Selim Cinek281c2022016-10-13 19:14:43 -070064 private NotificationShelf mShelf;
65 private int mZDistanceBetweenElements;
66 private int mBaseZHeight;
Selim Cinek91d4cba2016-11-10 19:59:48 -080067 private int mMaxLayoutHeight;
Selim Cinekdb167372016-11-17 15:41:17 -080068 private ActivatableNotificationView mLastVisibleBackgroundChild;
Selim Cinek727903c2016-12-06 17:28:10 -080069 private float mCurrentScrollVelocity;
Selim Cinek355652a2016-12-07 13:32:12 -080070 private int mStatusBarState;
Selim Cinekd5ab6452016-12-08 16:34:00 -080071 private float mExpandingVelocity;
72 private boolean mPanelTracking;
73 private boolean mExpansionChanging;
Selim Cinekfcff4c62016-12-27 14:26:06 +010074 private boolean mPanelFullWidth;
yoshiki iguchi4e30e762018-02-06 12:09:23 +090075 private boolean mPulsing;
Selim Cinekec29d342017-05-05 18:31:49 -070076 private boolean mUnlockHintRunning;
Selim Cinek5cf1d052017-06-01 17:36:46 -070077 private boolean mQsCustomizerShowing;
Selim Cinek1f624952017-06-08 19:11:50 -070078 private int mIntrinsicPadding;
Selim Cinek2627d722018-01-19 12:16:49 -080079 private int mExpandAnimationTopChange;
80 private ExpandableNotificationRow mExpandingNotification;
Selim Cinek195dfc52019-05-30 19:35:05 -070081 private float mHideAmount;
shawnlin5be1f7c2018-05-21 20:50:54 +080082 private boolean mAppearing;
Selim Cinek5040f2e2019-02-14 18:22:42 -080083 private float mPulseHeight = MAX_PULSE_HEIGHT;
Selim Cinek3d6ae232019-01-04 14:14:33 -080084 private float mDozeAmount = 0.0f;
Selim Cinekc3fec682019-06-06 18:11:07 -070085 private HeadsUpManager mHeadUpManager;
Selim Cinekb0fada62019-06-17 19:03:59 -070086 private Runnable mOnPulseHeightChangedListener;
Selim Cinek281c2022016-10-13 19:14:43 -070087
Ned Burns9eb06332019-04-23 16:02:12 -040088 public AmbientState(
89 Context context,
Selim Cinekc3fec682019-06-06 18:11:07 -070090 @NonNull SectionProvider sectionProvider,
91 HeadsUpManager headsUpManager) {
Ned Burns9eb06332019-04-23 16:02:12 -040092 mSectionProvider = sectionProvider;
Selim Cinekc3fec682019-06-06 18:11:07 -070093 mHeadUpManager = headsUpManager;
Selim Cinek281c2022016-10-13 19:14:43 -070094 reload(context);
95 }
96
97 /**
98 * Reload the dimens e.g. if the density changed.
99 */
100 public void reload(Context context) {
Selim Cinek2627d722018-01-19 12:16:49 -0800101 mZDistanceBetweenElements = getZDistanceBetweenElements(context);
102 mBaseZHeight = getBaseHeight(mZDistanceBetweenElements);
103 }
104
105 private static int getZDistanceBetweenElements(Context context) {
106 return Math.max(1, context.getResources()
Selim Cinek281c2022016-10-13 19:14:43 -0700107 .getDimensionPixelSize(R.dimen.z_distance_between_notifications));
Selim Cinek2627d722018-01-19 12:16:49 -0800108 }
109
110 private static int getBaseHeight(int zdistanceBetweenElements) {
111 return 4 * zdistanceBetweenElements;
112 }
113
114 /**
115 * @return the launch height for notifications that are launched
116 */
117 public static int getNotificationLaunchHeight(Context context) {
118 int zDistance = getZDistanceBetweenElements(context);
119 return getBaseHeight(zDistance) * 2;
Selim Cinek281c2022016-10-13 19:14:43 -0700120 }
121
122 /**
123 * @return the basic Z height on which notifications remain.
124 */
125 public int getBaseZHeight() {
126 return mBaseZHeight;
127 }
128
129 /**
130 * @return the distance in Z between two overlaying notifications.
131 */
132 public int getZDistanceBetweenElements() {
133 return mZDistanceBetweenElements;
134 }
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200135
136 public int getScrollY() {
137 return mScrollY;
138 }
139
140 public void setScrollY(int scrollY) {
141 this.mScrollY = scrollY;
142 }
143
Gus Prevas0fa58d62019-01-11 13:58:40 -0500144 /**
145 * Index of the child view whose Y position on screen is returned by {@link #getAnchorViewY()}.
146 * Other views are laid out outwards from this view in both directions.
147 */
148 public int getAnchorViewIndex() {
149 return mAnchorViewIndex;
150 }
151
152 public void setAnchorViewIndex(int anchorViewIndex) {
153 mAnchorViewIndex = anchorViewIndex;
154 }
155
156 /** Current Y position of the view at {@link #getAnchorViewIndex()}. */
157 public int getAnchorViewY() {
158 return mAnchorViewY;
159 }
160
161 public void setAnchorViewY(int anchorViewY) {
162 mAnchorViewY = anchorViewY;
163 }
164
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500165 /** Call when dragging begins. */
166 public void onBeginDrag(ExpandableView view) {
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200167 mDraggedViews.add(view);
168 }
169
170 public void onDragFinished(View view) {
171 mDraggedViews.remove(view);
172 }
173
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500174 public ArrayList<ExpandableView> getDraggedViews() {
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200175 return mDraggedViews;
176 }
177
178 /**
179 * @param dimmed Whether we are in a dimmed state (on the lockscreen), where the backgrounds are
180 * translucent and everything is scaled back a bit.
181 */
182 public void setDimmed(boolean dimmed) {
183 mDimmed = dimmed;
184 }
185
Selim Cinek195dfc52019-05-30 19:35:05 -0700186 /** While dozing, we draw as little as possible, assuming a black background */
Selim Cinekc1d9ab22019-05-21 18:08:30 -0700187 public void setDozing(boolean dozing) {
188 mDozing = dozing;
John Spurlockbf370992014-06-17 13:58:31 -0400189 }
190
Selim Cinek195dfc52019-05-30 19:35:05 -0700191 /** Hide ratio of the status bar **/
192 public void setHideAmount(float hidemount) {
193 if (hidemount == 1.0f && mHideAmount != hidemount) {
194 // Whenever we are fully hidden, let's reset the pulseHeight again
Selim Cinekb0fada62019-06-17 19:03:59 -0700195 setPulseHeight(MAX_PULSE_HEIGHT);
Selim Cinek5040f2e2019-02-14 18:22:42 -0800196 }
Selim Cinek195dfc52019-05-30 19:35:05 -0700197 mHideAmount = hidemount;
Lucas Dupinb561eda2018-04-09 17:25:04 -0700198 }
199
Selim Cinek195dfc52019-05-30 19:35:05 -0700200 /** Returns the hide ratio of the status bar */
201 public float getHideAmount() {
202 return mHideAmount;
Lucas Dupinb561eda2018-04-09 17:25:04 -0700203 }
204
Jorim Jaggiae441282014-08-01 02:45:18 +0200205 public void setHideSensitive(boolean hideSensitive) {
206 mHideSensitive = hideSensitive;
207 }
208
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200209 /**
210 * In dimmed mode, a child can be activated, which happens on the first tap of the double-tap
211 * interaction. This child is then scaled normally and its background is fully opaque.
212 */
Selim Cineka32ab602014-06-11 15:06:01 +0200213 public void setActivatedChild(ActivatableNotificationView activatedChild) {
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200214 mActivatedChild = activatedChild;
215 }
216
217 public boolean isDimmed() {
Selim Cinekf434a742019-05-28 17:39:49 -0700218 // While we are expanding from pulse, we want the notifications not to be dimmed, otherwise
219 // you'd see the difference to the pulsing notification
220 return mDimmed && !(isPulseExpanding() && mDozeAmount == 1.0f);
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200221 }
222
Selim Cinekc1d9ab22019-05-21 18:08:30 -0700223 public boolean isDozing() {
224 return mDozing;
John Spurlockbf370992014-06-17 13:58:31 -0400225 }
226
Jorim Jaggiae441282014-08-01 02:45:18 +0200227 public boolean isHideSensitive() {
228 return mHideSensitive;
229 }
230
Selim Cineka32ab602014-06-11 15:06:01 +0200231 public ActivatableNotificationView getActivatedChild() {
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200232 return mActivatedChild;
233 }
Selim Cinek8d9ff9c2014-05-12 15:13:04 +0200234
235 public void setOverScrollAmount(float amount, boolean onTop) {
236 if (onTop) {
237 mOverScrollTopAmount = amount;
238 } else {
239 mOverScrollBottomAmount = amount;
240 }
241 }
242
243 public float getOverScrollAmount(boolean top) {
244 return top ? mOverScrollTopAmount : mOverScrollBottomAmount;
245 }
Selim Cinekc27437b2014-05-14 10:23:33 +0200246
Selim Cinekdb167372016-11-17 15:41:17 -0800247 public int getSpeedBumpIndex() {
248 return mSpeedBumpIndex;
Selim Cinekc27437b2014-05-14 10:23:33 +0200249 }
250
Selim Cinekdb167372016-11-17 15:41:17 -0800251 public void setSpeedBumpIndex(int shelfIndex) {
252 mSpeedBumpIndex = shelfIndex;
Selim Cinekc27437b2014-05-14 10:23:33 +0200253 }
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700254
Ned Burns9eb06332019-04-23 16:02:12 -0400255 public SectionProvider getSectionProvider() {
256 return mSectionProvider;
Gus Prevase2d6f042018-10-17 15:25:30 -0400257 }
258
Selim Cineka59ecc32015-04-07 10:51:49 -0700259 public float getStackTranslation() {
260 return mStackTranslation;
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700261 }
262
Selim Cineka59ecc32015-04-07 10:51:49 -0700263 public void setStackTranslation(float stackTranslation) {
264 mStackTranslation = stackTranslation;
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700265 }
266
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700267 public void setLayoutHeight(int layoutHeight) {
268 mLayoutHeight = layoutHeight;
269 }
270
Selim Cineka59ecc32015-04-07 10:51:49 -0700271 public float getTopPadding() {
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700272 return mTopPadding;
273 }
274
275 public void setTopPadding(int topPadding) {
276 mTopPadding = topPadding;
277 }
278
279 public int getInnerHeight() {
Selim Cinek3d6ae232019-01-04 14:14:33 -0800280 return getInnerHeight(false /* ignorePulseHeight */);
281 }
282
283 /**
284 * @param ignorePulseHeight ignore the pulse height for this request
285 * @return the inner height of the algorithm.
286 */
287 public int getInnerHeight(boolean ignorePulseHeight) {
Selim Cinek5040f2e2019-02-14 18:22:42 -0800288 if (mDozeAmount == 1.0f && !isPulseExpanding()) {
289 return mShelf.getHeight();
290 }
Selim Cinek3d6ae232019-01-04 14:14:33 -0800291 int height = Math.max(mLayoutMinHeight,
292 Math.min(mLayoutHeight, mMaxLayoutHeight) - mTopPadding);
293 if (ignorePulseHeight) {
294 return height;
295 }
Selim Cinek5040f2e2019-02-14 18:22:42 -0800296 float pulseHeight = Math.min(mPulseHeight, (float) height);
Selim Cinek3d6ae232019-01-04 14:14:33 -0800297 return (int) MathUtils.lerp(height, pulseHeight, mDozeAmount);
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700298 }
299
Selim Cinek5040f2e2019-02-14 18:22:42 -0800300 public boolean isPulseExpanding() {
Selim Cinek195dfc52019-05-30 19:35:05 -0700301 return mPulseHeight != MAX_PULSE_HEIGHT && mDozeAmount != 0.0f && mHideAmount != 1.0f;
Selim Cinek5040f2e2019-02-14 18:22:42 -0800302 }
303
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700304 public boolean isShadeExpanded() {
305 return mShadeExpanded;
306 }
307
308 public void setShadeExpanded(boolean shadeExpanded) {
309 mShadeExpanded = shadeExpanded;
310 }
311
312 public void setMaxHeadsUpTranslation(float maxHeadsUpTranslation) {
313 mMaxHeadsUpTranslation = maxHeadsUpTranslation;
314 }
315
316 public float getMaxHeadsUpTranslation() {
317 return mMaxHeadsUpTranslation;
318 }
Selim Cineka59ecc32015-04-07 10:51:49 -0700319
Selim Cinek9c17b772015-07-07 20:37:09 -0700320 public void setDismissAllInProgress(boolean dismissAllInProgress) {
321 mDismissAllInProgress = dismissAllInProgress;
322 }
323
324 public boolean isDismissAllInProgress() {
325 return mDismissAllInProgress;
326 }
Selim Cinekbc243a92016-09-27 16:35:13 -0700327
328 public void setLayoutMinHeight(int layoutMinHeight) {
329 mLayoutMinHeight = layoutMinHeight;
330 }
Selim Cinek281c2022016-10-13 19:14:43 -0700331
332 public void setShelf(NotificationShelf shelf) {
333 mShelf = shelf;
334 }
335
Eliot Courtney5d3d2d02018-01-18 15:59:03 +0900336 @Nullable
Selim Cinek281c2022016-10-13 19:14:43 -0700337 public NotificationShelf getShelf() {
338 return mShelf;
339 }
Selim Cinek91d4cba2016-11-10 19:59:48 -0800340
341 public void setLayoutMaxHeight(int maxLayoutHeight) {
342 mMaxLayoutHeight = maxLayoutHeight;
343 }
Selim Cinekdb167372016-11-17 15:41:17 -0800344
345 /**
346 * Sets the last visible view of the host layout, that has a background, i.e the very last
347 * view in the shade, without the clear all button.
348 */
349 public void setLastVisibleBackgroundChild(
350 ActivatableNotificationView lastVisibleBackgroundChild) {
351 mLastVisibleBackgroundChild = lastVisibleBackgroundChild;
352 }
353
354 public ActivatableNotificationView getLastVisibleBackgroundChild() {
355 return mLastVisibleBackgroundChild;
356 }
Selim Cinek727903c2016-12-06 17:28:10 -0800357
358 public void setCurrentScrollVelocity(float currentScrollVelocity) {
359 mCurrentScrollVelocity = currentScrollVelocity;
360 }
361
362 public float getCurrentScrollVelocity() {
363 return mCurrentScrollVelocity;
364 }
Selim Cinek355652a2016-12-07 13:32:12 -0800365
366 public boolean isOnKeyguard() {
367 return mStatusBarState == StatusBarState.KEYGUARD;
368 }
369
370 public void setStatusBarState(int statusBarState) {
371 mStatusBarState = statusBarState;
372 }
Selim Cinekd5ab6452016-12-08 16:34:00 -0800373
374 public void setExpandingVelocity(float expandingVelocity) {
375 mExpandingVelocity = expandingVelocity;
376 }
377
378 public void setExpansionChanging(boolean expansionChanging) {
379 mExpansionChanging = expansionChanging;
380 }
381
382 public boolean isExpansionChanging() {
383 return mExpansionChanging;
384 }
385
386 public float getExpandingVelocity() {
387 return mExpandingVelocity;
388 }
389
390 public void setPanelTracking(boolean panelTracking) {
391 mPanelTracking = panelTracking;
392 }
393
Selim Cinekbe2c4432017-05-30 12:11:09 -0700394 public boolean hasPulsingNotifications() {
Selim Cinekc3fec682019-06-06 18:11:07 -0700395 return mPulsing && mHeadUpManager != null && mHeadUpManager.hasNotifications();
Adrian Roosd83e9992017-03-16 15:17:57 -0700396 }
397
yoshiki iguchi4e30e762018-02-06 12:09:23 +0900398 public void setPulsing(boolean hasPulsing) {
Selim Cinekebf42342017-07-13 15:46:10 +0200399 mPulsing = hasPulsing;
400 }
401
Selim Cinekd0b48e32019-05-24 20:49:23 -0700402 /**
403 * @return if we're pulsing in general
404 */
405 public boolean isPulsing() {
406 return mPulsing;
407 }
408
Ned Burnsf81c4c42019-01-07 14:10:43 -0500409 public boolean isPulsing(NotificationEntry entry) {
Selim Cinekc3fec682019-06-06 18:11:07 -0700410 if (!mPulsing || mHeadUpManager == null) {
Selim Cinekebf42342017-07-13 15:46:10 +0200411 return false;
412 }
Selim Cinekc3fec682019-06-06 18:11:07 -0700413 return mHeadUpManager.isAlerting(entry.key);
Adrian Roosd83e9992017-03-16 15:17:57 -0700414 }
415
Selim Cinekd5ab6452016-12-08 16:34:00 -0800416 public boolean isPanelTracking() {
417 return mPanelTracking;
418 }
Selim Cinekfcff4c62016-12-27 14:26:06 +0100419
420 public boolean isPanelFullWidth() {
421 return mPanelFullWidth;
422 }
423
424 public void setPanelFullWidth(boolean panelFullWidth) {
425 mPanelFullWidth = panelFullWidth;
426 }
Selim Cinekec29d342017-05-05 18:31:49 -0700427
428 public void setUnlockHintRunning(boolean unlockHintRunning) {
429 mUnlockHintRunning = unlockHintRunning;
430 }
431
432 public boolean isUnlockHintRunning() {
433 return mUnlockHintRunning;
434 }
Selim Cinek5cf1d052017-06-01 17:36:46 -0700435
436 public boolean isQsCustomizerShowing() {
437 return mQsCustomizerShowing;
438 }
439
440 public void setQsCustomizerShowing(boolean qsCustomizerShowing) {
441 mQsCustomizerShowing = qsCustomizerShowing;
442 }
Selim Cinek1f624952017-06-08 19:11:50 -0700443
444 public void setIntrinsicPadding(int intrinsicPadding) {
445 mIntrinsicPadding = intrinsicPadding;
446 }
447
448 public int getIntrinsicPadding() {
449 return mIntrinsicPadding;
450 }
Selim Cinekebf42342017-07-13 15:46:10 +0200451
452 /**
Selim Cinekebf42342017-07-13 15:46:10 +0200453 * @return whether a view is dozing and not pulsing right now
454 */
455 public boolean isDozingAndNotPulsing(ExpandableView view) {
456 if (view instanceof ExpandableNotificationRow) {
457 return isDozingAndNotPulsing((ExpandableNotificationRow) view);
458 }
459 return false;
460 }
461
462 /**
463 * @return whether a row is dozing and not pulsing right now
464 */
465 public boolean isDozingAndNotPulsing(ExpandableNotificationRow row) {
Selim Cinekc1d9ab22019-05-21 18:08:30 -0700466 return isDozing() && !isPulsing(row.getEntry());
Selim Cinekebf42342017-07-13 15:46:10 +0200467 }
Selim Cinek2627d722018-01-19 12:16:49 -0800468
469 public void setExpandAnimationTopChange(int expandAnimationTopChange) {
470 mExpandAnimationTopChange = expandAnimationTopChange;
471 }
472
473 public void setExpandingNotification(ExpandableNotificationRow row) {
474 mExpandingNotification = row;
475 }
476
477 public ExpandableNotificationRow getExpandingNotification() {
478 return mExpandingNotification;
479 }
480
481 public int getExpandAnimationTopChange() {
482 return mExpandAnimationTopChange;
483 }
Lucas Dupin16cfe452018-02-08 13:14:50 -0800484
485 /**
Selim Cinek195dfc52019-05-30 19:35:05 -0700486 * @return {@code true } when shade is completely hidden: in AOD, ambient display or when
487 * bypassing.
Lucas Dupin16cfe452018-02-08 13:14:50 -0800488 */
Selim Cinek195dfc52019-05-30 19:35:05 -0700489 public boolean isFullyHidden() {
490 return mHideAmount == 1;
Lucas Dupin16cfe452018-02-08 13:14:50 -0800491 }
492
Selim Cinek195dfc52019-05-30 19:35:05 -0700493 public boolean isHiddenAtAll() {
494 return mHideAmount != 0;
Gus Prevas99ba4ba2018-10-01 16:40:23 -0400495 }
496
shawnlin5be1f7c2018-05-21 20:50:54 +0800497 public void setAppearing(boolean appearing) {
498 mAppearing = appearing;
499 }
500
501 public boolean isAppearing() {
502 return mAppearing;
503 }
Selim Cinek3d6ae232019-01-04 14:14:33 -0800504
Selim Cinek5040f2e2019-02-14 18:22:42 -0800505 public void setPulseHeight(float height) {
Selim Cinekb0fada62019-06-17 19:03:59 -0700506 if (height != mPulseHeight) {
507 mPulseHeight = height;
508 if (mOnPulseHeightChangedListener != null) {
509 mOnPulseHeightChangedListener.run();
510 }
511 }
512 }
513
514 public float getPulseHeight() {
515 if (mPulseHeight == MAX_PULSE_HEIGHT) {
516 // If we're not pulse expanding, the height should be 0
517 return 0;
518 }
519 return mPulseHeight;
Selim Cinek3d6ae232019-01-04 14:14:33 -0800520 }
521
522 public void setDozeAmount(float dozeAmount) {
523 if (dozeAmount != mDozeAmount) {
524 mDozeAmount = dozeAmount;
Selim Cinek459aee32019-02-20 11:18:56 -0800525 if (dozeAmount == 0.0f || dozeAmount == 1.0f) {
Selim Cinek5040f2e2019-02-14 18:22:42 -0800526 // We woke all the way up, let's reset the pulse height
Selim Cinekb0fada62019-06-17 19:03:59 -0700527 setPulseHeight(MAX_PULSE_HEIGHT);
Selim Cinek3d6ae232019-01-04 14:14:33 -0800528 }
529 }
530 }
Selim Cinekae55d832019-02-22 17:43:43 -0800531
532 /**
533 * Is the device fully awake, which is different from not tark at all when there are pulsing
534 * notifications.
535 */
536 public boolean isFullyAwake() {
537 return mDozeAmount == 0.0f;
538 }
Selim Cinekb0fada62019-06-17 19:03:59 -0700539
540 public void setOnPulseHeightChangedListener(Runnable onPulseHeightChangedListener) {
541 mOnPulseHeightChangedListener = onPulseHeightChangedListener;
542 }
543
544 public Runnable getOnPulseHeightChangedListener() {
545 return mOnPulseHeightChangedListener;
546 }
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200547}