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