Skip to content

Commit 3afd00e

Browse files
author
Selim Cinek
committed
Fixed a bug in the notification stack algorithm
Bad holes could occur when a notification was at the same time in the top and the bottom stack. This also improves the landscape / smallscreen interaction with the shade. Bug: 16715133 Change-Id: Icbb4d080e658f4ddbd39b7d08652ca5311a47978
1 parent 8705eb9 commit 3afd00e

3 files changed

Lines changed: 44 additions & 7 deletions

File tree

packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
279279
positionClockAndNotifications();
280280
mNotificationStackScroller.setStackHeight(getExpandedHeight());
281281
}
282+
mNotificationStackScroller.updateIsSmallScreen(
283+
mHeader.getCollapsedHeight() + mQsPeekHeight);
282284
}
283285

284286
@Override

packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2164,6 +2164,14 @@ public float getBottomMostNotificationBottom() {
21642164
return max + getTranslationY();
21652165
}
21662166

2167+
/**
2168+
* @param qsMinHeight The minimum height of the quick settings including padding
2169+
* See {@link StackScrollAlgorithm#updateIsSmallScreen}.
2170+
*/
2171+
public void updateIsSmallScreen(int qsMinHeight) {
2172+
mStackScrollAlgorithm.updateIsSmallScreen(mMaxLayoutHeight - qsMinHeight);
2173+
}
2174+
21672175
/**
21682176
* A listener that is notified when some child locations might have changed.
21692177
*/

packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public class StackScrollAlgorithm {
7171
private int mBottomStackSlowDownLength;
7272
private int mTopStackSlowDownLength;
7373
private int mCollapseSecondCardPadding;
74+
private boolean mIsSmallScreen;
75+
private int mMaxNotificationHeight;
7476

7577
public StackScrollAlgorithm(Context context) {
7678
initConstants(context);
@@ -106,6 +108,8 @@ private void initConstants(Context context) {
106108
.getDimensionPixelSize(R.dimen.notification_padding);
107109
mCollapsedSize = context.getResources()
108110
.getDimensionPixelSize(R.dimen.notification_min_height);
111+
mMaxNotificationHeight = context.getResources()
112+
.getDimensionPixelSize(R.dimen.notification_max_height);
109113
mTopStackPeekSize = context.getResources()
110114
.getDimensionPixelSize(R.dimen.top_stack_peek_amount);
111115
mBottomStackPeekSize = context.getResources()
@@ -377,14 +381,17 @@ private void updatePositionsForState(StackScrollState resultState,
377381
// We are in the top Stack
378382
updateStateForTopStackChild(algorithmState,
379383
numberOfElementsCompletelyIn, i, childHeight, childViewState, scrollOffset);
380-
clampYTranslation(childViewState, childHeight);
384+
clampPositionToTopStackEnd(childViewState, childHeight);
385+
381386
// check if we are overlapping with the bottom stack
382387
if (childViewState.yTranslation + childHeight + mPaddingBetweenElements
383388
>= bottomStackStart && !mIsExpansionChanging && i != 0) {
384-
// TODO: handle overlapping sizes with end stack better
385-
// we just collapse this element
386-
childViewState.height = mCollapsedSize;
389+
// we just collapse this element slightly
390+
int newSize = (int) Math.max(bottomStackStart - mPaddingBetweenElements -
391+
childViewState.yTranslation, mCollapsedSize);
392+
childViewState.height = newSize;
387393
}
394+
clampPositionToBottomStackStart(childViewState, childViewState.height);
388395
} else if (nextYPosition >= bottomStackStart) {
389396
// Case 2:
390397
// We are in the bottom stack.
@@ -489,11 +496,17 @@ private void updateStateForChildTransitioningInBottom(StackScrollAlgorithmState
489496
// the offset starting at the transitionPosition of the bottom stack
490497
float offset = mBottomStackIndentationFunctor.getValue(algorithmState.partialInBottom);
491498
algorithmState.itemsInBottomStack += algorithmState.partialInBottom;
492-
childViewState.yTranslation = transitioningPositionStart + offset - childHeight
499+
int newHeight = childHeight;
500+
if (childHeight > mCollapsedSize && mIsSmallScreen) {
501+
newHeight = (int) Math.max(Math.min(transitioningPositionStart + offset -
502+
mPaddingBetweenElements - currentYPosition, childHeight), mCollapsedSize);
503+
childViewState.height = newHeight;
504+
}
505+
childViewState.yTranslation = transitioningPositionStart + offset - newHeight
493506
- mPaddingBetweenElements;
494-
507+
495508
// We want at least to be at the end of the top stack when collapsing
496-
clampPositionToTopStackEnd(childViewState, childHeight);
509+
clampPositionToTopStackEnd(childViewState, newHeight);
497510
childViewState.location = StackScrollState.ViewState.LOCATION_MAIN_AREA;
498511
}
499512

@@ -705,6 +718,20 @@ private void updateInnerHeight() {
705718
mInnerHeight = mLayoutHeight - mTopPadding;
706719
}
707720

721+
722+
/**
723+
* Update whether the device is very small, i.e. Notifications can be in both the top and the
724+
* bottom stack at the same time
725+
*
726+
* @param panelHeight The normal height of the panel when it's open
727+
*/
728+
public void updateIsSmallScreen(int panelHeight) {
729+
mIsSmallScreen = panelHeight <
730+
mCollapsedSize /* top stack */
731+
+ mBottomStackSlowDownLength + mBottomStackPeekSize /* bottom stack */
732+
+ mMaxNotificationHeight; /* max notification height */
733+
}
734+
708735
public void onExpansionStarted(StackScrollState currentState) {
709736
mIsExpansionChanging = true;
710737
mExpandedOnStart = mIsExpanded;

0 commit comments

Comments
 (0)