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