blob: b4220f1da715867d242b5cf02ff3f1cdf9a458f0 [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
Selim Cinek281c2022016-10-13 19:14:43 -070025import com.android.systemui.R;
Gus Prevase2d6f042018-10-17 15:25:30 -040026import com.android.systemui.statusbar.NotificationShelf;
27import com.android.systemui.statusbar.StatusBarState;
Ned Burnsf81c4c42019-01-07 14:10:43 -050028import com.android.systemui.statusbar.notification.collection.NotificationEntry;
Rohan Shah20790b82018-07-02 17:21:04 -070029import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
30import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
31import com.android.systemui.statusbar.notification.row.ExpandableView;
Ned Burns9eb06332019-04-23 16:02:12 -040032import com.android.systemui.statusbar.notification.stack.StackScrollAlgorithm.SectionProvider;
Selim Cinekc3fec682019-06-06 18:11:07 -070033import com.android.systemui.statusbar.policy.HeadsUpManager;
Jorim Jaggid552d9d2014-05-07 19:41:13 +020034
35import java.util.ArrayList;
36
37/**
38 * A global state to track all input states for the algorithm.
39 */
40public class AmbientState {
Gus Prevase2d6f042018-10-17 15:25:30 -040041
Selim Cinek5040f2e2019-02-14 18:22:42 -080042 private static final float MAX_PULSE_HEIGHT = 100000f;
Gus Prevase2d6f042018-10-17 15:25:30 -040043
Ned Burns9eb06332019-04-23 16:02:12 -040044 private final SectionProvider mSectionProvider;
Dave Mankoffa4d195d2018-11-16 13:33:27 -050045 private ArrayList<ExpandableView> mDraggedViews = new ArrayList<>();
Jorim Jaggid552d9d2014-05-07 19:41:13 +020046 private int mScrollY;
Gus Prevas0fa58d62019-01-11 13:58:40 -050047 private int mAnchorViewIndex;
48 private int mAnchorViewY;
Jorim Jaggid552d9d2014-05-07 19:41:13 +020049 private boolean mDimmed;
Selim Cineka32ab602014-06-11 15:06:01 +020050 private ActivatableNotificationView mActivatedChild;
Selim Cinek8d9ff9c2014-05-12 15:13:04 +020051 private float mOverScrollTopAmount;
52 private float mOverScrollBottomAmount;
Selim Cinekdb167372016-11-17 15:41:17 -080053 private int mSpeedBumpIndex = -1;
Selim Cinekc1d9ab22019-05-21 18:08:30 -070054 private boolean mDozing;
Jorim Jaggiae441282014-08-01 02:45:18 +020055 private boolean mHideSensitive;
Selim Cineka59ecc32015-04-07 10:51:49 -070056 private float mStackTranslation;
Selim Cinekb8f09cf2015-03-16 17:09:28 -070057 private int mLayoutHeight;
58 private int mTopPadding;
59 private boolean mShadeExpanded;
60 private float mMaxHeadsUpTranslation;
Selim Cinek9c17b772015-07-07 20:37:09 -070061 private boolean mDismissAllInProgress;
Selim Cinekbc243a92016-09-27 16:35:13 -070062 private int mLayoutMinHeight;
Selim Cinek281c2022016-10-13 19:14:43 -070063 private NotificationShelf mShelf;
64 private int mZDistanceBetweenElements;
65 private int mBaseZHeight;
Selim Cinek91d4cba2016-11-10 19:59:48 -080066 private int mMaxLayoutHeight;
Selim Cinek4b9710e2020-05-26 15:54:24 -070067 private ExpandableView mLastVisibleBackgroundChild;
Selim Cinek727903c2016-12-06 17:28:10 -080068 private float mCurrentScrollVelocity;
Selim Cinek355652a2016-12-07 13:32:12 -080069 private int mStatusBarState;
Selim Cinekd5ab6452016-12-08 16:34:00 -080070 private float mExpandingVelocity;
71 private boolean mPanelTracking;
72 private boolean mExpansionChanging;
Selim Cinekfcff4c62016-12-27 14:26:06 +010073 private boolean mPanelFullWidth;
yoshiki iguchi4e30e762018-02-06 12:09:23 +090074 private boolean mPulsing;
Selim Cinekec29d342017-05-05 18:31:49 -070075 private boolean mUnlockHintRunning;
Selim Cinek5cf1d052017-06-01 17:36:46 -070076 private boolean mQsCustomizerShowing;
Selim Cinek1f624952017-06-08 19:11:50 -070077 private int mIntrinsicPadding;
Selim Cinek2627d722018-01-19 12:16:49 -080078 private int mExpandAnimationTopChange;
79 private ExpandableNotificationRow mExpandingNotification;
Selim Cinek195dfc52019-05-30 19:35:05 -070080 private float mHideAmount;
shawnlin5be1f7c2018-05-21 20:50:54 +080081 private boolean mAppearing;
Selim Cinek5040f2e2019-02-14 18:22:42 -080082 private float mPulseHeight = MAX_PULSE_HEIGHT;
Selim Cinek3d6ae232019-01-04 14:14:33 -080083 private float mDozeAmount = 0.0f;
Selim Cinekc3fec682019-06-06 18:11:07 -070084 private HeadsUpManager mHeadUpManager;
Selim Cinekb0fada62019-06-17 19:03:59 -070085 private Runnable mOnPulseHeightChangedListener;
Selim Cinek281c2022016-10-13 19:14:43 -070086
Ned Burns9eb06332019-04-23 16:02:12 -040087 public AmbientState(
88 Context context,
Selim Cinekc3fec682019-06-06 18:11:07 -070089 @NonNull SectionProvider sectionProvider,
90 HeadsUpManager headsUpManager) {
Ned Burns9eb06332019-04-23 16:02:12 -040091 mSectionProvider = sectionProvider;
Selim Cinekc3fec682019-06-06 18:11:07 -070092 mHeadUpManager = headsUpManager;
Selim Cinek281c2022016-10-13 19:14:43 -070093 reload(context);
94 }
95
96 /**
97 * Reload the dimens e.g. if the density changed.
98 */
99 public void reload(Context context) {
Selim Cinek2627d722018-01-19 12:16:49 -0800100 mZDistanceBetweenElements = getZDistanceBetweenElements(context);
101 mBaseZHeight = getBaseHeight(mZDistanceBetweenElements);
102 }
103
104 private static int getZDistanceBetweenElements(Context context) {
105 return Math.max(1, context.getResources()
Selim Cinek281c2022016-10-13 19:14:43 -0700106 .getDimensionPixelSize(R.dimen.z_distance_between_notifications));
Selim Cinek2627d722018-01-19 12:16:49 -0800107 }
108
109 private static int getBaseHeight(int zdistanceBetweenElements) {
110 return 4 * zdistanceBetweenElements;
111 }
112
113 /**
114 * @return the launch height for notifications that are launched
115 */
116 public static int getNotificationLaunchHeight(Context context) {
117 int zDistance = getZDistanceBetweenElements(context);
118 return getBaseHeight(zDistance) * 2;
Selim Cinek281c2022016-10-13 19:14:43 -0700119 }
120
121 /**
122 * @return the basic Z height on which notifications remain.
123 */
124 public int getBaseZHeight() {
125 return mBaseZHeight;
126 }
127
128 /**
129 * @return the distance in Z between two overlaying notifications.
130 */
131 public int getZDistanceBetweenElements() {
132 return mZDistanceBetweenElements;
133 }
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200134
135 public int getScrollY() {
136 return mScrollY;
137 }
138
139 public void setScrollY(int scrollY) {
140 this.mScrollY = scrollY;
141 }
142
Gus Prevas0fa58d62019-01-11 13:58:40 -0500143 /**
144 * Index of the child view whose Y position on screen is returned by {@link #getAnchorViewY()}.
145 * Other views are laid out outwards from this view in both directions.
146 */
147 public int getAnchorViewIndex() {
148 return mAnchorViewIndex;
149 }
150
151 public void setAnchorViewIndex(int anchorViewIndex) {
152 mAnchorViewIndex = anchorViewIndex;
153 }
154
155 /** Current Y position of the view at {@link #getAnchorViewIndex()}. */
156 public int getAnchorViewY() {
157 return mAnchorViewY;
158 }
159
160 public void setAnchorViewY(int anchorViewY) {
161 mAnchorViewY = anchorViewY;
162 }
163
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500164 /** Call when dragging begins. */
165 public void onBeginDrag(ExpandableView view) {
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200166 mDraggedViews.add(view);
167 }
168
169 public void onDragFinished(View view) {
170 mDraggedViews.remove(view);
171 }
172
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500173 public ArrayList<ExpandableView> getDraggedViews() {
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200174 return mDraggedViews;
175 }
176
177 /**
178 * @param dimmed Whether we are in a dimmed state (on the lockscreen), where the backgrounds are
179 * translucent and everything is scaled back a bit.
180 */
181 public void setDimmed(boolean dimmed) {
182 mDimmed = dimmed;
183 }
184
Selim Cinek195dfc52019-05-30 19:35:05 -0700185 /** While dozing, we draw as little as possible, assuming a black background */
Selim Cinekc1d9ab22019-05-21 18:08:30 -0700186 public void setDozing(boolean dozing) {
187 mDozing = dozing;
John Spurlockbf370992014-06-17 13:58:31 -0400188 }
189
Selim Cinek195dfc52019-05-30 19:35:05 -0700190 /** Hide ratio of the status bar **/
191 public void setHideAmount(float hidemount) {
192 if (hidemount == 1.0f && mHideAmount != hidemount) {
193 // Whenever we are fully hidden, let's reset the pulseHeight again
Selim Cinekb0fada62019-06-17 19:03:59 -0700194 setPulseHeight(MAX_PULSE_HEIGHT);
Selim Cinek5040f2e2019-02-14 18:22:42 -0800195 }
Selim Cinek195dfc52019-05-30 19:35:05 -0700196 mHideAmount = hidemount;
Lucas Dupinb561eda2018-04-09 17:25:04 -0700197 }
198
Selim Cinek195dfc52019-05-30 19:35:05 -0700199 /** Returns the hide ratio of the status bar */
200 public float getHideAmount() {
201 return mHideAmount;
Lucas Dupinb561eda2018-04-09 17:25:04 -0700202 }
203
Jorim Jaggiae441282014-08-01 02:45:18 +0200204 public void setHideSensitive(boolean hideSensitive) {
205 mHideSensitive = hideSensitive;
206 }
207
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200208 /**
209 * In dimmed mode, a child can be activated, which happens on the first tap of the double-tap
210 * interaction. This child is then scaled normally and its background is fully opaque.
211 */
Selim Cineka32ab602014-06-11 15:06:01 +0200212 public void setActivatedChild(ActivatableNotificationView activatedChild) {
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200213 mActivatedChild = activatedChild;
214 }
215
216 public boolean isDimmed() {
Selim Cinekf434a742019-05-28 17:39:49 -0700217 // While we are expanding from pulse, we want the notifications not to be dimmed, otherwise
218 // you'd see the difference to the pulsing notification
219 return mDimmed && !(isPulseExpanding() && mDozeAmount == 1.0f);
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200220 }
221
Selim Cinekc1d9ab22019-05-21 18:08:30 -0700222 public boolean isDozing() {
223 return mDozing;
John Spurlockbf370992014-06-17 13:58:31 -0400224 }
225
Jorim Jaggiae441282014-08-01 02:45:18 +0200226 public boolean isHideSensitive() {
227 return mHideSensitive;
228 }
229
Selim Cineka32ab602014-06-11 15:06:01 +0200230 public ActivatableNotificationView getActivatedChild() {
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200231 return mActivatedChild;
232 }
Selim Cinek8d9ff9c2014-05-12 15:13:04 +0200233
234 public void setOverScrollAmount(float amount, boolean onTop) {
235 if (onTop) {
236 mOverScrollTopAmount = amount;
237 } else {
238 mOverScrollBottomAmount = amount;
239 }
240 }
241
242 public float getOverScrollAmount(boolean top) {
243 return top ? mOverScrollTopAmount : mOverScrollBottomAmount;
244 }
Selim Cinekc27437b2014-05-14 10:23:33 +0200245
Selim Cinekdb167372016-11-17 15:41:17 -0800246 public int getSpeedBumpIndex() {
247 return mSpeedBumpIndex;
Selim Cinekc27437b2014-05-14 10:23:33 +0200248 }
249
Selim Cinekdb167372016-11-17 15:41:17 -0800250 public void setSpeedBumpIndex(int shelfIndex) {
251 mSpeedBumpIndex = shelfIndex;
Selim Cinekc27437b2014-05-14 10:23:33 +0200252 }
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700253
Ned Burns9eb06332019-04-23 16:02:12 -0400254 public SectionProvider getSectionProvider() {
255 return mSectionProvider;
Gus Prevase2d6f042018-10-17 15:25:30 -0400256 }
257
Selim Cineka59ecc32015-04-07 10:51:49 -0700258 public float getStackTranslation() {
259 return mStackTranslation;
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700260 }
261
Selim Cineka59ecc32015-04-07 10:51:49 -0700262 public void setStackTranslation(float stackTranslation) {
263 mStackTranslation = stackTranslation;
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700264 }
265
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700266 public void setLayoutHeight(int layoutHeight) {
267 mLayoutHeight = layoutHeight;
268 }
269
Selim Cineka59ecc32015-04-07 10:51:49 -0700270 public float getTopPadding() {
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700271 return mTopPadding;
272 }
273
274 public void setTopPadding(int topPadding) {
275 mTopPadding = topPadding;
276 }
277
278 public int getInnerHeight() {
Selim Cinek3d6ae232019-01-04 14:14:33 -0800279 return getInnerHeight(false /* ignorePulseHeight */);
280 }
281
282 /**
283 * @param ignorePulseHeight ignore the pulse height for this request
284 * @return the inner height of the algorithm.
285 */
286 public int getInnerHeight(boolean ignorePulseHeight) {
Selim Cinek5040f2e2019-02-14 18:22:42 -0800287 if (mDozeAmount == 1.0f && !isPulseExpanding()) {
288 return mShelf.getHeight();
289 }
Selim Cinek3d6ae232019-01-04 14:14:33 -0800290 int height = Math.max(mLayoutMinHeight,
291 Math.min(mLayoutHeight, mMaxLayoutHeight) - mTopPadding);
292 if (ignorePulseHeight) {
293 return height;
294 }
Selim Cinek5040f2e2019-02-14 18:22:42 -0800295 float pulseHeight = Math.min(mPulseHeight, (float) height);
Selim Cinek3d6ae232019-01-04 14:14:33 -0800296 return (int) MathUtils.lerp(height, pulseHeight, mDozeAmount);
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700297 }
298
Selim Cinek5040f2e2019-02-14 18:22:42 -0800299 public boolean isPulseExpanding() {
Selim Cinek195dfc52019-05-30 19:35:05 -0700300 return mPulseHeight != MAX_PULSE_HEIGHT && mDozeAmount != 0.0f && mHideAmount != 1.0f;
Selim Cinek5040f2e2019-02-14 18:22:42 -0800301 }
302
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700303 public boolean isShadeExpanded() {
304 return mShadeExpanded;
305 }
306
307 public void setShadeExpanded(boolean shadeExpanded) {
308 mShadeExpanded = shadeExpanded;
309 }
310
311 public void setMaxHeadsUpTranslation(float maxHeadsUpTranslation) {
312 mMaxHeadsUpTranslation = maxHeadsUpTranslation;
313 }
314
315 public float getMaxHeadsUpTranslation() {
316 return mMaxHeadsUpTranslation;
317 }
Selim Cineka59ecc32015-04-07 10:51:49 -0700318
Selim Cinek9c17b772015-07-07 20:37:09 -0700319 public void setDismissAllInProgress(boolean dismissAllInProgress) {
320 mDismissAllInProgress = dismissAllInProgress;
321 }
322
323 public boolean isDismissAllInProgress() {
324 return mDismissAllInProgress;
325 }
Selim Cinekbc243a92016-09-27 16:35:13 -0700326
327 public void setLayoutMinHeight(int layoutMinHeight) {
328 mLayoutMinHeight = layoutMinHeight;
329 }
Selim Cinek281c2022016-10-13 19:14:43 -0700330
331 public void setShelf(NotificationShelf shelf) {
332 mShelf = shelf;
333 }
334
Eliot Courtney5d3d2d02018-01-18 15:59:03 +0900335 @Nullable
Selim Cinek281c2022016-10-13 19:14:43 -0700336 public NotificationShelf getShelf() {
337 return mShelf;
338 }
Selim Cinek91d4cba2016-11-10 19:59:48 -0800339
340 public void setLayoutMaxHeight(int maxLayoutHeight) {
341 mMaxLayoutHeight = maxLayoutHeight;
342 }
Selim Cinekdb167372016-11-17 15:41:17 -0800343
344 /**
345 * Sets the last visible view of the host layout, that has a background, i.e the very last
346 * view in the shade, without the clear all button.
347 */
348 public void setLastVisibleBackgroundChild(
Selim Cinek4b9710e2020-05-26 15:54:24 -0700349 ExpandableView lastVisibleBackgroundChild) {
Selim Cinekdb167372016-11-17 15:41:17 -0800350 mLastVisibleBackgroundChild = lastVisibleBackgroundChild;
351 }
352
Selim Cinek4b9710e2020-05-26 15:54:24 -0700353 public ExpandableView getLastVisibleBackgroundChild() {
Selim Cinekdb167372016-11-17 15:41:17 -0800354 return mLastVisibleBackgroundChild;
355 }
Selim Cinek727903c2016-12-06 17:28:10 -0800356
357 public void setCurrentScrollVelocity(float currentScrollVelocity) {
358 mCurrentScrollVelocity = currentScrollVelocity;
359 }
360
361 public float getCurrentScrollVelocity() {
362 return mCurrentScrollVelocity;
363 }
Selim Cinek355652a2016-12-07 13:32:12 -0800364
365 public boolean isOnKeyguard() {
366 return mStatusBarState == StatusBarState.KEYGUARD;
367 }
368
369 public void setStatusBarState(int statusBarState) {
370 mStatusBarState = statusBarState;
371 }
Selim Cinekd5ab6452016-12-08 16:34:00 -0800372
373 public void setExpandingVelocity(float expandingVelocity) {
374 mExpandingVelocity = expandingVelocity;
375 }
376
377 public void setExpansionChanging(boolean expansionChanging) {
378 mExpansionChanging = expansionChanging;
379 }
380
381 public boolean isExpansionChanging() {
382 return mExpansionChanging;
383 }
384
385 public float getExpandingVelocity() {
386 return mExpandingVelocity;
387 }
388
389 public void setPanelTracking(boolean panelTracking) {
390 mPanelTracking = panelTracking;
391 }
392
Selim Cinekbe2c4432017-05-30 12:11:09 -0700393 public boolean hasPulsingNotifications() {
Selim Cinekc3fec682019-06-06 18:11:07 -0700394 return mPulsing && mHeadUpManager != null && mHeadUpManager.hasNotifications();
Adrian Roosd83e9992017-03-16 15:17:57 -0700395 }
396
yoshiki iguchi4e30e762018-02-06 12:09:23 +0900397 public void setPulsing(boolean hasPulsing) {
Selim Cinekebf42342017-07-13 15:46:10 +0200398 mPulsing = hasPulsing;
399 }
400
Selim Cinekd0b48e32019-05-24 20:49:23 -0700401 /**
402 * @return if we're pulsing in general
403 */
404 public boolean isPulsing() {
405 return mPulsing;
406 }
407
Ned Burnsf81c4c42019-01-07 14:10:43 -0500408 public boolean isPulsing(NotificationEntry entry) {
Selim Cinekc3fec682019-06-06 18:11:07 -0700409 if (!mPulsing || mHeadUpManager == null) {
Selim Cinekebf42342017-07-13 15:46:10 +0200410 return false;
411 }
Ned Burns00b4b2d2019-10-17 22:09:27 -0400412 return mHeadUpManager.isAlerting(entry.getKey());
Adrian Roosd83e9992017-03-16 15:17:57 -0700413 }
414
Selim Cinekd5ab6452016-12-08 16:34:00 -0800415 public boolean isPanelTracking() {
416 return mPanelTracking;
417 }
Selim Cinekfcff4c62016-12-27 14:26:06 +0100418
419 public boolean isPanelFullWidth() {
420 return mPanelFullWidth;
421 }
422
423 public void setPanelFullWidth(boolean panelFullWidth) {
424 mPanelFullWidth = panelFullWidth;
425 }
Selim Cinekec29d342017-05-05 18:31:49 -0700426
427 public void setUnlockHintRunning(boolean unlockHintRunning) {
428 mUnlockHintRunning = unlockHintRunning;
429 }
430
431 public boolean isUnlockHintRunning() {
432 return mUnlockHintRunning;
433 }
Selim Cinek5cf1d052017-06-01 17:36:46 -0700434
435 public boolean isQsCustomizerShowing() {
436 return mQsCustomizerShowing;
437 }
438
439 public void setQsCustomizerShowing(boolean qsCustomizerShowing) {
440 mQsCustomizerShowing = qsCustomizerShowing;
441 }
Selim Cinek1f624952017-06-08 19:11:50 -0700442
443 public void setIntrinsicPadding(int intrinsicPadding) {
444 mIntrinsicPadding = intrinsicPadding;
445 }
446
447 public int getIntrinsicPadding() {
448 return mIntrinsicPadding;
449 }
Selim Cinekebf42342017-07-13 15:46:10 +0200450
451 /**
Selim Cinekebf42342017-07-13 15:46:10 +0200452 * @return whether a view is dozing and not pulsing right now
453 */
454 public boolean isDozingAndNotPulsing(ExpandableView view) {
455 if (view instanceof ExpandableNotificationRow) {
456 return isDozingAndNotPulsing((ExpandableNotificationRow) view);
457 }
458 return false;
459 }
460
461 /**
462 * @return whether a row is dozing and not pulsing right now
463 */
464 public boolean isDozingAndNotPulsing(ExpandableNotificationRow row) {
Selim Cinekc1d9ab22019-05-21 18:08:30 -0700465 return isDozing() && !isPulsing(row.getEntry());
Selim Cinekebf42342017-07-13 15:46:10 +0200466 }
Selim Cinek2627d722018-01-19 12:16:49 -0800467
468 public void setExpandAnimationTopChange(int expandAnimationTopChange) {
469 mExpandAnimationTopChange = expandAnimationTopChange;
470 }
471
472 public void setExpandingNotification(ExpandableNotificationRow row) {
473 mExpandingNotification = row;
474 }
475
476 public ExpandableNotificationRow getExpandingNotification() {
477 return mExpandingNotification;
478 }
479
480 public int getExpandAnimationTopChange() {
481 return mExpandAnimationTopChange;
482 }
Lucas Dupin16cfe452018-02-08 13:14:50 -0800483
484 /**
Selim Cinek195dfc52019-05-30 19:35:05 -0700485 * @return {@code true } when shade is completely hidden: in AOD, ambient display or when
486 * bypassing.
Lucas Dupin16cfe452018-02-08 13:14:50 -0800487 */
Selim Cinek195dfc52019-05-30 19:35:05 -0700488 public boolean isFullyHidden() {
489 return mHideAmount == 1;
Lucas Dupin16cfe452018-02-08 13:14:50 -0800490 }
491
Selim Cinek195dfc52019-05-30 19:35:05 -0700492 public boolean isHiddenAtAll() {
493 return mHideAmount != 0;
Gus Prevas99ba4ba2018-10-01 16:40:23 -0400494 }
495
shawnlin5be1f7c2018-05-21 20:50:54 +0800496 public void setAppearing(boolean appearing) {
497 mAppearing = appearing;
498 }
499
500 public boolean isAppearing() {
501 return mAppearing;
502 }
Selim Cinek3d6ae232019-01-04 14:14:33 -0800503
Selim Cinek5040f2e2019-02-14 18:22:42 -0800504 public void setPulseHeight(float height) {
Selim Cinekb0fada62019-06-17 19:03:59 -0700505 if (height != mPulseHeight) {
506 mPulseHeight = height;
507 if (mOnPulseHeightChangedListener != null) {
508 mOnPulseHeightChangedListener.run();
509 }
510 }
511 }
512
513 public float getPulseHeight() {
514 if (mPulseHeight == MAX_PULSE_HEIGHT) {
515 // If we're not pulse expanding, the height should be 0
516 return 0;
517 }
518 return mPulseHeight;
Selim Cinek3d6ae232019-01-04 14:14:33 -0800519 }
520
521 public void setDozeAmount(float dozeAmount) {
522 if (dozeAmount != mDozeAmount) {
523 mDozeAmount = dozeAmount;
Selim Cinek459aee32019-02-20 11:18:56 -0800524 if (dozeAmount == 0.0f || dozeAmount == 1.0f) {
Selim Cinek5040f2e2019-02-14 18:22:42 -0800525 // We woke all the way up, let's reset the pulse height
Selim Cinekb0fada62019-06-17 19:03:59 -0700526 setPulseHeight(MAX_PULSE_HEIGHT);
Selim Cinek3d6ae232019-01-04 14:14:33 -0800527 }
528 }
529 }
Selim Cinekae55d832019-02-22 17:43:43 -0800530
531 /**
532 * Is the device fully awake, which is different from not tark at all when there are pulsing
533 * notifications.
534 */
535 public boolean isFullyAwake() {
536 return mDozeAmount == 0.0f;
537 }
Selim Cinekb0fada62019-06-17 19:03:59 -0700538
539 public void setOnPulseHeightChangedListener(Runnable onPulseHeightChangedListener) {
540 mOnPulseHeightChangedListener = onPulseHeightChangedListener;
541 }
542
543 public Runnable getOnPulseHeightChangedListener() {
544 return mOnPulseHeightChangedListener;
545 }
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200546}