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 | |
Ned Burns | 9eb0633 | 2019-04-23 16:02:12 -0400 | [diff] [blame] | 19 | import android.annotation.NonNull; |
Eliot Courtney | 5d3d2d0 | 2018-01-18 15:59:03 +0900 | [diff] [blame] | 20 | import android.annotation.Nullable; |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 21 | import android.content.Context; |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 22 | import android.util.MathUtils; |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 23 | import android.view.View; |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 24 | |
Kevin | a97ea05 | 2018-09-11 13:53:18 -0700 | [diff] [blame] | 25 | import com.android.systemui.Dependency; |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 26 | import com.android.systemui.R; |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 27 | import com.android.systemui.statusbar.NotificationShelf; |
| 28 | import com.android.systemui.statusbar.StatusBarState; |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 29 | import com.android.systemui.statusbar.notification.collection.NotificationEntry; |
Rohan Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 30 | import com.android.systemui.statusbar.notification.row.ActivatableNotificationView; |
| 31 | import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; |
| 32 | import com.android.systemui.statusbar.notification.row.ExpandableView; |
Ned Burns | 9eb0633 | 2019-04-23 16:02:12 -0400 | [diff] [blame] | 33 | import com.android.systemui.statusbar.notification.stack.StackScrollAlgorithm.SectionProvider; |
Selim Cinek | c3fec68 | 2019-06-06 18:11:07 -0700 | [diff] [blame] | 34 | import com.android.systemui.statusbar.policy.HeadsUpManager; |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 35 | |
| 36 | import java.util.ArrayList; |
| 37 | |
| 38 | /** |
| 39 | * A global state to track all input states for the algorithm. |
| 40 | */ |
| 41 | public class AmbientState { |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 42 | |
Selim Cinek | 5040f2e | 2019-02-14 18:22:42 -0800 | [diff] [blame] | 43 | private static final float MAX_PULSE_HEIGHT = 100000f; |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 44 | |
Ned Burns | 9eb0633 | 2019-04-23 16:02:12 -0400 | [diff] [blame] | 45 | private final SectionProvider mSectionProvider; |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 46 | private ArrayList<ExpandableView> mDraggedViews = new ArrayList<>(); |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 47 | private int mScrollY; |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 48 | private int mAnchorViewIndex; |
| 49 | private int mAnchorViewY; |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 50 | private boolean mDimmed; |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 51 | private ActivatableNotificationView mActivatedChild; |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 52 | private float mOverScrollTopAmount; |
| 53 | private float mOverScrollBottomAmount; |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 54 | private int mSpeedBumpIndex = -1; |
Selim Cinek | c1d9ab2 | 2019-05-21 18:08:30 -0700 | [diff] [blame] | 55 | private boolean mDozing; |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 56 | private boolean mHideSensitive; |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 57 | private float mStackTranslation; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 58 | private int mLayoutHeight; |
| 59 | private int mTopPadding; |
| 60 | private boolean mShadeExpanded; |
| 61 | private float mMaxHeadsUpTranslation; |
Selim Cinek | 9c17b77 | 2015-07-07 20:37:09 -0700 | [diff] [blame] | 62 | private boolean mDismissAllInProgress; |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 63 | private int mLayoutMinHeight; |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 64 | private NotificationShelf mShelf; |
| 65 | private int mZDistanceBetweenElements; |
| 66 | private int mBaseZHeight; |
Selim Cinek | 91d4cba | 2016-11-10 19:59:48 -0800 | [diff] [blame] | 67 | private int mMaxLayoutHeight; |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 68 | private ActivatableNotificationView mLastVisibleBackgroundChild; |
Selim Cinek | 727903c | 2016-12-06 17:28:10 -0800 | [diff] [blame] | 69 | private float mCurrentScrollVelocity; |
Selim Cinek | 355652a | 2016-12-07 13:32:12 -0800 | [diff] [blame] | 70 | private int mStatusBarState; |
Selim Cinek | d5ab645 | 2016-12-08 16:34:00 -0800 | [diff] [blame] | 71 | private float mExpandingVelocity; |
| 72 | private boolean mPanelTracking; |
| 73 | private boolean mExpansionChanging; |
Selim Cinek | fcff4c6 | 2016-12-27 14:26:06 +0100 | [diff] [blame] | 74 | private boolean mPanelFullWidth; |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 75 | private boolean mPulsing; |
Selim Cinek | ec29d34 | 2017-05-05 18:31:49 -0700 | [diff] [blame] | 76 | private boolean mUnlockHintRunning; |
Selim Cinek | 5cf1d05 | 2017-06-01 17:36:46 -0700 | [diff] [blame] | 77 | private boolean mQsCustomizerShowing; |
Selim Cinek | 1f62495 | 2017-06-08 19:11:50 -0700 | [diff] [blame] | 78 | private int mIntrinsicPadding; |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 79 | private int mExpandAnimationTopChange; |
| 80 | private ExpandableNotificationRow mExpandingNotification; |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 81 | private float mHideAmount; |
shawnlin | 5be1f7c | 2018-05-21 20:50:54 +0800 | [diff] [blame] | 82 | private boolean mAppearing; |
Selim Cinek | 5040f2e | 2019-02-14 18:22:42 -0800 | [diff] [blame] | 83 | private float mPulseHeight = MAX_PULSE_HEIGHT; |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 84 | private float mDozeAmount = 0.0f; |
Selim Cinek | c3fec68 | 2019-06-06 18:11:07 -0700 | [diff] [blame] | 85 | private HeadsUpManager mHeadUpManager; |
Selim Cinek | b0fada6 | 2019-06-17 19:03:59 -0700 | [diff] [blame] | 86 | private Runnable mOnPulseHeightChangedListener; |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 87 | |
Ned Burns | 9eb0633 | 2019-04-23 16:02:12 -0400 | [diff] [blame] | 88 | public AmbientState( |
| 89 | Context context, |
Selim Cinek | c3fec68 | 2019-06-06 18:11:07 -0700 | [diff] [blame] | 90 | @NonNull SectionProvider sectionProvider, |
| 91 | HeadsUpManager headsUpManager) { |
Ned Burns | 9eb0633 | 2019-04-23 16:02:12 -0400 | [diff] [blame] | 92 | mSectionProvider = sectionProvider; |
Selim Cinek | c3fec68 | 2019-06-06 18:11:07 -0700 | [diff] [blame] | 93 | mHeadUpManager = headsUpManager; |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 94 | reload(context); |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Reload the dimens e.g. if the density changed. |
| 99 | */ |
| 100 | public void reload(Context context) { |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 101 | mZDistanceBetweenElements = getZDistanceBetweenElements(context); |
| 102 | mBaseZHeight = getBaseHeight(mZDistanceBetweenElements); |
| 103 | } |
| 104 | |
| 105 | private static int getZDistanceBetweenElements(Context context) { |
| 106 | return Math.max(1, context.getResources() |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 107 | .getDimensionPixelSize(R.dimen.z_distance_between_notifications)); |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 108 | } |
| 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 Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 120 | } |
| 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 Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 135 | |
| 136 | public int getScrollY() { |
| 137 | return mScrollY; |
| 138 | } |
| 139 | |
| 140 | public void setScrollY(int scrollY) { |
| 141 | this.mScrollY = scrollY; |
| 142 | } |
| 143 | |
Gus Prevas | 0fa58d6 | 2019-01-11 13:58:40 -0500 | [diff] [blame] | 144 | /** |
| 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 Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 165 | /** Call when dragging begins. */ |
| 166 | public void onBeginDrag(ExpandableView view) { |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 167 | mDraggedViews.add(view); |
| 168 | } |
| 169 | |
| 170 | public void onDragFinished(View view) { |
| 171 | mDraggedViews.remove(view); |
| 172 | } |
| 173 | |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 174 | public ArrayList<ExpandableView> getDraggedViews() { |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 175 | 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 Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 186 | /** While dozing, we draw as little as possible, assuming a black background */ |
Selim Cinek | c1d9ab2 | 2019-05-21 18:08:30 -0700 | [diff] [blame] | 187 | public void setDozing(boolean dozing) { |
| 188 | mDozing = dozing; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 189 | } |
| 190 | |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 191 | /** 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 Cinek | b0fada6 | 2019-06-17 19:03:59 -0700 | [diff] [blame] | 195 | setPulseHeight(MAX_PULSE_HEIGHT); |
Selim Cinek | 5040f2e | 2019-02-14 18:22:42 -0800 | [diff] [blame] | 196 | } |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 197 | mHideAmount = hidemount; |
Lucas Dupin | b561eda | 2018-04-09 17:25:04 -0700 | [diff] [blame] | 198 | } |
| 199 | |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 200 | /** Returns the hide ratio of the status bar */ |
| 201 | public float getHideAmount() { |
| 202 | return mHideAmount; |
Lucas Dupin | b561eda | 2018-04-09 17:25:04 -0700 | [diff] [blame] | 203 | } |
| 204 | |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 205 | public void setHideSensitive(boolean hideSensitive) { |
| 206 | mHideSensitive = hideSensitive; |
| 207 | } |
| 208 | |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 209 | /** |
| 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 Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 213 | public void setActivatedChild(ActivatableNotificationView activatedChild) { |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 214 | mActivatedChild = activatedChild; |
| 215 | } |
| 216 | |
| 217 | public boolean isDimmed() { |
Selim Cinek | f434a74 | 2019-05-28 17:39:49 -0700 | [diff] [blame] | 218 | // 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 Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 221 | } |
| 222 | |
Selim Cinek | c1d9ab2 | 2019-05-21 18:08:30 -0700 | [diff] [blame] | 223 | public boolean isDozing() { |
| 224 | return mDozing; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 225 | } |
| 226 | |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 227 | public boolean isHideSensitive() { |
| 228 | return mHideSensitive; |
| 229 | } |
| 230 | |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 231 | public ActivatableNotificationView getActivatedChild() { |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 232 | return mActivatedChild; |
| 233 | } |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 234 | |
| 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 Cinek | c27437b | 2014-05-14 10:23:33 +0200 | [diff] [blame] | 246 | |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 247 | public int getSpeedBumpIndex() { |
| 248 | return mSpeedBumpIndex; |
Selim Cinek | c27437b | 2014-05-14 10:23:33 +0200 | [diff] [blame] | 249 | } |
| 250 | |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 251 | public void setSpeedBumpIndex(int shelfIndex) { |
| 252 | mSpeedBumpIndex = shelfIndex; |
Selim Cinek | c27437b | 2014-05-14 10:23:33 +0200 | [diff] [blame] | 253 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 254 | |
Ned Burns | 9eb0633 | 2019-04-23 16:02:12 -0400 | [diff] [blame] | 255 | public SectionProvider getSectionProvider() { |
| 256 | return mSectionProvider; |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 257 | } |
| 258 | |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 259 | public float getStackTranslation() { |
| 260 | return mStackTranslation; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 261 | } |
| 262 | |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 263 | public void setStackTranslation(float stackTranslation) { |
| 264 | mStackTranslation = stackTranslation; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 265 | } |
| 266 | |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 267 | public void setLayoutHeight(int layoutHeight) { |
| 268 | mLayoutHeight = layoutHeight; |
| 269 | } |
| 270 | |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 271 | public float getTopPadding() { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 272 | return mTopPadding; |
| 273 | } |
| 274 | |
| 275 | public void setTopPadding(int topPadding) { |
| 276 | mTopPadding = topPadding; |
| 277 | } |
| 278 | |
| 279 | public int getInnerHeight() { |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 280 | 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 Cinek | 5040f2e | 2019-02-14 18:22:42 -0800 | [diff] [blame] | 288 | if (mDozeAmount == 1.0f && !isPulseExpanding()) { |
| 289 | return mShelf.getHeight(); |
| 290 | } |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 291 | int height = Math.max(mLayoutMinHeight, |
| 292 | Math.min(mLayoutHeight, mMaxLayoutHeight) - mTopPadding); |
| 293 | if (ignorePulseHeight) { |
| 294 | return height; |
| 295 | } |
Selim Cinek | 5040f2e | 2019-02-14 18:22:42 -0800 | [diff] [blame] | 296 | float pulseHeight = Math.min(mPulseHeight, (float) height); |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 297 | return (int) MathUtils.lerp(height, pulseHeight, mDozeAmount); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 298 | } |
| 299 | |
Selim Cinek | 5040f2e | 2019-02-14 18:22:42 -0800 | [diff] [blame] | 300 | public boolean isPulseExpanding() { |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 301 | return mPulseHeight != MAX_PULSE_HEIGHT && mDozeAmount != 0.0f && mHideAmount != 1.0f; |
Selim Cinek | 5040f2e | 2019-02-14 18:22:42 -0800 | [diff] [blame] | 302 | } |
| 303 | |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 304 | 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 Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 319 | |
Selim Cinek | 9c17b77 | 2015-07-07 20:37:09 -0700 | [diff] [blame] | 320 | public void setDismissAllInProgress(boolean dismissAllInProgress) { |
| 321 | mDismissAllInProgress = dismissAllInProgress; |
| 322 | } |
| 323 | |
| 324 | public boolean isDismissAllInProgress() { |
| 325 | return mDismissAllInProgress; |
| 326 | } |
Selim Cinek | bc243a9 | 2016-09-27 16:35:13 -0700 | [diff] [blame] | 327 | |
| 328 | public void setLayoutMinHeight(int layoutMinHeight) { |
| 329 | mLayoutMinHeight = layoutMinHeight; |
| 330 | } |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 331 | |
| 332 | public void setShelf(NotificationShelf shelf) { |
| 333 | mShelf = shelf; |
| 334 | } |
| 335 | |
Eliot Courtney | 5d3d2d0 | 2018-01-18 15:59:03 +0900 | [diff] [blame] | 336 | @Nullable |
Selim Cinek | 281c202 | 2016-10-13 19:14:43 -0700 | [diff] [blame] | 337 | public NotificationShelf getShelf() { |
| 338 | return mShelf; |
| 339 | } |
Selim Cinek | 91d4cba | 2016-11-10 19:59:48 -0800 | [diff] [blame] | 340 | |
| 341 | public void setLayoutMaxHeight(int maxLayoutHeight) { |
| 342 | mMaxLayoutHeight = maxLayoutHeight; |
| 343 | } |
Selim Cinek | db16737 | 2016-11-17 15:41:17 -0800 | [diff] [blame] | 344 | |
| 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 Cinek | 727903c | 2016-12-06 17:28:10 -0800 | [diff] [blame] | 357 | |
| 358 | public void setCurrentScrollVelocity(float currentScrollVelocity) { |
| 359 | mCurrentScrollVelocity = currentScrollVelocity; |
| 360 | } |
| 361 | |
| 362 | public float getCurrentScrollVelocity() { |
| 363 | return mCurrentScrollVelocity; |
| 364 | } |
Selim Cinek | 355652a | 2016-12-07 13:32:12 -0800 | [diff] [blame] | 365 | |
| 366 | public boolean isOnKeyguard() { |
| 367 | return mStatusBarState == StatusBarState.KEYGUARD; |
| 368 | } |
| 369 | |
| 370 | public void setStatusBarState(int statusBarState) { |
| 371 | mStatusBarState = statusBarState; |
| 372 | } |
Selim Cinek | d5ab645 | 2016-12-08 16:34:00 -0800 | [diff] [blame] | 373 | |
| 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 Cinek | be2c443 | 2017-05-30 12:11:09 -0700 | [diff] [blame] | 394 | public boolean hasPulsingNotifications() { |
Selim Cinek | c3fec68 | 2019-06-06 18:11:07 -0700 | [diff] [blame] | 395 | return mPulsing && mHeadUpManager != null && mHeadUpManager.hasNotifications(); |
Adrian Roos | d83e999 | 2017-03-16 15:17:57 -0700 | [diff] [blame] | 396 | } |
| 397 | |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 398 | public void setPulsing(boolean hasPulsing) { |
Selim Cinek | ebf4234 | 2017-07-13 15:46:10 +0200 | [diff] [blame] | 399 | mPulsing = hasPulsing; |
| 400 | } |
| 401 | |
Selim Cinek | d0b48e3 | 2019-05-24 20:49:23 -0700 | [diff] [blame] | 402 | /** |
| 403 | * @return if we're pulsing in general |
| 404 | */ |
| 405 | public boolean isPulsing() { |
| 406 | return mPulsing; |
| 407 | } |
| 408 | |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 409 | public boolean isPulsing(NotificationEntry entry) { |
Selim Cinek | c3fec68 | 2019-06-06 18:11:07 -0700 | [diff] [blame] | 410 | if (!mPulsing || mHeadUpManager == null) { |
Selim Cinek | ebf4234 | 2017-07-13 15:46:10 +0200 | [diff] [blame] | 411 | return false; |
| 412 | } |
Selim Cinek | c3fec68 | 2019-06-06 18:11:07 -0700 | [diff] [blame] | 413 | return mHeadUpManager.isAlerting(entry.key); |
Adrian Roos | d83e999 | 2017-03-16 15:17:57 -0700 | [diff] [blame] | 414 | } |
| 415 | |
Selim Cinek | d5ab645 | 2016-12-08 16:34:00 -0800 | [diff] [blame] | 416 | public boolean isPanelTracking() { |
| 417 | return mPanelTracking; |
| 418 | } |
Selim Cinek | fcff4c6 | 2016-12-27 14:26:06 +0100 | [diff] [blame] | 419 | |
| 420 | public boolean isPanelFullWidth() { |
| 421 | return mPanelFullWidth; |
| 422 | } |
| 423 | |
| 424 | public void setPanelFullWidth(boolean panelFullWidth) { |
| 425 | mPanelFullWidth = panelFullWidth; |
| 426 | } |
Selim Cinek | ec29d34 | 2017-05-05 18:31:49 -0700 | [diff] [blame] | 427 | |
| 428 | public void setUnlockHintRunning(boolean unlockHintRunning) { |
| 429 | mUnlockHintRunning = unlockHintRunning; |
| 430 | } |
| 431 | |
| 432 | public boolean isUnlockHintRunning() { |
| 433 | return mUnlockHintRunning; |
| 434 | } |
Selim Cinek | 5cf1d05 | 2017-06-01 17:36:46 -0700 | [diff] [blame] | 435 | |
| 436 | public boolean isQsCustomizerShowing() { |
| 437 | return mQsCustomizerShowing; |
| 438 | } |
| 439 | |
| 440 | public void setQsCustomizerShowing(boolean qsCustomizerShowing) { |
| 441 | mQsCustomizerShowing = qsCustomizerShowing; |
| 442 | } |
Selim Cinek | 1f62495 | 2017-06-08 19:11:50 -0700 | [diff] [blame] | 443 | |
| 444 | public void setIntrinsicPadding(int intrinsicPadding) { |
| 445 | mIntrinsicPadding = intrinsicPadding; |
| 446 | } |
| 447 | |
| 448 | public int getIntrinsicPadding() { |
| 449 | return mIntrinsicPadding; |
| 450 | } |
Selim Cinek | ebf4234 | 2017-07-13 15:46:10 +0200 | [diff] [blame] | 451 | |
| 452 | /** |
Selim Cinek | ebf4234 | 2017-07-13 15:46:10 +0200 | [diff] [blame] | 453 | * @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 Cinek | c1d9ab2 | 2019-05-21 18:08:30 -0700 | [diff] [blame] | 466 | return isDozing() && !isPulsing(row.getEntry()); |
Selim Cinek | ebf4234 | 2017-07-13 15:46:10 +0200 | [diff] [blame] | 467 | } |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 468 | |
| 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 Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame] | 484 | |
| 485 | /** |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 486 | * @return {@code true } when shade is completely hidden: in AOD, ambient display or when |
| 487 | * bypassing. |
Lucas Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame] | 488 | */ |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 489 | public boolean isFullyHidden() { |
| 490 | return mHideAmount == 1; |
Lucas Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame] | 491 | } |
| 492 | |
Selim Cinek | 195dfc5 | 2019-05-30 19:35:05 -0700 | [diff] [blame] | 493 | public boolean isHiddenAtAll() { |
| 494 | return mHideAmount != 0; |
Gus Prevas | 99ba4ba | 2018-10-01 16:40:23 -0400 | [diff] [blame] | 495 | } |
| 496 | |
shawnlin | 5be1f7c | 2018-05-21 20:50:54 +0800 | [diff] [blame] | 497 | public void setAppearing(boolean appearing) { |
| 498 | mAppearing = appearing; |
| 499 | } |
| 500 | |
| 501 | public boolean isAppearing() { |
| 502 | return mAppearing; |
| 503 | } |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 504 | |
Selim Cinek | 5040f2e | 2019-02-14 18:22:42 -0800 | [diff] [blame] | 505 | public void setPulseHeight(float height) { |
Selim Cinek | b0fada6 | 2019-06-17 19:03:59 -0700 | [diff] [blame] | 506 | 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 Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 520 | } |
| 521 | |
| 522 | public void setDozeAmount(float dozeAmount) { |
| 523 | if (dozeAmount != mDozeAmount) { |
| 524 | mDozeAmount = dozeAmount; |
Selim Cinek | 459aee3 | 2019-02-20 11:18:56 -0800 | [diff] [blame] | 525 | if (dozeAmount == 0.0f || dozeAmount == 1.0f) { |
Selim Cinek | 5040f2e | 2019-02-14 18:22:42 -0800 | [diff] [blame] | 526 | // We woke all the way up, let's reset the pulse height |
Selim Cinek | b0fada6 | 2019-06-17 19:03:59 -0700 | [diff] [blame] | 527 | setPulseHeight(MAX_PULSE_HEIGHT); |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 528 | } |
| 529 | } |
| 530 | } |
Selim Cinek | ae55d83 | 2019-02-22 17:43:43 -0800 | [diff] [blame] | 531 | |
| 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 Cinek | b0fada6 | 2019-06-17 19:03:59 -0700 | [diff] [blame] | 539 | |
| 540 | public void setOnPulseHeightChangedListener(Runnable onPulseHeightChangedListener) { |
| 541 | mOnPulseHeightChangedListener = onPulseHeightChangedListener; |
| 542 | } |
| 543 | |
| 544 | public Runnable getOnPulseHeightChangedListener() { |
| 545 | return mOnPulseHeightChangedListener; |
| 546 | } |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 547 | } |