Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [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 | |
| 17 | package com.android.systemui.statusbar.stack; |
| 18 | |
| 19 | import android.content.Context; |
Christoph Studer | 6e3eceb | 2014-04-01 18:40:27 +0200 | [diff] [blame] | 20 | import android.util.Log; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 21 | import android.view.View; |
| 22 | import android.view.ViewGroup; |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 23 | |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 24 | import com.android.systemui.R; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 25 | import com.android.systemui.statusbar.ExpandableNotificationRow; |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 26 | import com.android.systemui.statusbar.ExpandableView; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 27 | |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 28 | import java.util.ArrayList; |
| 29 | |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 30 | /** |
| 31 | * The Algorithm of the {@link com.android.systemui.statusbar.stack |
| 32 | * .NotificationStackScrollLayout} which can be queried for {@link com.android.systemui.statusbar |
| 33 | * .stack.StackScrollState} |
| 34 | */ |
| 35 | public class StackScrollAlgorithm { |
| 36 | |
Christoph Studer | 6e3eceb | 2014-04-01 18:40:27 +0200 | [diff] [blame] | 37 | private static final String LOG_TAG = "StackScrollAlgorithm"; |
| 38 | |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 39 | private static final int MAX_ITEMS_IN_BOTTOM_STACK = 3; |
| 40 | private static final int MAX_ITEMS_IN_TOP_STACK = 3; |
| 41 | |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 42 | /** When a child is activated, the other cards' alpha fade to this value. */ |
| 43 | private static final float ACTIVATED_INVERSE_ALPHA = 0.9f; |
Jorim Jaggi | 362dd6d | 2014-07-09 19:04:07 +0200 | [diff] [blame] | 44 | public static final float DIMMED_SCALE = 0.95f; |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 45 | |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 46 | private int mPaddingBetweenElements; |
| 47 | private int mCollapsedSize; |
| 48 | private int mTopStackPeekSize; |
| 49 | private int mBottomStackPeekSize; |
| 50 | private int mZDistanceBetweenElements; |
| 51 | private int mZBasicHeight; |
Selim Cinek | 708a6c1 | 2014-05-28 14:16:02 +0200 | [diff] [blame] | 52 | private int mRoundedRectCornerRadius; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 53 | |
| 54 | private StackIndentationFunctor mTopStackIndentationFunctor; |
| 55 | private StackIndentationFunctor mBottomStackIndentationFunctor; |
| 56 | |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 57 | private int mLayoutHeight; |
Jorim Jaggi | 8c1a44b | 2014-04-29 19:04:02 +0200 | [diff] [blame] | 58 | |
| 59 | /** mLayoutHeight - mTopPadding */ |
| 60 | private int mInnerHeight; |
| 61 | private int mTopPadding; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 62 | private StackScrollAlgorithmState mTempAlgorithmState = new StackScrollAlgorithmState(); |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 63 | private boolean mIsExpansionChanging; |
| 64 | private int mFirstChildMaxHeight; |
| 65 | private boolean mIsExpanded; |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 66 | private ExpandableView mFirstChildWhileExpanding; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 67 | private boolean mExpandedOnStart; |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 68 | private int mTopStackTotalSize; |
Selim Cinek | 34c0a8d | 2014-05-12 00:01:43 +0200 | [diff] [blame] | 69 | private int mPaddingBetweenElementsDimmed; |
| 70 | private int mPaddingBetweenElementsNormal; |
| 71 | private int mBottomStackSlowDownLength; |
Selim Cinek | ad3e5af | 2014-07-04 12:24:11 +0200 | [diff] [blame] | 72 | private int mTopStackSlowDownLength; |
Selim Cinek | d83771e | 2014-07-04 16:45:31 +0200 | [diff] [blame] | 73 | private int mCollapseSecondCardPadding; |
Selim Cinek | 3afd00e | 2014-08-11 22:32:57 +0200 | [diff] [blame] | 74 | private boolean mIsSmallScreen; |
| 75 | private int mMaxNotificationHeight; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 76 | |
| 77 | public StackScrollAlgorithm(Context context) { |
| 78 | initConstants(context); |
Selim Cinek | 34c0a8d | 2014-05-12 00:01:43 +0200 | [diff] [blame] | 79 | updatePadding(false); |
| 80 | } |
| 81 | |
| 82 | private void updatePadding(boolean dimmed) { |
| 83 | mPaddingBetweenElements = dimmed |
| 84 | ? mPaddingBetweenElementsDimmed |
| 85 | : mPaddingBetweenElementsNormal; |
Selim Cinek | ad3e5af | 2014-07-04 12:24:11 +0200 | [diff] [blame] | 86 | mTopStackTotalSize = mTopStackSlowDownLength + mPaddingBetweenElements |
| 87 | + mTopStackPeekSize; |
Selim Cinek | 34c0a8d | 2014-05-12 00:01:43 +0200 | [diff] [blame] | 88 | mTopStackIndentationFunctor = new PiecewiseLinearIndentationFunctor( |
| 89 | MAX_ITEMS_IN_TOP_STACK, |
| 90 | mTopStackPeekSize, |
Selim Cinek | b96924d | 2014-05-12 15:11:25 +0200 | [diff] [blame] | 91 | mTopStackTotalSize - mTopStackPeekSize, |
Selim Cinek | 34c0a8d | 2014-05-12 00:01:43 +0200 | [diff] [blame] | 92 | 0.5f); |
| 93 | mBottomStackIndentationFunctor = new PiecewiseLinearIndentationFunctor( |
| 94 | MAX_ITEMS_IN_BOTTOM_STACK, |
| 95 | mBottomStackPeekSize, |
| 96 | getBottomStackSlowDownLength(), |
| 97 | 0.5f); |
| 98 | } |
| 99 | |
| 100 | public int getBottomStackSlowDownLength() { |
| 101 | return mBottomStackSlowDownLength + mPaddingBetweenElements; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | private void initConstants(Context context) { |
Selim Cinek | 34c0a8d | 2014-05-12 00:01:43 +0200 | [diff] [blame] | 105 | mPaddingBetweenElementsDimmed = context.getResources() |
| 106 | .getDimensionPixelSize(R.dimen.notification_padding_dimmed); |
| 107 | mPaddingBetweenElementsNormal = context.getResources() |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 108 | .getDimensionPixelSize(R.dimen.notification_padding); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 109 | mCollapsedSize = context.getResources() |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 110 | .getDimensionPixelSize(R.dimen.notification_min_height); |
Selim Cinek | 3afd00e | 2014-08-11 22:32:57 +0200 | [diff] [blame] | 111 | mMaxNotificationHeight = context.getResources() |
| 112 | .getDimensionPixelSize(R.dimen.notification_max_height); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 113 | mTopStackPeekSize = context.getResources() |
| 114 | .getDimensionPixelSize(R.dimen.top_stack_peek_amount); |
| 115 | mBottomStackPeekSize = context.getResources() |
| 116 | .getDimensionPixelSize(R.dimen.bottom_stack_peek_amount); |
| 117 | mZDistanceBetweenElements = context.getResources() |
| 118 | .getDimensionPixelSize(R.dimen.z_distance_between_notifications); |
| 119 | mZBasicHeight = (MAX_ITEMS_IN_BOTTOM_STACK + 1) * mZDistanceBetweenElements; |
Selim Cinek | 34c0a8d | 2014-05-12 00:01:43 +0200 | [diff] [blame] | 120 | mBottomStackSlowDownLength = context.getResources() |
| 121 | .getDimensionPixelSize(R.dimen.bottom_stack_slow_down_length); |
Selim Cinek | ad3e5af | 2014-07-04 12:24:11 +0200 | [diff] [blame] | 122 | mTopStackSlowDownLength = context.getResources() |
| 123 | .getDimensionPixelSize(R.dimen.top_stack_slow_down_length); |
Selim Cinek | 708a6c1 | 2014-05-28 14:16:02 +0200 | [diff] [blame] | 124 | mRoundedRectCornerRadius = context.getResources().getDimensionPixelSize( |
Selim Cinek | 697178b | 2014-07-02 19:40:30 +0200 | [diff] [blame] | 125 | R.dimen.notification_material_rounded_rect_radius); |
Selim Cinek | d83771e | 2014-07-04 16:45:31 +0200 | [diff] [blame] | 126 | mCollapseSecondCardPadding = context.getResources().getDimensionPixelSize( |
| 127 | R.dimen.notification_collapse_second_card_padding); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 131 | public void getStackScrollState(AmbientState ambientState, StackScrollState resultState) { |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 132 | // The state of the local variables are saved in an algorithmState to easily subdivide it |
| 133 | // into multiple phases. |
| 134 | StackScrollAlgorithmState algorithmState = mTempAlgorithmState; |
| 135 | |
| 136 | // First we reset the view states to their default values. |
| 137 | resultState.resetViewStates(); |
| 138 | |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 139 | algorithmState.itemsInTopStack = 0.0f; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 140 | algorithmState.partialInTop = 0.0f; |
| 141 | algorithmState.lastTopStackIndex = 0; |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 142 | algorithmState.scrolledPixelsTop = 0; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 143 | algorithmState.itemsInBottomStack = 0.0f; |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 144 | algorithmState.partialInBottom = 0.0f; |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 145 | float bottomOverScroll = ambientState.getOverScrollAmount(false /* onTop */); |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 146 | |
| 147 | int scrollY = ambientState.getScrollY(); |
| 148 | |
| 149 | // Due to the overScroller, the stackscroller can have negative scroll state. This is |
| 150 | // already accounted for by the top padding and doesn't need an additional adaption |
| 151 | scrollY = Math.max(0, scrollY); |
| 152 | algorithmState.scrollY = (int) (scrollY + mCollapsedSize + bottomOverScroll); |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 153 | |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 154 | updateVisibleChildren(resultState, algorithmState); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 155 | |
| 156 | // Phase 1: |
| 157 | findNumberOfItemsInTopStackAndUpdateState(resultState, algorithmState); |
| 158 | |
| 159 | // Phase 2: |
| 160 | updatePositionsForState(resultState, algorithmState); |
| 161 | |
| 162 | // Phase 3: |
| 163 | updateZValuesForState(resultState, algorithmState); |
Selim Cinek | eb97356 | 2014-05-02 17:07:49 +0200 | [diff] [blame] | 164 | |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 165 | handleDraggedViews(ambientState, resultState, algorithmState); |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 166 | updateDimmedActivatedHideSensitive(ambientState, resultState, algorithmState); |
Selim Cinek | 708a6c1 | 2014-05-28 14:16:02 +0200 | [diff] [blame] | 167 | updateClipping(resultState, algorithmState); |
Selim Cinek | f54090e | 2014-06-17 17:24:51 -0700 | [diff] [blame] | 168 | updateScrimAmount(resultState, algorithmState, ambientState.getScrimAmount()); |
Selim Cinek | 3d2b94bf | 2014-07-02 22:12:47 +0200 | [diff] [blame] | 169 | updateSpeedBumpState(resultState, algorithmState, ambientState.getSpeedBumpIndex()); |
| 170 | } |
| 171 | |
| 172 | private void updateSpeedBumpState(StackScrollState resultState, |
| 173 | StackScrollAlgorithmState algorithmState, int speedBumpIndex) { |
| 174 | int childCount = algorithmState.visibleChildren.size(); |
| 175 | for (int i = 0; i < childCount; i++) { |
| 176 | View child = algorithmState.visibleChildren.get(i); |
| 177 | StackScrollState.ViewState childViewState = resultState.getViewStateForView(child); |
Selim Cinek | 3107cfa | 2014-07-22 15:24:29 +0200 | [diff] [blame] | 178 | |
| 179 | // The speed bump can also be gone, so equality needs to be taken when comparing |
| 180 | // indices. |
| 181 | childViewState.belowSpeedBump = speedBumpIndex != -1 && i >= speedBumpIndex; |
Selim Cinek | 3d2b94bf | 2014-07-02 22:12:47 +0200 | [diff] [blame] | 182 | } |
Selim Cinek | f54090e | 2014-06-17 17:24:51 -0700 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | private void updateScrimAmount(StackScrollState resultState, |
| 186 | StackScrollAlgorithmState algorithmState, float scrimAmount) { |
| 187 | int childCount = algorithmState.visibleChildren.size(); |
| 188 | for (int i = 0; i < childCount; i++) { |
| 189 | View child = algorithmState.visibleChildren.get(i); |
| 190 | StackScrollState.ViewState childViewState = resultState.getViewStateForView(child); |
| 191 | childViewState.scrimAmount = scrimAmount; |
| 192 | } |
Selim Cinek | 708a6c1 | 2014-05-28 14:16:02 +0200 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | private void updateClipping(StackScrollState resultState, |
| 196 | StackScrollAlgorithmState algorithmState) { |
| 197 | float previousNotificationEnd = 0; |
| 198 | float previousNotificationStart = 0; |
| 199 | boolean previousNotificationIsSwiped = false; |
| 200 | int childCount = algorithmState.visibleChildren.size(); |
| 201 | for (int i = 0; i < childCount; i++) { |
| 202 | ExpandableView child = algorithmState.visibleChildren.get(i); |
| 203 | StackScrollState.ViewState state = resultState.getViewStateForView(child); |
Jorim Jaggi | 2e34ec3 | 2014-07-01 03:17:05 +0200 | [diff] [blame] | 204 | float newYTranslation = state.yTranslation + state.height * (1f - state.scale) / 2f; |
| 205 | float newHeight = state.height * state.scale; |
Selim Cinek | 708a6c1 | 2014-05-28 14:16:02 +0200 | [diff] [blame] | 206 | // apply clipping and shadow |
| 207 | float newNotificationEnd = newYTranslation + newHeight; |
| 208 | |
| 209 | // In the unlocked shade we have to clip a little bit higher because of the rounded |
| 210 | // corners of the notifications. |
Jorim Jaggi | 2e34ec3 | 2014-07-01 03:17:05 +0200 | [diff] [blame] | 211 | float clippingCorrection = state.dimmed ? 0 : mRoundedRectCornerRadius * state.scale; |
Selim Cinek | 708a6c1 | 2014-05-28 14:16:02 +0200 | [diff] [blame] | 212 | |
| 213 | // When the previous notification is swiped, we don't clip the content to the |
| 214 | // bottom of it. |
| 215 | float clipHeight = previousNotificationIsSwiped |
| 216 | ? newHeight |
| 217 | : newNotificationEnd - (previousNotificationEnd - clippingCorrection); |
| 218 | |
| 219 | updateChildClippingAndBackground(state, newHeight, clipHeight, |
Jorim Jaggi | 2e34ec3 | 2014-07-01 03:17:05 +0200 | [diff] [blame] | 220 | newHeight - (previousNotificationStart - newYTranslation)); |
Selim Cinek | 708a6c1 | 2014-05-28 14:16:02 +0200 | [diff] [blame] | 221 | |
| 222 | if (!child.isTransparent()) { |
| 223 | // Only update the previous values if we are not transparent, |
| 224 | // otherwise we would clip to a transparent view. |
Jorim Jaggi | 2e34ec3 | 2014-07-01 03:17:05 +0200 | [diff] [blame] | 225 | previousNotificationStart = newYTranslation + state.clipTopAmount * state.scale; |
Selim Cinek | 708a6c1 | 2014-05-28 14:16:02 +0200 | [diff] [blame] | 226 | previousNotificationEnd = newNotificationEnd; |
| 227 | previousNotificationIsSwiped = child.getTranslationX() != 0; |
| 228 | } |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | /** |
| 233 | * Updates the shadow outline and the clipping for a view. |
| 234 | * |
| 235 | * @param state the viewState to update |
| 236 | * @param realHeight the currently applied height of the view |
| 237 | * @param clipHeight the desired clip height, the rest of the view will be clipped from the top |
| 238 | * @param backgroundHeight the desired background height. The shadows of the view will be |
| 239 | * based on this height and the content will be clipped from the top |
| 240 | */ |
Jorim Jaggi | 2e34ec3 | 2014-07-01 03:17:05 +0200 | [diff] [blame] | 241 | private void updateChildClippingAndBackground(StackScrollState.ViewState state, |
| 242 | float realHeight, float clipHeight, float backgroundHeight) { |
Selim Cinek | 708a6c1 | 2014-05-28 14:16:02 +0200 | [diff] [blame] | 243 | if (realHeight > clipHeight) { |
Jorim Jaggi | 2e34ec3 | 2014-07-01 03:17:05 +0200 | [diff] [blame] | 244 | // Rather overlap than create a hole. |
| 245 | state.topOverLap = (int) Math.floor((realHeight - clipHeight) / state.scale); |
Selim Cinek | 708a6c1 | 2014-05-28 14:16:02 +0200 | [diff] [blame] | 246 | } else { |
| 247 | state.topOverLap = 0; |
| 248 | } |
| 249 | if (realHeight > backgroundHeight) { |
Jorim Jaggi | 2e34ec3 | 2014-07-01 03:17:05 +0200 | [diff] [blame] | 250 | // Rather overlap than create a hole. |
| 251 | state.clipTopAmount = (int) Math.floor((realHeight - backgroundHeight) / state.scale); |
Selim Cinek | 708a6c1 | 2014-05-28 14:16:02 +0200 | [diff] [blame] | 252 | } else { |
| 253 | state.clipTopAmount = 0; |
| 254 | } |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | /** |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 258 | * Updates the dimmed, activated and hiding sensitive states of the children. |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 259 | */ |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 260 | private void updateDimmedActivatedHideSensitive(AmbientState ambientState, |
| 261 | StackScrollState resultState, StackScrollAlgorithmState algorithmState) { |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 262 | boolean dimmed = ambientState.isDimmed(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 263 | boolean dark = ambientState.isDark(); |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 264 | boolean hideSensitive = ambientState.isHideSensitive(); |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 265 | View activatedChild = ambientState.getActivatedChild(); |
| 266 | int childCount = algorithmState.visibleChildren.size(); |
| 267 | for (int i = 0; i < childCount; i++) { |
| 268 | View child = algorithmState.visibleChildren.get(i); |
| 269 | StackScrollState.ViewState childViewState = resultState.getViewStateForView(child); |
| 270 | childViewState.dimmed = dimmed; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 271 | childViewState.dark = dark; |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 272 | childViewState.hideSensitive = hideSensitive; |
Selim Cinek | b89de4e | 2014-06-10 10:47:05 +0200 | [diff] [blame] | 273 | boolean isActivatedChild = activatedChild == child; |
| 274 | childViewState.scale = !dimmed || isActivatedChild |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 275 | ? 1.0f |
| 276 | : DIMMED_SCALE; |
Selim Cinek | b89de4e | 2014-06-10 10:47:05 +0200 | [diff] [blame] | 277 | if (dimmed && activatedChild != null) { |
| 278 | if (!isActivatedChild) { |
| 279 | childViewState.alpha *= ACTIVATED_INVERSE_ALPHA; |
| 280 | } else { |
| 281 | childViewState.zTranslation += 2.0f * mZDistanceBetweenElements; |
| 282 | } |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 283 | } |
| 284 | } |
Selim Cinek | eb97356 | 2014-05-02 17:07:49 +0200 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | /** |
| 288 | * Handle the special state when views are being dragged |
| 289 | */ |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 290 | private void handleDraggedViews(AmbientState ambientState, StackScrollState resultState, |
Selim Cinek | eb97356 | 2014-05-02 17:07:49 +0200 | [diff] [blame] | 291 | StackScrollAlgorithmState algorithmState) { |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 292 | ArrayList<View> draggedViews = ambientState.getDraggedViews(); |
| 293 | for (View draggedView : draggedViews) { |
Selim Cinek | eb97356 | 2014-05-02 17:07:49 +0200 | [diff] [blame] | 294 | int childIndex = algorithmState.visibleChildren.indexOf(draggedView); |
| 295 | if (childIndex >= 0 && childIndex < algorithmState.visibleChildren.size() - 1) { |
| 296 | View nextChild = algorithmState.visibleChildren.get(childIndex + 1); |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 297 | if (!draggedViews.contains(nextChild)) { |
Selim Cinek | eb97356 | 2014-05-02 17:07:49 +0200 | [diff] [blame] | 298 | // only if the view is not dragged itself we modify its state to be fully |
| 299 | // visible |
| 300 | StackScrollState.ViewState viewState = resultState.getViewStateForView( |
| 301 | nextChild); |
| 302 | // The child below the dragged one must be fully visible |
| 303 | viewState.alpha = 1; |
| 304 | } |
| 305 | |
| 306 | // Lets set the alpha to the one it currently has, as its currently being dragged |
| 307 | StackScrollState.ViewState viewState = resultState.getViewStateForView(draggedView); |
| 308 | // The dragged child should keep the set alpha |
| 309 | viewState.alpha = draggedView.getAlpha(); |
| 310 | } |
| 311 | } |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 312 | } |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 313 | |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 314 | /** |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 315 | * Update the visible children on the state. |
| 316 | */ |
| 317 | private void updateVisibleChildren(StackScrollState resultState, |
| 318 | StackScrollAlgorithmState state) { |
| 319 | ViewGroup hostView = resultState.getHostView(); |
| 320 | int childCount = hostView.getChildCount(); |
| 321 | state.visibleChildren.clear(); |
| 322 | state.visibleChildren.ensureCapacity(childCount); |
| 323 | for (int i = 0; i < childCount; i++) { |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 324 | ExpandableView v = (ExpandableView) hostView.getChildAt(i); |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 325 | if (v.getVisibility() != View.GONE) { |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 326 | StackScrollState.ViewState viewState = resultState.getViewStateForView(v); |
| 327 | viewState.notGoneIndex = state.visibleChildren.size(); |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 328 | state.visibleChildren.add(v); |
| 329 | } |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | /** |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 334 | * Determine the positions for the views. This is the main part of the algorithm. |
| 335 | * |
| 336 | * @param resultState The result state to update if a change to the properties of a child occurs |
| 337 | * @param algorithmState The state in which the current pass of the algorithm is currently in |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 338 | */ |
| 339 | private void updatePositionsForState(StackScrollState resultState, |
| 340 | StackScrollAlgorithmState algorithmState) { |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 341 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 342 | // The starting position of the bottom stack peek |
Jorim Jaggi | 8c1a44b | 2014-04-29 19:04:02 +0200 | [diff] [blame] | 343 | float bottomPeekStart = mInnerHeight - mBottomStackPeekSize; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 344 | |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 345 | // The position where the bottom stack starts. |
Selim Cinek | 34c0a8d | 2014-05-12 00:01:43 +0200 | [diff] [blame] | 346 | float bottomStackStart = bottomPeekStart - mBottomStackSlowDownLength; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 347 | |
| 348 | // The y coordinate of the current child. |
| 349 | float currentYPosition = 0.0f; |
| 350 | |
| 351 | // How far in is the element currently transitioning into the bottom stack. |
| 352 | float yPositionInScrollView = 0.0f; |
| 353 | |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 354 | int childCount = algorithmState.visibleChildren.size(); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 355 | int numberOfElementsCompletelyIn = (int) algorithmState.itemsInTopStack; |
| 356 | for (int i = 0; i < childCount; i++) { |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 357 | ExpandableView child = algorithmState.visibleChildren.get(i); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 358 | StackScrollState.ViewState childViewState = resultState.getViewStateForView(child); |
Christoph Studer | 6e3eceb | 2014-04-01 18:40:27 +0200 | [diff] [blame] | 359 | childViewState.location = StackScrollState.ViewState.LOCATION_UNKNOWN; |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 360 | int childHeight = getMaxAllowedChildHeight(child); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 361 | float yPositionInScrollViewAfterElement = yPositionInScrollView |
| 362 | + childHeight |
| 363 | + mPaddingBetweenElements; |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 364 | float scrollOffset = yPositionInScrollView - algorithmState.scrollY + mCollapsedSize; |
| 365 | |
| 366 | if (i == algorithmState.lastTopStackIndex + 1) { |
| 367 | // Normally the position of this child is the position in the regular scrollview, |
| 368 | // but if the two stacks are very close to each other, |
| 369 | // then have have to push it even more upwards to the position of the bottom |
| 370 | // stack start. |
| 371 | currentYPosition = Math.min(scrollOffset, bottomStackStart); |
| 372 | } |
| 373 | childViewState.yTranslation = currentYPosition; |
| 374 | |
| 375 | // The y position after this element |
| 376 | float nextYPosition = currentYPosition + childHeight + |
| 377 | mPaddingBetweenElements; |
| 378 | |
| 379 | if (i <= algorithmState.lastTopStackIndex) { |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 380 | // Case 1: |
| 381 | // We are in the top Stack |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 382 | updateStateForTopStackChild(algorithmState, |
| 383 | numberOfElementsCompletelyIn, i, childHeight, childViewState, scrollOffset); |
Selim Cinek | 3afd00e | 2014-08-11 22:32:57 +0200 | [diff] [blame] | 384 | clampPositionToTopStackEnd(childViewState, childHeight); |
| 385 | |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 386 | // check if we are overlapping with the bottom stack |
| 387 | if (childViewState.yTranslation + childHeight + mPaddingBetweenElements |
Selim Cinek | 4581cf8 | 2014-08-12 12:40:32 +0200 | [diff] [blame] | 388 | >= bottomStackStart && !mIsExpansionChanging && i != 0 && mIsSmallScreen) { |
Selim Cinek | 3afd00e | 2014-08-11 22:32:57 +0200 | [diff] [blame] | 389 | // we just collapse this element slightly |
| 390 | int newSize = (int) Math.max(bottomStackStart - mPaddingBetweenElements - |
| 391 | childViewState.yTranslation, mCollapsedSize); |
| 392 | childViewState.height = newSize; |
Selim Cinek | 4581cf8 | 2014-08-12 12:40:32 +0200 | [diff] [blame] | 393 | updateStateForChildTransitioningInBottom(algorithmState, bottomStackStart, |
| 394 | bottomPeekStart, childViewState.yTranslation, childViewState, |
| 395 | childHeight); |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 396 | } |
Selim Cinek | 3afd00e | 2014-08-11 22:32:57 +0200 | [diff] [blame] | 397 | clampPositionToBottomStackStart(childViewState, childViewState.height); |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 398 | } else if (nextYPosition >= bottomStackStart) { |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 399 | // Case 2: |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 400 | // We are in the bottom stack. |
| 401 | if (currentYPosition >= bottomStackStart) { |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 402 | // According to the regular scroll view we are fully translated out of the |
| 403 | // bottom of the screen so we are fully in the bottom stack |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 404 | updateStateForChildFullyInBottomStack(algorithmState, |
| 405 | bottomStackStart, childViewState, childHeight); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 406 | } else { |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 407 | // According to the regular scroll view we are currently translating out of / |
| 408 | // into the bottom of the screen |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 409 | updateStateForChildTransitioningInBottom(algorithmState, |
| 410 | bottomStackStart, bottomPeekStart, currentYPosition, |
| 411 | childViewState, childHeight); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 412 | } |
Christoph Studer | 6e3eceb | 2014-04-01 18:40:27 +0200 | [diff] [blame] | 413 | } else { |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 414 | // Case 3: |
| 415 | // We are in the regular scroll area. |
Christoph Studer | 6e3eceb | 2014-04-01 18:40:27 +0200 | [diff] [blame] | 416 | childViewState.location = StackScrollState.ViewState.LOCATION_MAIN_AREA; |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 417 | clampYTranslation(childViewState, childHeight); |
Christoph Studer | 6e3eceb | 2014-04-01 18:40:27 +0200 | [diff] [blame] | 418 | } |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 419 | |
Christoph Studer | 6e3eceb | 2014-04-01 18:40:27 +0200 | [diff] [blame] | 420 | // The first card is always rendered. |
| 421 | if (i == 0) { |
| 422 | childViewState.alpha = 1.0f; |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 423 | childViewState.yTranslation = Math.max(mCollapsedSize - algorithmState.scrollY, 0); |
Selim Cinek | d83771e | 2014-07-04 16:45:31 +0200 | [diff] [blame] | 424 | if (childViewState.yTranslation + childViewState.height |
| 425 | > bottomPeekStart - mCollapseSecondCardPadding) { |
Selim Cinek | 4fe3e47 | 2014-07-03 16:32:54 +0200 | [diff] [blame] | 426 | childViewState.height = (int) Math.max( |
Selim Cinek | d83771e | 2014-07-04 16:45:31 +0200 | [diff] [blame] | 427 | bottomPeekStart - mCollapseSecondCardPadding |
| 428 | - childViewState.yTranslation, mCollapsedSize); |
Selim Cinek | 4fe3e47 | 2014-07-03 16:32:54 +0200 | [diff] [blame] | 429 | } |
Christoph Studer | 6e3eceb | 2014-04-01 18:40:27 +0200 | [diff] [blame] | 430 | childViewState.location = StackScrollState.ViewState.LOCATION_FIRST_CARD; |
| 431 | } |
| 432 | if (childViewState.location == StackScrollState.ViewState.LOCATION_UNKNOWN) { |
| 433 | Log.wtf(LOG_TAG, "Failed to assign location for child " + i); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 434 | } |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 435 | currentYPosition = childViewState.yTranslation + childHeight + mPaddingBetweenElements; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 436 | yPositionInScrollView = yPositionInScrollViewAfterElement; |
Jorim Jaggi | 8c1a44b | 2014-04-29 19:04:02 +0200 | [diff] [blame] | 437 | |
| 438 | childViewState.yTranslation += mTopPadding; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 439 | } |
| 440 | } |
| 441 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 442 | /** |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 443 | * Clamp the yTranslation both up and down to valid positions. |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 444 | * |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 445 | * @param childViewState the view state of the child |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 446 | * @param childHeight the height of this child |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 447 | */ |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 448 | private void clampYTranslation(StackScrollState.ViewState childViewState, int childHeight) { |
| 449 | clampPositionToBottomStackStart(childViewState, childHeight); |
| 450 | clampPositionToTopStackEnd(childViewState, childHeight); |
| 451 | } |
| 452 | |
| 453 | /** |
| 454 | * Clamp the yTranslation of the child down such that its end is at most on the beginning of |
| 455 | * the bottom stack. |
| 456 | * |
| 457 | * @param childViewState the view state of the child |
| 458 | * @param childHeight the height of this child |
| 459 | */ |
| 460 | private void clampPositionToBottomStackStart(StackScrollState.ViewState childViewState, |
| 461 | int childHeight) { |
| 462 | childViewState.yTranslation = Math.min(childViewState.yTranslation, |
Selim Cinek | d83771e | 2014-07-04 16:45:31 +0200 | [diff] [blame] | 463 | mInnerHeight - mBottomStackPeekSize - mCollapseSecondCardPadding - childHeight); |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 464 | } |
| 465 | |
| 466 | /** |
| 467 | * Clamp the yTranslation of the child up such that its end is at lest on the end of the top |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 468 | * stack.get |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 469 | * |
| 470 | * @param childViewState the view state of the child |
| 471 | * @param childHeight the height of this child |
| 472 | */ |
| 473 | private void clampPositionToTopStackEnd(StackScrollState.ViewState childViewState, |
| 474 | int childHeight) { |
| 475 | childViewState.yTranslation = Math.max(childViewState.yTranslation, |
| 476 | mCollapsedSize - childHeight); |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 477 | } |
| 478 | |
| 479 | private int getMaxAllowedChildHeight(View child) { |
| 480 | if (child instanceof ExpandableNotificationRow) { |
| 481 | ExpandableNotificationRow row = (ExpandableNotificationRow) child; |
Jorim Jaggi | 9cbadd3 | 2014-05-01 20:18:31 +0200 | [diff] [blame] | 482 | return row.getIntrinsicHeight(); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 483 | } else if (child instanceof ExpandableView) { |
| 484 | ExpandableView expandableView = (ExpandableView) child; |
| 485 | return expandableView.getActualHeight(); |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 486 | } |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 487 | return child == null? mCollapsedSize : child.getHeight(); |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 488 | } |
| 489 | |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 490 | private void updateStateForChildTransitioningInBottom(StackScrollAlgorithmState algorithmState, |
| 491 | float transitioningPositionStart, float bottomPeakStart, float currentYPosition, |
| 492 | StackScrollState.ViewState childViewState, int childHeight) { |
Christoph Studer | 6e3eceb | 2014-04-01 18:40:27 +0200 | [diff] [blame] | 493 | |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 494 | // This is the transitioning element on top of bottom stack, calculate how far we are in. |
| 495 | algorithmState.partialInBottom = 1.0f - ( |
| 496 | (transitioningPositionStart - currentYPosition) / (childHeight + |
| 497 | mPaddingBetweenElements)); |
| 498 | |
| 499 | // the offset starting at the transitionPosition of the bottom stack |
| 500 | float offset = mBottomStackIndentationFunctor.getValue(algorithmState.partialInBottom); |
| 501 | algorithmState.itemsInBottomStack += algorithmState.partialInBottom; |
Selim Cinek | 3afd00e | 2014-08-11 22:32:57 +0200 | [diff] [blame] | 502 | int newHeight = childHeight; |
| 503 | if (childHeight > mCollapsedSize && mIsSmallScreen) { |
| 504 | newHeight = (int) Math.max(Math.min(transitioningPositionStart + offset - |
| 505 | mPaddingBetweenElements - currentYPosition, childHeight), mCollapsedSize); |
| 506 | childViewState.height = newHeight; |
| 507 | } |
| 508 | childViewState.yTranslation = transitioningPositionStart + offset - newHeight |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 509 | - mPaddingBetweenElements; |
Selim Cinek | 3afd00e | 2014-08-11 22:32:57 +0200 | [diff] [blame] | 510 | |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 511 | // We want at least to be at the end of the top stack when collapsing |
Selim Cinek | 3afd00e | 2014-08-11 22:32:57 +0200 | [diff] [blame] | 512 | clampPositionToTopStackEnd(childViewState, newHeight); |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 513 | childViewState.location = StackScrollState.ViewState.LOCATION_MAIN_AREA; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 514 | } |
| 515 | |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 516 | private void updateStateForChildFullyInBottomStack(StackScrollAlgorithmState algorithmState, |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 517 | float transitioningPositionStart, StackScrollState.ViewState childViewState, |
| 518 | int childHeight) { |
| 519 | |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 520 | float currentYPosition; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 521 | algorithmState.itemsInBottomStack += 1.0f; |
| 522 | if (algorithmState.itemsInBottomStack < MAX_ITEMS_IN_BOTTOM_STACK) { |
| 523 | // We are visually entering the bottom stack |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 524 | currentYPosition = transitioningPositionStart |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 525 | + mBottomStackIndentationFunctor.getValue(algorithmState.itemsInBottomStack) |
| 526 | - mPaddingBetweenElements; |
Christoph Studer | 6e3eceb | 2014-04-01 18:40:27 +0200 | [diff] [blame] | 527 | childViewState.location = StackScrollState.ViewState.LOCATION_BOTTOM_STACK_PEEKING; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 528 | } else { |
| 529 | // we are fully inside the stack |
| 530 | if (algorithmState.itemsInBottomStack > MAX_ITEMS_IN_BOTTOM_STACK + 2) { |
| 531 | childViewState.alpha = 0.0f; |
| 532 | } else if (algorithmState.itemsInBottomStack |
| 533 | > MAX_ITEMS_IN_BOTTOM_STACK + 1) { |
| 534 | childViewState.alpha = 1.0f - algorithmState.partialInBottom; |
| 535 | } |
Christoph Studer | 6e3eceb | 2014-04-01 18:40:27 +0200 | [diff] [blame] | 536 | childViewState.location = StackScrollState.ViewState.LOCATION_BOTTOM_STACK_HIDDEN; |
Jorim Jaggi | 8c1a44b | 2014-04-29 19:04:02 +0200 | [diff] [blame] | 537 | currentYPosition = mInnerHeight; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 538 | } |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 539 | childViewState.yTranslation = currentYPosition - childHeight; |
| 540 | clampPositionToTopStackEnd(childViewState, childHeight); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 541 | } |
| 542 | |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 543 | private void updateStateForTopStackChild(StackScrollAlgorithmState algorithmState, |
| 544 | int numberOfElementsCompletelyIn, int i, int childHeight, |
| 545 | StackScrollState.ViewState childViewState, float scrollOffset) { |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 546 | |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 547 | |
| 548 | // First we calculate the index relative to the current stack window of size at most |
| 549 | // {@link #MAX_ITEMS_IN_TOP_STACK} |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 550 | int paddedIndex = i - 1 |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 551 | - Math.max(numberOfElementsCompletelyIn - MAX_ITEMS_IN_TOP_STACK, 0); |
| 552 | if (paddedIndex >= 0) { |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 553 | |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 554 | // We are currently visually entering the top stack |
Selim Cinek | ad3e5af | 2014-07-04 12:24:11 +0200 | [diff] [blame] | 555 | float distanceToStack = (childHeight + mPaddingBetweenElements) |
| 556 | - algorithmState.scrolledPixelsTop; |
| 557 | if (i == algorithmState.lastTopStackIndex |
| 558 | && distanceToStack > (mTopStackTotalSize + mPaddingBetweenElements)) { |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 559 | |
| 560 | // Child is currently translating into stack but not yet inside slow down zone. |
| 561 | // Handle it like the regular scrollview. |
| 562 | childViewState.yTranslation = scrollOffset; |
Christoph Studer | 6e3eceb | 2014-04-01 18:40:27 +0200 | [diff] [blame] | 563 | } else { |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 564 | // Apply stacking logic. |
| 565 | float numItemsBefore; |
| 566 | if (i == algorithmState.lastTopStackIndex) { |
Selim Cinek | ad3e5af | 2014-07-04 12:24:11 +0200 | [diff] [blame] | 567 | numItemsBefore = 1.0f |
| 568 | - (distanceToStack / (mTopStackTotalSize + mPaddingBetweenElements)); |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 569 | } else { |
| 570 | numItemsBefore = algorithmState.itemsInTopStack - i; |
| 571 | } |
| 572 | // The end position of the current child |
Selim Cinek | ad3e5af | 2014-07-04 12:24:11 +0200 | [diff] [blame] | 573 | float currentChildEndY = mCollapsedSize + mTopStackTotalSize |
| 574 | - mTopStackIndentationFunctor.getValue(numItemsBefore); |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 575 | childViewState.yTranslation = currentChildEndY - childHeight; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 576 | } |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 577 | childViewState.location = StackScrollState.ViewState.LOCATION_TOP_STACK_PEEKING; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 578 | } else { |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 579 | if (paddedIndex == -1) { |
| 580 | childViewState.alpha = 1.0f - algorithmState.partialInTop; |
| 581 | } else { |
| 582 | // We are hidden behind the top card and faded out, so we can hide ourselves. |
| 583 | childViewState.alpha = 0.0f; |
| 584 | } |
| 585 | childViewState.yTranslation = mCollapsedSize - childHeight; |
Christoph Studer | 6e3eceb | 2014-04-01 18:40:27 +0200 | [diff] [blame] | 586 | childViewState.location = StackScrollState.ViewState.LOCATION_TOP_STACK_HIDDEN; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 587 | } |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 588 | |
| 589 | |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 590 | } |
| 591 | |
| 592 | /** |
| 593 | * Find the number of items in the top stack and update the result state if needed. |
| 594 | * |
| 595 | * @param resultState The result state to update if a height change of an child occurs |
| 596 | * @param algorithmState The state in which the current pass of the algorithm is currently in |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 597 | */ |
| 598 | private void findNumberOfItemsInTopStackAndUpdateState(StackScrollState resultState, |
| 599 | StackScrollAlgorithmState algorithmState) { |
| 600 | |
| 601 | // The y Position if the element would be in a regular scrollView |
| 602 | float yPositionInScrollView = 0.0f; |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 603 | int childCount = algorithmState.visibleChildren.size(); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 604 | |
| 605 | // find the number of elements in the top stack. |
| 606 | for (int i = 0; i < childCount; i++) { |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 607 | ExpandableView child = algorithmState.visibleChildren.get(i); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 608 | StackScrollState.ViewState childViewState = resultState.getViewStateForView(child); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 609 | int childHeight = getMaxAllowedChildHeight(child); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 610 | float yPositionInScrollViewAfterElement = yPositionInScrollView |
| 611 | + childHeight |
| 612 | + mPaddingBetweenElements; |
| 613 | if (yPositionInScrollView < algorithmState.scrollY) { |
Selim Cinek | 8d9ff9c | 2014-05-12 15:13:04 +0200 | [diff] [blame] | 614 | if (i == 0 && algorithmState.scrollY <= mCollapsedSize) { |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 615 | |
| 616 | // The starting position of the bottom stack peek |
Selim Cinek | d83771e | 2014-07-04 16:45:31 +0200 | [diff] [blame] | 617 | int bottomPeekStart = mInnerHeight - mBottomStackPeekSize - |
| 618 | mCollapseSecondCardPadding; |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 619 | // Collapse and expand the first child while the shade is being expanded |
| 620 | float maxHeight = mIsExpansionChanging && child == mFirstChildWhileExpanding |
| 621 | ? mFirstChildMaxHeight |
| 622 | : childHeight; |
| 623 | childViewState.height = (int) Math.max(Math.min(bottomPeekStart, maxHeight), |
| 624 | mCollapsedSize); |
| 625 | algorithmState.itemsInTopStack = 1.0f; |
| 626 | |
| 627 | } else if (yPositionInScrollViewAfterElement < algorithmState.scrollY) { |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 628 | // According to the regular scroll view we are fully off screen |
| 629 | algorithmState.itemsInTopStack += 1.0f; |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 630 | if (i == 0) { |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 631 | childViewState.height = mCollapsedSize; |
| 632 | } |
| 633 | } else { |
| 634 | // According to the regular scroll view we are partially off screen |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 635 | |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 636 | // How much did we scroll into this child |
Selim Cinek | ad3e5af | 2014-07-04 12:24:11 +0200 | [diff] [blame] | 637 | algorithmState.scrolledPixelsTop = algorithmState.scrollY |
| 638 | - yPositionInScrollView; |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 639 | algorithmState.partialInTop = (algorithmState.scrolledPixelsTop) / (childHeight |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 640 | + mPaddingBetweenElements); |
| 641 | |
| 642 | // Our element can be expanded, so this can get negative |
| 643 | algorithmState.partialInTop = Math.max(0.0f, algorithmState.partialInTop); |
| 644 | algorithmState.itemsInTopStack += algorithmState.partialInTop; |
Selim Cinek | ad3e5af | 2014-07-04 12:24:11 +0200 | [diff] [blame] | 645 | |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 646 | if (i == 0) { |
Selim Cinek | ad3e5af | 2014-07-04 12:24:11 +0200 | [diff] [blame] | 647 | // If it is expanded we have to collapse it to a new size |
| 648 | float newSize = yPositionInScrollViewAfterElement |
| 649 | - mPaddingBetweenElements |
| 650 | - algorithmState.scrollY + mCollapsedSize; |
| 651 | newSize = Math.max(mCollapsedSize, newSize); |
Selim Cinek | 4e456be | 2014-06-12 18:09:43 +0200 | [diff] [blame] | 652 | algorithmState.itemsInTopStack = 1.0f; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 653 | childViewState.height = (int) newSize; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 654 | } |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 655 | algorithmState.lastTopStackIndex = i; |
| 656 | break; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 657 | } |
| 658 | } else { |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 659 | algorithmState.lastTopStackIndex = i - 1; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 660 | // We are already past the stack so we can end the loop |
| 661 | break; |
| 662 | } |
| 663 | yPositionInScrollView = yPositionInScrollViewAfterElement; |
| 664 | } |
| 665 | } |
| 666 | |
| 667 | /** |
| 668 | * Calculate the Z positions for all children based on the number of items in both stacks and |
| 669 | * save it in the resultState |
| 670 | * |
| 671 | * @param resultState The result state to update the zTranslation values |
| 672 | * @param algorithmState The state in which the current pass of the algorithm is currently in |
| 673 | */ |
| 674 | private void updateZValuesForState(StackScrollState resultState, |
| 675 | StackScrollAlgorithmState algorithmState) { |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 676 | int childCount = algorithmState.visibleChildren.size(); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 677 | for (int i = 0; i < childCount; i++) { |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 678 | View child = algorithmState.visibleChildren.get(i); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 679 | StackScrollState.ViewState childViewState = resultState.getViewStateForView(child); |
| 680 | if (i < algorithmState.itemsInTopStack) { |
| 681 | float stackIndex = algorithmState.itemsInTopStack - i; |
| 682 | stackIndex = Math.min(stackIndex, MAX_ITEMS_IN_TOP_STACK + 2); |
Selim Cinek | 4e456be | 2014-06-12 18:09:43 +0200 | [diff] [blame] | 683 | if (i == 0 && algorithmState.itemsInTopStack < 2.0f) { |
| 684 | |
| 685 | // We only have the top item and an additional item in the top stack, |
| 686 | // Interpolate the index from 0 to 2 while the second item is |
| 687 | // translating in. |
| 688 | stackIndex -= 1.0f; |
| 689 | if (algorithmState.scrollY > mCollapsedSize) { |
| 690 | |
| 691 | // Since there is a shadow treshhold, we cant just interpolate from 0 to |
| 692 | // 2 but we interpolate from 0.1f to 2.0f when scrolled in. The jump in |
| 693 | // height will not be noticable since we have padding in between. |
| 694 | stackIndex = 0.1f + stackIndex * 1.9f; |
| 695 | } |
| 696 | } |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 697 | childViewState.zTranslation = mZBasicHeight |
| 698 | + stackIndex * mZDistanceBetweenElements; |
| 699 | } else if (i > (childCount - 1 - algorithmState.itemsInBottomStack)) { |
| 700 | float numItemsAbove = i - (childCount - 1 - algorithmState.itemsInBottomStack); |
| 701 | float translationZ = mZBasicHeight |
| 702 | - numItemsAbove * mZDistanceBetweenElements; |
| 703 | childViewState.zTranslation = translationZ; |
| 704 | } else { |
| 705 | childViewState.zTranslation = mZBasicHeight; |
| 706 | } |
| 707 | } |
| 708 | } |
| 709 | |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 710 | public void setLayoutHeight(int layoutHeight) { |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 711 | this.mLayoutHeight = layoutHeight; |
Jorim Jaggi | 8c1a44b | 2014-04-29 19:04:02 +0200 | [diff] [blame] | 712 | updateInnerHeight(); |
| 713 | } |
| 714 | |
| 715 | public void setTopPadding(int topPadding) { |
| 716 | mTopPadding = topPadding; |
| 717 | updateInnerHeight(); |
| 718 | } |
| 719 | |
| 720 | private void updateInnerHeight() { |
| 721 | mInnerHeight = mLayoutHeight - mTopPadding; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 722 | } |
| 723 | |
Selim Cinek | 3afd00e | 2014-08-11 22:32:57 +0200 | [diff] [blame] | 724 | |
| 725 | /** |
| 726 | * Update whether the device is very small, i.e. Notifications can be in both the top and the |
| 727 | * bottom stack at the same time |
| 728 | * |
| 729 | * @param panelHeight The normal height of the panel when it's open |
| 730 | */ |
| 731 | public void updateIsSmallScreen(int panelHeight) { |
| 732 | mIsSmallScreen = panelHeight < |
| 733 | mCollapsedSize /* top stack */ |
| 734 | + mBottomStackSlowDownLength + mBottomStackPeekSize /* bottom stack */ |
| 735 | + mMaxNotificationHeight; /* max notification height */ |
| 736 | } |
| 737 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 738 | public void onExpansionStarted(StackScrollState currentState) { |
| 739 | mIsExpansionChanging = true; |
| 740 | mExpandedOnStart = mIsExpanded; |
| 741 | ViewGroup hostView = currentState.getHostView(); |
| 742 | updateFirstChildHeightWhileExpanding(hostView); |
| 743 | } |
| 744 | |
| 745 | private void updateFirstChildHeightWhileExpanding(ViewGroup hostView) { |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 746 | mFirstChildWhileExpanding = (ExpandableView) findFirstVisibleChild(hostView); |
Jorim Jaggi | 9f347ae | 2014-04-11 00:47:18 +0200 | [diff] [blame] | 747 | if (mFirstChildWhileExpanding != null) { |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 748 | if (mExpandedOnStart) { |
| 749 | |
| 750 | // We are collapsing the shade, so the first child can get as most as high as the |
| 751 | // current height. |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 752 | mFirstChildMaxHeight = mFirstChildWhileExpanding.getActualHeight(); |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 753 | } else { |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame^] | 754 | updateFirstChildMaxSizeToMaxHeight(); |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 755 | } |
| 756 | } else { |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 757 | mFirstChildMaxHeight = 0; |
| 758 | } |
| 759 | } |
| 760 | |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame^] | 761 | private void updateFirstChildMaxSizeToMaxHeight() { |
| 762 | // We are expanding the shade, expand it to its full height. |
| 763 | if (!isMaxSizeInitialized(mFirstChildWhileExpanding)) { |
| 764 | |
| 765 | // This child was not layouted yet, wait for a layout pass |
| 766 | mFirstChildWhileExpanding |
| 767 | .addOnLayoutChangeListener(new View.OnLayoutChangeListener() { |
| 768 | @Override |
| 769 | public void onLayoutChange(View v, int left, int top, int right, |
| 770 | int bottom, int oldLeft, int oldTop, int oldRight, |
| 771 | int oldBottom) { |
| 772 | if (mFirstChildWhileExpanding != null) { |
| 773 | mFirstChildMaxHeight = getMaxAllowedChildHeight( |
| 774 | mFirstChildWhileExpanding); |
| 775 | } else { |
| 776 | mFirstChildMaxHeight = 0; |
| 777 | } |
| 778 | v.removeOnLayoutChangeListener(this); |
| 779 | } |
| 780 | }); |
| 781 | } else { |
| 782 | mFirstChildMaxHeight = getMaxAllowedChildHeight(mFirstChildWhileExpanding); |
| 783 | } |
| 784 | } |
| 785 | |
Selim Cinek | 7d44772 | 2014-06-10 15:51:59 +0200 | [diff] [blame] | 786 | private boolean isMaxSizeInitialized(ExpandableView child) { |
| 787 | if (child instanceof ExpandableNotificationRow) { |
| 788 | ExpandableNotificationRow row = (ExpandableNotificationRow) child; |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame^] | 789 | return row.isMaxExpandHeightInitialized(); |
Selim Cinek | 7d44772 | 2014-06-10 15:51:59 +0200 | [diff] [blame] | 790 | } |
| 791 | return child == null || child.getWidth() != 0; |
| 792 | } |
| 793 | |
Jorim Jaggi | 9f347ae | 2014-04-11 00:47:18 +0200 | [diff] [blame] | 794 | private View findFirstVisibleChild(ViewGroup container) { |
| 795 | int childCount = container.getChildCount(); |
| 796 | for (int i = 0; i < childCount; i++) { |
| 797 | View child = container.getChildAt(i); |
| 798 | if (child.getVisibility() != View.GONE) { |
| 799 | return child; |
| 800 | } |
| 801 | } |
| 802 | return null; |
| 803 | } |
| 804 | |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 805 | public void onExpansionStopped() { |
| 806 | mIsExpansionChanging = false; |
| 807 | mFirstChildWhileExpanding = null; |
| 808 | } |
| 809 | |
| 810 | public void setIsExpanded(boolean isExpanded) { |
| 811 | this.mIsExpanded = isExpanded; |
| 812 | } |
| 813 | |
| 814 | public void notifyChildrenChanged(ViewGroup hostView) { |
| 815 | if (mIsExpansionChanging) { |
| 816 | updateFirstChildHeightWhileExpanding(hostView); |
| 817 | } |
| 818 | } |
| 819 | |
Selim Cinek | 34c0a8d | 2014-05-12 00:01:43 +0200 | [diff] [blame] | 820 | public void setDimmed(boolean dimmed) { |
| 821 | updatePadding(dimmed); |
| 822 | } |
| 823 | |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame^] | 824 | public void onReset(ExpandableView view) { |
| 825 | if (view.equals(mFirstChildWhileExpanding)) { |
| 826 | updateFirstChildMaxSizeToMaxHeight(); |
| 827 | } |
| 828 | } |
| 829 | |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 830 | class StackScrollAlgorithmState { |
| 831 | |
| 832 | /** |
| 833 | * The scroll position of the algorithm |
| 834 | */ |
| 835 | public int scrollY; |
| 836 | |
| 837 | /** |
| 838 | * The quantity of items which are in the top stack. |
| 839 | */ |
| 840 | public float itemsInTopStack; |
| 841 | |
| 842 | /** |
| 843 | * how far in is the element currently transitioning into the top stack |
| 844 | */ |
| 845 | public float partialInTop; |
| 846 | |
| 847 | /** |
Selim Cinek | 343e6e2 | 2014-04-11 21:23:30 +0200 | [diff] [blame] | 848 | * The number of pixels the last child in the top stack has scrolled in to the stack |
| 849 | */ |
| 850 | public float scrolledPixelsTop; |
| 851 | |
| 852 | /** |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 853 | * The last item index which is in the top stack. |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 854 | */ |
| 855 | public int lastTopStackIndex; |
| 856 | |
| 857 | /** |
| 858 | * The quantity of items which are in the bottom stack. |
| 859 | */ |
| 860 | public float itemsInBottomStack; |
| 861 | |
| 862 | /** |
| 863 | * how far in is the element currently transitioning into the bottom stack |
| 864 | */ |
| 865 | public float partialInBottom; |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 866 | |
| 867 | /** |
| 868 | * The children from the host view which are not gone. |
| 869 | */ |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 870 | public final ArrayList<ExpandableView> visibleChildren = new ArrayList<ExpandableView>(); |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 871 | } |
| 872 | |
| 873 | } |