blob: 7882fd32e04463d4de14e58988047512763755df [file] [log] [blame]
Selim Cinek67b22602014-03-10 15:40:16 +01001/*
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;
Selim Cinek67b22602014-03-10 15:40:16 +010018
19import android.content.Context;
Anthony Chen9fe1ee72017-04-07 13:53:37 -070020import android.content.res.Resources;
Christoph Studer6e3eceb2014-04-01 18:40:27 +020021import android.util.Log;
Selim Cinek67b22602014-03-10 15:40:16 +010022import android.view.View;
23import android.view.ViewGroup;
Gus Prevase2d6f042018-10-17 15:25:30 -040024
Selim Cinek67b22602014-03-10 15:40:16 +010025import com.android.systemui.R;
Selim Cinekcde90e52016-12-22 21:01:49 +010026import com.android.systemui.statusbar.EmptyShadeView;
Gus Prevase2d6f042018-10-17 15:25:30 -040027import com.android.systemui.statusbar.NotificationShelf;
28import com.android.systemui.statusbar.notification.NotificationUtils;
Rohan Shah20790b82018-07-02 17:21:04 -070029import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
30import com.android.systemui.statusbar.notification.row.ExpandableView;
31import com.android.systemui.statusbar.notification.row.FooterView;
Selim Cinek67b22602014-03-10 15:40:16 +010032
Jorim Jaggid4a57442014-04-10 02:45:55 +020033import java.util.ArrayList;
Selim Cinek42357e02016-02-24 18:48:01 -080034import java.util.HashMap;
Selim Cinekb5605e52015-02-20 18:21:41 +010035import java.util.List;
Jorim Jaggid4a57442014-04-10 02:45:55 +020036
Selim Cinek67b22602014-03-10 15:40:16 +010037/**
Rohan Shah20790b82018-07-02 17:21:04 -070038 * The Algorithm of the {@link com.android.systemui.statusbar.notification.stack
Selim Cinek67b22602014-03-10 15:40:16 +010039 * .NotificationStackScrollLayout} which can be queried for {@link com.android.systemui.statusbar
40 * .stack.StackScrollState}
41 */
42public class StackScrollAlgorithm {
43
Gus Prevas0fa58d62019-01-11 13:58:40 -050044 static final boolean ANCHOR_SCROLLING = false;
45
Christoph Studer6e3eceb2014-04-01 18:40:27 +020046 private static final String LOG_TAG = "StackScrollAlgorithm";
Dave Mankoffa4d195d2018-11-16 13:33:27 -050047 private final ViewGroup mHostView;
Christoph Studer6e3eceb2014-04-01 18:40:27 +020048
Selim Cinek67b22602014-03-10 15:40:16 +010049 private int mPaddingBetweenElements;
Selim Cinek61633a82016-01-25 15:54:10 -080050 private int mIncreasedPaddingBetweenElements;
Gus Prevase2d6f042018-10-17 15:25:30 -040051 private int mGapHeight;
Selim Cinek67b22602014-03-10 15:40:16 +010052 private int mCollapsedSize;
Selim Cinek67b22602014-03-10 15:40:16 +010053
Selim Cinek67b22602014-03-10 15:40:16 +010054 private StackScrollAlgorithmState mTempAlgorithmState = new StackScrollAlgorithmState();
Selim Cinek1685e632014-04-08 02:27:49 +020055 private boolean mIsExpanded;
Anthony Chen9fe1ee72017-04-07 13:53:37 -070056 private boolean mClipNotificationScrollToTop;
Selim Cinekcafa87f2016-10-26 17:00:17 -070057 private int mStatusBarHeight;
Selim Cinekaa9db1f2018-02-27 17:35:47 -080058 private float mHeadsUpInset;
Selim Cinek99e9adf2018-03-15 09:17:47 -070059 private int mPinnedZTranslationExtra;
Selim Cinek67b22602014-03-10 15:40:16 +010060
Dave Mankoffa4d195d2018-11-16 13:33:27 -050061 public StackScrollAlgorithm(Context context, ViewGroup hostView) {
62 mHostView = hostView;
Selim Cinekaf0dc312015-12-15 17:01:44 -080063 initView(context);
Selim Cinek34c0a8d2014-05-12 00:01:43 +020064 }
65
Selim Cinekaf0dc312015-12-15 17:01:44 -080066 public void initView(Context context) {
67 initConstants(context);
Selim Cinek34c0a8d2014-05-12 00:01:43 +020068 }
69
Selim Cinek67b22602014-03-10 15:40:16 +010070 private void initConstants(Context context) {
Anthony Chen9fe1ee72017-04-07 13:53:37 -070071 Resources res = context.getResources();
72 mPaddingBetweenElements = res.getDimensionPixelSize(
Selim Cinekdb167372016-11-17 15:41:17 -080073 R.dimen.notification_divider_height);
Anthony Chen9fe1ee72017-04-07 13:53:37 -070074 mIncreasedPaddingBetweenElements =
75 res.getDimensionPixelSize(R.dimen.notification_divider_height_increased);
76 mCollapsedSize = res.getDimensionPixelSize(R.dimen.notification_min_height);
77 mStatusBarHeight = res.getDimensionPixelSize(R.dimen.status_bar_height);
78 mClipNotificationScrollToTop = res.getBoolean(R.bool.config_clipNotificationScrollToTop);
Selim Cinekaa9db1f2018-02-27 17:35:47 -080079 mHeadsUpInset = mStatusBarHeight + res.getDimensionPixelSize(
80 R.dimen.heads_up_status_bar_padding);
Selim Cinek99e9adf2018-03-15 09:17:47 -070081 mPinnedZTranslationExtra = res.getDimensionPixelSize(
82 R.dimen.heads_up_pinned_elevation);
Gus Prevase2d6f042018-10-17 15:25:30 -040083 mGapHeight = res.getDimensionPixelSize(R.dimen.notification_section_divider_height);
Jorim Jaggid7c1fae2014-08-13 18:27:47 +020084 }
Selim Cinek67b22602014-03-10 15:40:16 +010085
Dave Mankoffa4d195d2018-11-16 13:33:27 -050086 /**
87 * Updates the state of all children in the hostview based on this algorithm.
88 */
89 public void resetViewStates(AmbientState ambientState) {
Selim Cinek67b22602014-03-10 15:40:16 +010090 // The state of the local variables are saved in an algorithmState to easily subdivide it
91 // into multiple phases.
92 StackScrollAlgorithmState algorithmState = mTempAlgorithmState;
93
94 // First we reset the view states to their default values.
Dave Mankoffa4d195d2018-11-16 13:33:27 -050095 resetChildViewStates();
Selim Cinek67b22602014-03-10 15:40:16 +010096
Dave Mankoffa4d195d2018-11-16 13:33:27 -050097 initAlgorithmState(mHostView, algorithmState, ambientState);
Selim Cinek1408eb52014-06-02 14:45:38 +020098
Dave Mankoffa4d195d2018-11-16 13:33:27 -050099 updatePositionsForState(algorithmState, ambientState);
Selim Cinek67b22602014-03-10 15:40:16 +0100100
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500101 updateZValuesForState(algorithmState, ambientState);
Selim Cinek3776fe02016-02-04 13:32:43 -0800102
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500103 updateHeadsUpStates(algorithmState, ambientState);
Selim Cinekeb973562014-05-02 17:07:49 +0200104
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500105 updateDimmedActivatedHideSensitive(ambientState, algorithmState);
106 updateClipping(algorithmState, ambientState);
107 updateSpeedBumpState(algorithmState, ambientState);
108 updateShelfState(ambientState);
109 getNotificationChildrenStates(algorithmState, ambientState);
Selim Cinekb5605e52015-02-20 18:21:41 +0100110 }
111
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500112 private void resetChildViewStates() {
113 int numChildren = mHostView.getChildCount();
114 for (int i = 0; i < numChildren; i++) {
115 ExpandableView child = (ExpandableView) mHostView.getChildAt(i);
116 child.resetViewState();
117 }
118 }
119
120 private void getNotificationChildrenStates(StackScrollAlgorithmState algorithmState,
Selim Cinekc25989e2018-02-16 16:42:14 -0800121 AmbientState ambientState) {
Selim Cinekb5605e52015-02-20 18:21:41 +0100122 int childCount = algorithmState.visibleChildren.size();
123 for (int i = 0; i < childCount; i++) {
124 ExpandableView v = algorithmState.visibleChildren.get(i);
125 if (v instanceof ExpandableNotificationRow) {
126 ExpandableNotificationRow row = (ExpandableNotificationRow) v;
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500127 row.updateChildrenStates(ambientState);
Selim Cinekb5605e52015-02-20 18:21:41 +0100128 }
129 }
Selim Cinek3d2b94bf2014-07-02 22:12:47 +0200130 }
131
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500132 private void updateSpeedBumpState(StackScrollAlgorithmState algorithmState,
133 AmbientState ambientState) {
Selim Cinek3d2b94bf2014-07-02 22:12:47 +0200134 int childCount = algorithmState.visibleChildren.size();
Selim Cinekdb167372016-11-17 15:41:17 -0800135 int belowSpeedBump = ambientState.getSpeedBumpIndex();
Selim Cinek3d2b94bf2014-07-02 22:12:47 +0200136 for (int i = 0; i < childCount; i++) {
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500137 ExpandableView child = algorithmState.visibleChildren.get(i);
138 ExpandableViewState childViewState = child.getViewState();
Selim Cinek3107cfa2014-07-22 15:24:29 +0200139
140 // The speed bump can also be gone, so equality needs to be taken when comparing
141 // indices.
Selim Cinekdb167372016-11-17 15:41:17 -0800142 childViewState.belowSpeedBump = i >= belowSpeedBump;
Selim Cinek3d2b94bf2014-07-02 22:12:47 +0200143 }
Selim Cinekdb167372016-11-17 15:41:17 -0800144
145 }
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500146
147 private void updateShelfState(AmbientState ambientState) {
Selim Cinek281c2022016-10-13 19:14:43 -0700148 NotificationShelf shelf = ambientState.getShelf();
Eliot Courtney5d3d2d02018-01-18 15:59:03 +0900149 if (shelf != null) {
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500150 shelf.updateState(ambientState);
Eliot Courtney5d3d2d02018-01-18 15:59:03 +0900151 }
Selim Cinekf54090e2014-06-17 17:24:51 -0700152 }
153
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500154 private void updateClipping(StackScrollAlgorithmState algorithmState,
155 AmbientState ambientState) {
Selim Cinek355652a2016-12-07 13:32:12 -0800156 float drawStart = !ambientState.isOnKeyguard() ? ambientState.getTopPadding()
Selim Cinek2627d722018-01-19 12:16:49 -0800157 + ambientState.getStackTranslation() + ambientState.getExpandAnimationTopChange()
158 : 0;
Selim Cinek708a6c12014-05-28 14:16:02 +0200159 float previousNotificationEnd = 0;
160 float previousNotificationStart = 0;
Selim Cinek708a6c12014-05-28 14:16:02 +0200161 int childCount = algorithmState.visibleChildren.size();
162 for (int i = 0; i < childCount; i++) {
163 ExpandableView child = algorithmState.visibleChildren.get(i);
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500164 ExpandableViewState state = child.getViewState();
Selim Cinek9b9d6e12017-11-30 12:29:47 +0100165 if (!child.mustStayOnScreen() || state.headsUpIsVisible) {
Selim Cinek3776fe02016-02-04 13:32:43 -0800166 previousNotificationEnd = Math.max(drawStart, previousNotificationEnd);
167 previousNotificationStart = Math.max(drawStart, previousNotificationStart);
168 }
Selim Cinek587cbf32016-01-19 11:36:18 -0800169 float newYTranslation = state.yTranslation;
170 float newHeight = state.height;
Selim Cinek708a6c12014-05-28 14:16:02 +0200171 float newNotificationEnd = newYTranslation + newHeight;
Mady Mellor53ac1ef2016-06-20 13:11:38 -0700172 boolean isHeadsUp = (child instanceof ExpandableNotificationRow)
173 && ((ExpandableNotificationRow) child).isPinned();
Anthony Chen9fe1ee72017-04-07 13:53:37 -0700174 if (mClipNotificationScrollToTop
175 && !state.inShelf && newYTranslation < previousNotificationEnd
Jorim Jaggi0fdf5742016-06-27 11:50:58 -0700176 && (!isHeadsUp || ambientState.isShadeExpanded())) {
Mady Mellorc128f222016-04-26 11:42:46 -0700177 // The previous view is overlapping on top, clip!
178 float overlapAmount = previousNotificationEnd - newYTranslation;
179 state.clipTopAmount = (int) overlapAmount;
Selim Cinekc5baa3e2014-10-29 19:04:19 +0100180 } else {
Mady Mellorc128f222016-04-26 11:42:46 -0700181 state.clipTopAmount = 0;
Selim Cinek9c17b772015-07-07 20:37:09 -0700182 }
183
Selim Cinek708a6c12014-05-28 14:16:02 +0200184 if (!child.isTransparent()) {
185 // Only update the previous values if we are not transparent,
186 // otherwise we would clip to a transparent view.
Mady Mellorc128f222016-04-26 11:42:46 -0700187 previousNotificationEnd = newNotificationEnd;
188 previousNotificationStart = newYTranslation;
Selim Cinek708a6c12014-05-28 14:16:02 +0200189 }
190 }
191 }
192
Selim Cinek9c17b772015-07-07 20:37:09 -0700193 public static boolean canChildBeDismissed(View v) {
Selim Cinek9e624e72016-07-20 13:46:49 -0700194 if (!(v instanceof ExpandableNotificationRow)) {
195 return false;
Selim Cinek38d429f2016-06-03 11:46:56 -0700196 }
Selim Cinek9e624e72016-07-20 13:46:49 -0700197 ExpandableNotificationRow row = (ExpandableNotificationRow) v;
Nadia Benbernou7a18c812019-02-08 16:23:10 -0500198 if (row.isBlockingHelperShowingAndTranslationFinished()) {
199 return true;
200 }
Aaron Heuckroth1dd67cb2018-06-14 14:28:08 -0400201 if (row.areGutsExposed() || !row.getEntry().hasFinishedInitialization()) {
Selim Cinek9e624e72016-07-20 13:46:49 -0700202 return false;
203 }
204 return row.canViewBeDismissed();
Selim Cinek9c17b772015-07-07 20:37:09 -0700205 }
206
Selim Cinek708a6c12014-05-28 14:16:02 +0200207 /**
Jorim Jaggiae441282014-08-01 02:45:18 +0200208 * Updates the dimmed, activated and hiding sensitive states of the children.
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200209 */
Jorim Jaggiae441282014-08-01 02:45:18 +0200210 private void updateDimmedActivatedHideSensitive(AmbientState ambientState,
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500211 StackScrollAlgorithmState algorithmState) {
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200212 boolean dimmed = ambientState.isDimmed();
Lucas Dupin16cfe452018-02-08 13:14:50 -0800213 boolean dark = ambientState.isFullyDark();
Jorim Jaggiae441282014-08-01 02:45:18 +0200214 boolean hideSensitive = ambientState.isHideSensitive();
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200215 View activatedChild = ambientState.getActivatedChild();
216 int childCount = algorithmState.visibleChildren.size();
217 for (int i = 0; i < childCount; i++) {
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500218 ExpandableView child = algorithmState.visibleChildren.get(i);
219 ExpandableViewState childViewState = child.getViewState();
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200220 childViewState.dimmed = dimmed;
John Spurlockbf370992014-06-17 13:58:31 -0400221 childViewState.dark = dark;
Jorim Jaggiae441282014-08-01 02:45:18 +0200222 childViewState.hideSensitive = hideSensitive;
Selim Cinekb89de4e2014-06-10 10:47:05 +0200223 boolean isActivatedChild = activatedChild == child;
Jorim Jaggi4538cee2014-09-09 15:21:38 +0200224 if (dimmed && isActivatedChild) {
Selim Cinek281c2022016-10-13 19:14:43 -0700225 childViewState.zTranslation += 2.0f * ambientState.getZDistanceBetweenElements();
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200226 }
227 }
Selim Cinekeb973562014-05-02 17:07:49 +0200228 }
229
230 /**
Selim Cinek61633a82016-01-25 15:54:10 -0800231 * Initialize the algorithm state like updating the visible children.
Jorim Jaggid4a57442014-04-10 02:45:55 +0200232 */
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500233 private void initAlgorithmState(ViewGroup hostView, StackScrollAlgorithmState state,
Selim Cinek3776fe02016-02-04 13:32:43 -0800234 AmbientState ambientState) {
Selim Cinek3776fe02016-02-04 13:32:43 -0800235 float bottomOverScroll = ambientState.getOverScrollAmount(false /* onTop */);
236
237 int scrollY = ambientState.getScrollY();
238
239 // Due to the overScroller, the stackscroller can have negative scroll state. This is
240 // already accounted for by the top padding and doesn't need an additional adaption
241 scrollY = Math.max(0, scrollY);
242 state.scrollY = (int) (scrollY + bottomOverScroll);
243
Gus Prevas0fa58d62019-01-11 13:58:40 -0500244 if (ANCHOR_SCROLLING) {
245 state.anchorViewY = (int) (ambientState.getAnchorViewY() - bottomOverScroll);
246 }
247
Selim Cinek3776fe02016-02-04 13:32:43 -0800248 //now init the visible children and update paddings
Jorim Jaggid4a57442014-04-10 02:45:55 +0200249 int childCount = hostView.getChildCount();
250 state.visibleChildren.clear();
251 state.visibleChildren.ensureCapacity(childCount);
Selim Cineka7ed2c12017-01-23 20:47:24 -0800252 state.paddingMap.clear();
Selim Cinekb036ca42015-02-20 15:56:28 +0100253 int notGoneIndex = 0;
Selim Cinek61633a82016-01-25 15:54:10 -0800254 ExpandableView lastView = null;
Selim Cinekd96ed402017-07-28 18:19:03 -0700255 int firstHiddenIndex = ambientState.isDark()
256 ? (ambientState.hasPulsingNotifications() ? 1 : 0)
257 : childCount;
258
259 // The goal here is to fill the padding map, by iterating over how much padding each child
260 // needs. The map is thereby reused, by first filling it with the padding amount and when
261 // iterating over it again, it's filled with the actual resolved value.
262
Jorim Jaggid4a57442014-04-10 02:45:55 +0200263 for (int i = 0; i < childCount; i++) {
Gus Prevas0fa58d62019-01-11 13:58:40 -0500264 if (ANCHOR_SCROLLING) {
265 if (i == ambientState.getAnchorViewIndex()) {
266 state.anchorViewIndex = state.visibleChildren.size();
267 }
268 }
Jorim Jaggibe565df2014-04-28 17:51:23 +0200269 ExpandableView v = (ExpandableView) hostView.getChildAt(i);
Jorim Jaggid4a57442014-04-10 02:45:55 +0200270 if (v.getVisibility() != View.GONE) {
Selim Cinek281c2022016-10-13 19:14:43 -0700271 if (v == ambientState.getShelf()) {
272 continue;
273 }
Selim Cinekd96ed402017-07-28 18:19:03 -0700274 if (i >= firstHiddenIndex) {
275 // we need normal padding now, to be in sync with what the stack calculates
276 lastView = null;
Selim Cinekd96ed402017-07-28 18:19:03 -0700277 }
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500278 notGoneIndex = updateNotGoneIndex(state, notGoneIndex, v);
Selim Cinekd96ed402017-07-28 18:19:03 -0700279 float increasedPadding = v.getIncreasedPaddingAmount();
Selim Cinek42357e02016-02-24 18:48:01 -0800280 if (increasedPadding != 0.0f) {
Selim Cineka7ed2c12017-01-23 20:47:24 -0800281 state.paddingMap.put(v, increasedPadding);
Selim Cinek61633a82016-01-25 15:54:10 -0800282 if (lastView != null) {
Selim Cineka7ed2c12017-01-23 20:47:24 -0800283 Float prevValue = state.paddingMap.get(lastView);
284 float newValue = getPaddingForValue(increasedPadding);
285 if (prevValue != null) {
286 float prevPadding = getPaddingForValue(prevValue);
287 if (increasedPadding > 0) {
288 newValue = NotificationUtils.interpolate(
289 prevPadding,
290 newValue,
291 increasedPadding);
292 } else if (prevValue > 0) {
293 newValue = NotificationUtils.interpolate(
294 newValue,
295 prevPadding,
296 prevValue);
297 }
298 }
299 state.paddingMap.put(lastView, newValue);
Selim Cinek61633a82016-01-25 15:54:10 -0800300 }
Selim Cineka7ed2c12017-01-23 20:47:24 -0800301 } else if (lastView != null) {
Selim Cinekd96ed402017-07-28 18:19:03 -0700302
303 // Let's now resolve the value to an actual padding
Selim Cineka7ed2c12017-01-23 20:47:24 -0800304 float newValue = getPaddingForValue(state.paddingMap.get(lastView));
305 state.paddingMap.put(lastView, newValue);
Selim Cinek61633a82016-01-25 15:54:10 -0800306 }
Selim Cinekb5605e52015-02-20 18:21:41 +0100307 if (v instanceof ExpandableNotificationRow) {
308 ExpandableNotificationRow row = (ExpandableNotificationRow) v;
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700309
310 // handle the notgoneIndex for the children as well
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500311 List<ExpandableNotificationRow> children = row.getNotificationChildren();
Selim Cinek83bc7832015-10-22 13:26:54 -0700312 if (row.isSummaryWithChildren() && children != null) {
Selim Cinekb5605e52015-02-20 18:21:41 +0100313 for (ExpandableNotificationRow childRow : children) {
314 if (childRow.getVisibility() != View.GONE) {
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500315 ExpandableViewState childState = childRow.getViewState();
Selim Cinekb5605e52015-02-20 18:21:41 +0100316 childState.notGoneIndex = notGoneIndex;
317 notGoneIndex++;
318 }
319 }
320 }
321 }
Selim Cinek61633a82016-01-25 15:54:10 -0800322 lastView = v;
Jorim Jaggid4a57442014-04-10 02:45:55 +0200323 }
324 }
Selim Cinek2627d722018-01-19 12:16:49 -0800325 ExpandableNotificationRow expandingNotification = ambientState.getExpandingNotification();
326 state.indexOfExpandingNotification = expandingNotification != null
Selim Cinekc25989e2018-02-16 16:42:14 -0800327 ? expandingNotification.isChildInGroup()
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500328 ? state.visibleChildren.indexOf(expandingNotification.getNotificationParent())
329 : state.visibleChildren.indexOf(expandingNotification)
Selim Cinek2627d722018-01-19 12:16:49 -0800330 : -1;
Jorim Jaggid4a57442014-04-10 02:45:55 +0200331 }
332
Selim Cineka7ed2c12017-01-23 20:47:24 -0800333 private float getPaddingForValue(Float increasedPadding) {
334 if (increasedPadding == null) {
335 return mPaddingBetweenElements;
336 } else if (increasedPadding >= 0.0f) {
337 return NotificationUtils.interpolate(
338 mPaddingBetweenElements,
339 mIncreasedPaddingBetweenElements,
340 increasedPadding);
341 } else {
342 return NotificationUtils.interpolate(
343 0,
344 mPaddingBetweenElements,
345 1.0f + increasedPadding);
346 }
347 }
348
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500349 private int updateNotGoneIndex(StackScrollAlgorithmState state, int notGoneIndex,
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700350 ExpandableView v) {
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500351 ExpandableViewState viewState = v.getViewState();
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700352 viewState.notGoneIndex = notGoneIndex;
353 state.visibleChildren.add(v);
354 notGoneIndex++;
355 return notGoneIndex;
356 }
357
Jorim Jaggid4a57442014-04-10 02:45:55 +0200358 /**
Selim Cinek67b22602014-03-10 15:40:16 +0100359 * Determine the positions for the views. This is the main part of the algorithm.
360 *
Selim Cinek67b22602014-03-10 15:40:16 +0100361 * @param algorithmState The state in which the current pass of the algorithm is currently in
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500362 * @param ambientState The current ambient state
Selim Cinek67b22602014-03-10 15:40:16 +0100363 */
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500364 private void updatePositionsForState(StackScrollAlgorithmState algorithmState,
365 AmbientState ambientState) {
Selim Cinek67b22602014-03-10 15:40:16 +0100366
Gus Prevas0fa58d62019-01-11 13:58:40 -0500367 if (ANCHOR_SCROLLING) {
368 float currentYPosition = algorithmState.anchorViewY;
369 int childCount = algorithmState.visibleChildren.size();
370 for (int i = algorithmState.anchorViewIndex; i < childCount; i++) {
371 if (i > algorithmState.anchorViewIndex && ambientState.beginsNewSection(i)) {
372 currentYPosition += mGapHeight;
373 }
374 currentYPosition = updateChild(i, algorithmState, ambientState, currentYPosition,
375 false /* reverse */);
376 }
377 currentYPosition = algorithmState.anchorViewY;
378 for (int i = algorithmState.anchorViewIndex - 1; i >= 0; i--) {
379 if (ambientState.beginsNewSection(i + 1)) {
380 currentYPosition -= mGapHeight;
381 }
382 currentYPosition = updateChild(i, algorithmState, ambientState, currentYPosition,
383 true /* reverse */);
384 }
385 } else {
386 // The y coordinate of the current child.
387 float currentYPosition = -algorithmState.scrollY;
388 int childCount = algorithmState.visibleChildren.size();
389 for (int i = 0; i < childCount; i++) {
390 if (ambientState.beginsNewSection(i)) {
391 currentYPosition += mGapHeight;
392 }
393 currentYPosition = updateChild(i, algorithmState, ambientState, currentYPosition,
394 false /* reverse */);
395 }
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700396 }
397 }
398
Gus Prevas0fa58d62019-01-11 13:58:40 -0500399 /**
400 * Populates the {@link ExpandableViewState} for a single child.
401 *
402 * @param i The index of the child in
403 * {@link StackScrollAlgorithmState#visibleChildren}.
404 * @param algorithmState The overall output state of the algorithm.
405 * @param ambientState The input state provided to the algorithm.
406 * @param currentYPosition The Y position of the current pass of the algorithm. For a forward
407 * pass, this should be the top of the child; for a reverse pass, the
408 * bottom of the child.
409 * @param reverse Whether we're laying out children in the reverse direction (Y
410 * positions
411 * decreasing) instead of the forward direction (Y positions
412 * increasing).
413 * @return The Y position after laying out the child. This will be the {@code currentYPosition}
414 * for the next call to this method, after adjusting for any gaps between children.
415 */
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500416 protected float updateChild(
417 int i,
418 StackScrollAlgorithmState algorithmState,
419 AmbientState ambientState,
Gus Prevas0fa58d62019-01-11 13:58:40 -0500420 float currentYPosition,
421 boolean reverse) {
Muyuan Li87798022016-04-07 17:51:25 -0700422 ExpandableView child = algorithmState.visibleChildren.get(i);
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500423 ExpandableViewState childViewState = child.getViewState();
Selim Cinekbbcebde2016-11-09 18:28:20 -0800424 childViewState.location = ExpandableViewState.LOCATION_UNKNOWN;
Muyuan Li87798022016-04-07 17:51:25 -0700425 int paddingAfterChild = getPaddingAfterChild(algorithmState, child);
426 int childHeight = getMaxAllowedChildHeight(child);
Gus Prevas0fa58d62019-01-11 13:58:40 -0500427 if (reverse) {
428 childViewState.yTranslation = currentYPosition - (childHeight + paddingAfterChild);
429 if (currentYPosition <= 0) {
430 childViewState.location = ExpandableViewState.LOCATION_HIDDEN_TOP;
431 }
432 } else {
433 childViewState.yTranslation = currentYPosition;
Gus Prevase2d6f042018-10-17 15:25:30 -0400434 }
Julia Reynoldsed1c9af2018-03-21 15:21:09 -0400435 boolean isFooterView = child instanceof FooterView;
Selim Cinekcde90e52016-12-22 21:01:49 +0100436 boolean isEmptyShadeView = child instanceof EmptyShadeView;
Muyuan Li87798022016-04-07 17:51:25 -0700437
Selim Cinekdb167372016-11-17 15:41:17 -0800438 childViewState.location = ExpandableViewState.LOCATION_MAIN_AREA;
Selim Cinek9b9d6e12017-11-30 12:29:47 +0100439 float inset = ambientState.getTopPadding() + ambientState.getStackTranslation();
Selim Cinekc25989e2018-02-16 16:42:14 -0800440 if (i <= algorithmState.getIndexOfExpandingNotification()) {
Selim Cinek2627d722018-01-19 12:16:49 -0800441 inset += ambientState.getExpandAnimationTopChange();
442 }
Selim Cinek9b9d6e12017-11-30 12:29:47 +0100443 if (child.mustStayOnScreen() && childViewState.yTranslation >= 0) {
444 // Even if we're not scrolled away we're in view and we're also not in the
445 // shelf. We can relax the constraints and let us scroll off the top!
446 float end = childViewState.yTranslation + childViewState.height + inset;
447 childViewState.headsUpIsVisible = end < ambientState.getMaxHeadsUpTranslation();
448 }
Julia Reynoldsed1c9af2018-03-21 15:21:09 -0400449 if (isFooterView) {
Selim Cinekdb167372016-11-17 15:41:17 -0800450 childViewState.yTranslation = Math.min(childViewState.yTranslation,
451 ambientState.getInnerHeight() - childHeight);
Selim Cinekcde90e52016-12-22 21:01:49 +0100452 } else if (isEmptyShadeView) {
453 childViewState.yTranslation = ambientState.getInnerHeight() - childHeight
454 + ambientState.getStackTranslation() * 0.25f;
Muyuan Li87798022016-04-07 17:51:25 -0700455 } else {
Selim Cinek2627d722018-01-19 12:16:49 -0800456 clampPositionToShelf(child, childViewState, ambientState);
Muyuan Li87798022016-04-07 17:51:25 -0700457 }
458
Gus Prevas0fa58d62019-01-11 13:58:40 -0500459 if (reverse) {
460 currentYPosition = childViewState.yTranslation;
461 } else {
462 currentYPosition = childViewState.yTranslation + childHeight + paddingAfterChild;
463 if (currentYPosition <= 0) {
464 childViewState.location = ExpandableViewState.LOCATION_HIDDEN_TOP;
465 }
Muyuan Li87798022016-04-07 17:51:25 -0700466 }
Selim Cinekbbcebde2016-11-09 18:28:20 -0800467 if (childViewState.location == ExpandableViewState.LOCATION_UNKNOWN) {
Muyuan Li87798022016-04-07 17:51:25 -0700468 Log.wtf(LOG_TAG, "Failed to assign location for child " + i);
469 }
470
Selim Cinek9b9d6e12017-11-30 12:29:47 +0100471 childViewState.yTranslation += inset;
Muyuan Li87798022016-04-07 17:51:25 -0700472 return currentYPosition;
473 }
474
475 protected int getPaddingAfterChild(StackScrollAlgorithmState algorithmState,
Selim Cinek61633a82016-01-25 15:54:10 -0800476 ExpandableView child) {
Selim Cinek281c2022016-10-13 19:14:43 -0700477 return algorithmState.getPaddingAfterChild(child);
Selim Cinek61633a82016-01-25 15:54:10 -0800478 }
479
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500480 private void updateHeadsUpStates(StackScrollAlgorithmState algorithmState,
481 AmbientState ambientState) {
Selim Cineka4baaa32015-04-20 14:27:54 -0700482 int childCount = algorithmState.visibleChildren.size();
483 ExpandableNotificationRow topHeadsUpEntry = null;
484 for (int i = 0; i < childCount; i++) {
485 View child = algorithmState.visibleChildren.get(i);
486 if (!(child instanceof ExpandableNotificationRow)) {
487 break;
488 }
489 ExpandableNotificationRow row = (ExpandableNotificationRow) child;
490 if (!row.isHeadsUp()) {
491 break;
Selim Cineka4baaa32015-04-20 14:27:54 -0700492 }
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500493 ExpandableViewState childState = row.getViewState();
Selim Cinek9b9d6e12017-11-30 12:29:47 +0100494 if (topHeadsUpEntry == null && row.mustStayOnScreen() && !childState.headsUpIsVisible) {
Selim Cinek3776fe02016-02-04 13:32:43 -0800495 topHeadsUpEntry = row;
Selim Cinekbbcebde2016-11-09 18:28:20 -0800496 childState.location = ExpandableViewState.LOCATION_FIRST_HUN;
Selim Cinek3776fe02016-02-04 13:32:43 -0800497 }
Selim Cinek1f3f5442015-04-10 17:54:46 -0700498 boolean isTopEntry = topHeadsUpEntry == row;
Selim Cinek3776fe02016-02-04 13:32:43 -0800499 float unmodifiedEndLocation = childState.yTranslation + childState.height;
Selim Cinek131c1e22015-05-11 19:04:49 -0700500 if (mIsExpanded) {
Selim Cinek9b9d6e12017-11-30 12:29:47 +0100501 if (row.mustStayOnScreen() && !childState.headsUpIsVisible) {
502 // Ensure that the heads up is always visible even when scrolled off
503 clampHunToTop(ambientState, row, childState);
504 if (i == 0 && ambientState.isAboveShelf(row)) {
505 // the first hun can't get off screen.
506 clampHunToMaxTranslation(ambientState, row, childState);
507 childState.hidden = false;
508 }
Selim Cinekd127d792016-11-01 19:11:41 -0700509 }
Selim Cinek131c1e22015-05-11 19:04:49 -0700510 }
Selim Cinek684a4422015-04-15 16:18:39 -0700511 if (row.isPinned()) {
Selim Cinekaa9db1f2018-02-27 17:35:47 -0800512 childState.yTranslation = Math.max(childState.yTranslation, mHeadsUpInset);
Selim Cinek31aada42015-12-18 17:51:15 -0800513 childState.height = Math.max(row.getIntrinsicHeight(), childState.height);
Selim Cinekcafa87f2016-10-26 17:00:17 -0700514 childState.hidden = false;
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500515 ExpandableViewState topState =
516 topHeadsUpEntry == null ? null : topHeadsUpEntry.getViewState();
Selim Cinek61cfd4b2017-12-08 12:42:36 -0800517 if (topState != null && !isTopEntry && (!mIsExpanded
Selim Cinek3776fe02016-02-04 13:32:43 -0800518 || unmodifiedEndLocation < topState.yTranslation + topState.height)) {
Selim Cinek684a4422015-04-15 16:18:39 -0700519 // Ensure that a headsUp doesn't vertically extend further than the heads-up at
520 // the top most z-position
Selim Cinek31aada42015-12-18 17:51:15 -0800521 childState.height = row.getIntrinsicHeight();
Selim Cineke53e6bb2015-04-13 16:14:26 -0700522 childState.yTranslation = topState.yTranslation + topState.height
523 - childState.height;
Selim Cinek1f3f5442015-04-10 17:54:46 -0700524 }
felkachang529bfe62018-07-04 12:51:44 +0800525
526 // heads up notification show and this row is the top entry of heads up
527 // notifications. i.e. this row should be the only one row that has input field
528 // To check if the row need to do translation according to scroll Y
529 // heads up show full of row's content and any scroll y indicate that the
530 // translationY need to move up the HUN.
Gus Prevas0fa58d62019-01-11 13:58:40 -0500531 // TODO: fix this check for anchor scrolling.
felkachang529bfe62018-07-04 12:51:44 +0800532 if (!mIsExpanded && isTopEntry && ambientState.getScrollY() > 0) {
533 childState.yTranslation -= ambientState.getScrollY();
534 }
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700535 }
Selim Cinekcafa87f2016-10-26 17:00:17 -0700536 if (row.isHeadsUpAnimatingAway()) {
537 childState.hidden = false;
538 }
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700539 }
Selim Cinek67b22602014-03-10 15:40:16 +0100540 }
541
Selim Cinek3776fe02016-02-04 13:32:43 -0800542 private void clampHunToTop(AmbientState ambientState, ExpandableNotificationRow row,
Selim Cinekbbcebde2016-11-09 18:28:20 -0800543 ExpandableViewState childState) {
Selim Cinek3776fe02016-02-04 13:32:43 -0800544 float newTranslation = Math.max(ambientState.getTopPadding()
545 + ambientState.getStackTranslation(), childState.yTranslation);
546 childState.height = (int) Math.max(childState.height - (newTranslation
Selim Cinek567e8452016-03-24 10:54:56 -0700547 - childState.yTranslation), row.getCollapsedHeight());
Selim Cinek3776fe02016-02-04 13:32:43 -0800548 childState.yTranslation = newTranslation;
549 }
550
551 private void clampHunToMaxTranslation(AmbientState ambientState, ExpandableNotificationRow row,
Selim Cinekbbcebde2016-11-09 18:28:20 -0800552 ExpandableViewState childState) {
Selim Cinek3776fe02016-02-04 13:32:43 -0800553 float newTranslation;
Selim Cinek7e0f9482017-05-22 20:00:56 -0700554 float maxHeadsUpTranslation = ambientState.getMaxHeadsUpTranslation();
555 float maxShelfPosition = ambientState.getInnerHeight() + ambientState.getTopPadding()
556 + ambientState.getStackTranslation();
557 maxHeadsUpTranslation = Math.min(maxHeadsUpTranslation, maxShelfPosition);
558 float bottomPosition = maxHeadsUpTranslation - row.getCollapsedHeight();
Selim Cinek3776fe02016-02-04 13:32:43 -0800559 newTranslation = Math.min(childState.yTranslation, bottomPosition);
Selim Cinek7e0f9482017-05-22 20:00:56 -0700560 childState.height = (int) Math.min(childState.height, maxHeadsUpTranslation
561 - newTranslation);
Selim Cinek3776fe02016-02-04 13:32:43 -0800562 childState.yTranslation = newTranslation;
Selim Cinek343e6e22014-04-11 21:23:30 +0200563 }
564
565 /**
Selim Cinek281c2022016-10-13 19:14:43 -0700566 * Clamp the height of the child down such that its end is at most on the beginning of
567 * the shelf.
568 *
Selim Cinek281c2022016-10-13 19:14:43 -0700569 * @param childViewState the view state of the child
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500570 * @param ambientState the ambient state
Selim Cinek281c2022016-10-13 19:14:43 -0700571 */
Selim Cinek2627d722018-01-19 12:16:49 -0800572 private void clampPositionToShelf(ExpandableView child,
573 ExpandableViewState childViewState,
Selim Cinek281c2022016-10-13 19:14:43 -0700574 AmbientState ambientState) {
Eliot Courtney5d3d2d02018-01-18 15:59:03 +0900575 if (ambientState.getShelf() == null) {
576 return;
577 }
578
Selim Cineka686b2c2016-10-26 13:58:27 -0700579 int shelfStart = ambientState.getInnerHeight()
580 - ambientState.getShelf().getIntrinsicHeight();
shawnlin5be1f7c2018-05-21 20:50:54 +0800581 if (ambientState.isAppearing() && !child.isAboveShelf()) {
582 // Don't show none heads-up notifications while in appearing phase.
583 childViewState.yTranslation = Math.max(childViewState.yTranslation, shelfStart);
584 }
Selim Cinek281c2022016-10-13 19:14:43 -0700585 childViewState.yTranslation = Math.min(childViewState.yTranslation, shelfStart);
Selim Cinekc383fd02016-10-21 15:31:26 -0700586 if (childViewState.yTranslation >= shelfStart) {
Selim Cinekc25989e2018-02-16 16:42:14 -0800587 childViewState.hidden = !child.isExpandAnimationRunning() && !child.hasExpandingChild();
Selim Cinekeccb5de2016-10-28 15:04:05 -0700588 childViewState.inShelf = true;
Selim Cinek9b9d6e12017-11-30 12:29:47 +0100589 childViewState.headsUpIsVisible = false;
Selim Cinekc383fd02016-10-21 15:31:26 -0700590 }
Selim Cinek281c2022016-10-13 19:14:43 -0700591 }
592
Muyuan Li87798022016-04-07 17:51:25 -0700593 protected int getMaxAllowedChildHeight(View child) {
Selim Cinek31aada42015-12-18 17:51:15 -0800594 if (child instanceof ExpandableView) {
Jorim Jaggibe565df2014-04-28 17:51:23 +0200595 ExpandableView expandableView = (ExpandableView) child;
Selim Cinek8d5727f2015-04-28 19:17:32 -0700596 return expandableView.getIntrinsicHeight();
Selim Cinek1685e632014-04-08 02:27:49 +0200597 }
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500598 return child == null ? mCollapsedSize : child.getHeight();
Selim Cinek1685e632014-04-08 02:27:49 +0200599 }
600
Selim Cinek67b22602014-03-10 15:40:16 +0100601 /**
Selim Cinek67b22602014-03-10 15:40:16 +0100602 * Calculate the Z positions for all children based on the number of items in both stacks and
603 * save it in the resultState
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500604 *
Selim Cinek67b22602014-03-10 15:40:16 +0100605 * @param algorithmState The state in which the current pass of the algorithm is currently in
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500606 * @param ambientState The ambient state of the algorithm
Selim Cinek67b22602014-03-10 15:40:16 +0100607 */
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500608 private void updateZValuesForState(StackScrollAlgorithmState algorithmState,
609 AmbientState ambientState) {
Jorim Jaggid4a57442014-04-10 02:45:55 +0200610 int childCount = algorithmState.visibleChildren.size();
Selim Cinek33223572016-02-19 19:32:22 -0800611 float childrenOnTop = 0.0f;
Selim Cinek3776fe02016-02-04 13:32:43 -0800612 for (int i = childCount - 1; i >= 0; i--) {
Selim Cinekdaab6f52017-04-06 16:46:34 -0700613 childrenOnTop = updateChildZValue(i, childrenOnTop,
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500614 algorithmState, ambientState);
Muyuan Li87798022016-04-07 17:51:25 -0700615 }
616 }
617
Selim Cinekdaab6f52017-04-06 16:46:34 -0700618 protected float updateChildZValue(int i, float childrenOnTop,
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500619 StackScrollAlgorithmState algorithmState,
Muyuan Li87798022016-04-07 17:51:25 -0700620 AmbientState ambientState) {
621 ExpandableView child = algorithmState.visibleChildren.get(i);
Dave Mankoffa4d195d2018-11-16 13:33:27 -0500622 ExpandableViewState childViewState = child.getViewState();
Selim Cinek281c2022016-10-13 19:14:43 -0700623 int zDistanceBetweenElements = ambientState.getZDistanceBetweenElements();
624 float baseZ = ambientState.getBaseZHeight();
Selim Cinek9b9d6e12017-11-30 12:29:47 +0100625 if (child.mustStayOnScreen() && !childViewState.headsUpIsVisible
626 && !ambientState.isDozingAndNotPulsing(child)
Muyuan Li87798022016-04-07 17:51:25 -0700627 && childViewState.yTranslation < ambientState.getTopPadding()
628 + ambientState.getStackTranslation()) {
629 if (childrenOnTop != 0.0f) {
630 childrenOnTop++;
631 } else {
632 float overlap = ambientState.getTopPadding()
633 + ambientState.getStackTranslation() - childViewState.yTranslation;
634 childrenOnTop += Math.min(1.0f, overlap / childViewState.height);
635 }
Selim Cinek281c2022016-10-13 19:14:43 -0700636 childViewState.zTranslation = baseZ
637 + childrenOnTop * zDistanceBetweenElements;
Selim Cinekebf42342017-07-13 15:46:10 +0200638 } else if (i == 0 && ambientState.isAboveShelf(child)) {
Selim Cinekd127d792016-11-01 19:11:41 -0700639 // In case this is a new view that has never been measured before, we don't want to
640 // elevate if we are currently expanded more then the notification
Eliot Courtney5d3d2d02018-01-18 15:59:03 +0900641 int shelfHeight = ambientState.getShelf() == null ? 0 :
642 ambientState.getShelf().getIntrinsicHeight();
Selim Cinekd127d792016-11-01 19:11:41 -0700643 float shelfStart = ambientState.getInnerHeight()
644 - shelfHeight + ambientState.getTopPadding()
645 + ambientState.getStackTranslation();
646 float notificationEnd = childViewState.yTranslation + child.getPinnedHeadsUpHeight()
647 + mPaddingBetweenElements;
648 if (shelfStart > notificationEnd) {
649 childViewState.zTranslation = baseZ;
650 } else {
651 float factor = (notificationEnd - shelfStart) / shelfHeight;
652 factor = Math.min(factor, 1.0f);
653 childViewState.zTranslation = baseZ + factor * zDistanceBetweenElements;
654 }
Muyuan Li87798022016-04-07 17:51:25 -0700655 } else {
Selim Cinek281c2022016-10-13 19:14:43 -0700656 childViewState.zTranslation = baseZ;
Selim Cinek67b22602014-03-10 15:40:16 +0100657 }
Selim Cinek99e9adf2018-03-15 09:17:47 -0700658
659 // We need to scrim the notification more from its surrounding content when we are pinned,
660 // and we therefore elevate it higher.
661 // We can use the headerVisibleAmount for this, since the value nicely goes from 0 to 1 when
662 // expanding after which we have a normal elevation again.
663 childViewState.zTranslation += (1.0f - child.getHeaderVisibleAmount())
664 * mPinnedZTranslationExtra;
Selim Cinekdaab6f52017-04-06 16:46:34 -0700665 return childrenOnTop;
Selim Cinek67b22602014-03-10 15:40:16 +0100666 }
667
Selim Cinek1685e632014-04-08 02:27:49 +0200668 public void setIsExpanded(boolean isExpanded) {
669 this.mIsExpanded = isExpanded;
670 }
671
Selim Cinek281c2022016-10-13 19:14:43 -0700672 public class StackScrollAlgorithmState {
Selim Cinek67b22602014-03-10 15:40:16 +0100673
674 /**
Gus Prevas0fa58d62019-01-11 13:58:40 -0500675 * The scroll position of the algorithm (absolute scrolling).
Selim Cinek67b22602014-03-10 15:40:16 +0100676 */
677 public int scrollY;
678
Gus Prevas0fa58d62019-01-11 13:58:40 -0500679 /** The index of the anchor view (anchor scrolling). */
680 public int anchorViewIndex;
681
682 /**
683 * The Y position, relative to the top of the screen, of the anchor view (anchor scrolling).
684 */
685 public int anchorViewY;
686
Selim Cinek67b22602014-03-10 15:40:16 +0100687 /**
Jorim Jaggid4a57442014-04-10 02:45:55 +0200688 * The children from the host view which are not gone.
689 */
Jorim Jaggibe565df2014-04-28 17:51:23 +0200690 public final ArrayList<ExpandableView> visibleChildren = new ArrayList<ExpandableView>();
Selim Cinek61633a82016-01-25 15:54:10 -0800691
692 /**
Selim Cineka7ed2c12017-01-23 20:47:24 -0800693 * The padding after each child measured in pixels.
Selim Cinek61633a82016-01-25 15:54:10 -0800694 */
Selim Cineka7ed2c12017-01-23 20:47:24 -0800695 public final HashMap<ExpandableView, Float> paddingMap = new HashMap<>();
Selim Cinek2627d722018-01-19 12:16:49 -0800696 private int indexOfExpandingNotification;
Selim Cinek281c2022016-10-13 19:14:43 -0700697
698 public int getPaddingAfterChild(ExpandableView child) {
Selim Cineka7ed2c12017-01-23 20:47:24 -0800699 Float padding = paddingMap.get(child);
700 if (padding == null) {
701 // Should only happen for the last view
702 return mPaddingBetweenElements;
703 }
704 return (int) padding.floatValue();
Selim Cinek281c2022016-10-13 19:14:43 -0700705 }
Selim Cinek2627d722018-01-19 12:16:49 -0800706
707 public int getIndexOfExpandingNotification() {
708 return indexOfExpandingNotification;
709 }
Selim Cinek67b22602014-03-10 15:40:16 +0100710 }
711
712}