From a424c504d585fa948ec0bacb692af1e2260fc9cf Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Tue, 5 Apr 2016 13:07:54 -0700 Subject: [PATCH] Fixed a bug where the scrollrange was calculated wrong First the scrollrange would allow the first element to be collapsed which doesn't make sense now that it's scrolling off. It could also be wrong if the notification was a group. Then the scrollrange was also wrong because the bottomInset was always added even though it shouldn't have done that. Change-Id: I7184946c4406bc0b5796194af86155aa6ba68c8e Fixes: 28015188 --- .../stack/NotificationStackScrollLayout.java | 33 ++++++++----------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java index bb1de046c291a..3fd60ea9432af 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -926,7 +926,7 @@ public class NotificationStackScrollLayout extends ViewGroup int positionInLinearLayout = getPositionInLinearLayout(v); int targetScroll = positionInLinearLayout + expandableView.getActualHeight() + - mBottomInset - getHeight() + getTopPadding(); + getImeInset() - getHeight() + getTopPadding(); if (mOwnScrollY < targetScroll) { mScroller.startScroll(mScrollX, mOwnScrollY, 0, targetScroll - mOwnScrollY); mDontReportNextOverScroll = true; @@ -936,8 +936,7 @@ public class NotificationStackScrollLayout extends ViewGroup @Override public WindowInsets onApplyWindowInsets(WindowInsets insets) { - mBottomInset = Math.max(0, insets.getSystemWindowInsetBottom() - - (getRootView().getHeight() - getHeight())); + mBottomInset = insets.getSystemWindowInsetBottom(); int range = getScrollRange(); if (mOwnScrollY > range) { @@ -1506,23 +1505,17 @@ public class NotificationStackScrollLayout extends ViewGroup } private int getScrollRange() { - int scrollRange = 0; - ExpandableView firstChild = (ExpandableView) getFirstChildNotGone(); - if (firstChild != null) { - int contentHeight = getContentHeight(); - scrollRange = Math.max(0, contentHeight - mMaxLayoutHeight + mBottomStackPeekSize - + mBottomStackSlowDownHeight); - if (scrollRange > 0) { - int firstChildMaxExpandHeight = getMaxExpandHeight(firstChild); - // We want to at least be able collapse the first item and not ending in a weird - // end state. - scrollRange = Math.max(scrollRange, firstChildMaxExpandHeight - - firstChild.getMinHeight()); - } - } - int imeOverlap = Math.max(0, - getContentHeight() - (getHeight() - mBottomInset)); - return scrollRange + imeOverlap; + int contentHeight = getContentHeight(); + int scrollRange = Math.max(0, contentHeight - mMaxLayoutHeight + mBottomStackPeekSize + + mBottomStackSlowDownHeight); + int imeInset = getImeInset(); + scrollRange += Math.min(imeInset, Math.max(0, + getContentHeight() - (getHeight() - imeInset))); + return scrollRange; + } + + private int getImeInset() { + return Math.max(0, mBottomInset - (getRootView().getHeight() - getHeight())); } /**