Loading packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +28 −47 Original line number Diff line number Diff line Loading @@ -364,6 +364,7 @@ public class NotificationStackScrollLayout extends ViewGroup private boolean mHeadsUpAnimatingAway; private int mStatusBarState; private int mCachedBackgroundColor; private Runnable mAnimateScroll = this::animateScroll; public NotificationStackScrollLayout(Context context) { this(context, null); Loading Loading @@ -1169,7 +1170,7 @@ public class NotificationStackScrollLayout extends ViewGroup if (mOwnScrollY < targetScroll || outOfViewScroll < mOwnScrollY) { mScroller.startScroll(mScrollX, mOwnScrollY, 0, targetScroll - mOwnScrollY); mDontReportNextOverScroll = true; postInvalidateOnAnimation(); animateScroll(); return true; } return false; Loading Loading @@ -1209,7 +1210,7 @@ public class NotificationStackScrollLayout extends ViewGroup mScroller.startScroll(mScrollX, mOwnScrollY, 0, range - mOwnScrollY); mDontReportNextOverScroll = true; mDontClampNextScroll = true; postInvalidateOnAnimation(); animateScroll(); } }; Loading Loading @@ -1326,7 +1327,7 @@ public class NotificationStackScrollLayout extends ViewGroup newScrollY = range; } if (newScrollY != oldScrollY) { customScrollTo(newScrollY); setOwnScrollY(newScrollY); return true; } } Loading Loading @@ -1406,13 +1407,13 @@ public class NotificationStackScrollLayout extends ViewGroup scrollAmount = overScrollUp(deltaY, range); } // Calling overScrollBy will call onOverScrolled, which // calls onScrollChanged if applicable. // Calling customOverScrollBy will call onCustomOverScrolled, which // sets the scrolling if applicable. if (scrollAmount != 0.0f) { // The scrolling motion could not be compensated with the // existing overScroll, we have to scroll the view overScrollBy(0, (int) scrollAmount, 0, mOwnScrollY, 0, range, 0, getHeight() / 2, true); customOverScrollBy((int) scrollAmount, mOwnScrollY, range, getHeight() / 2); } } break; Loading @@ -1436,7 +1437,7 @@ public class NotificationStackScrollLayout extends ViewGroup } else { if (mScroller.springBack(mScrollX, mOwnScrollY, 0, 0, 0, getScrollRange())) { postInvalidateOnAnimation(); animateScroll(); } } } Loading @@ -1449,7 +1450,7 @@ public class NotificationStackScrollLayout extends ViewGroup case MotionEvent.ACTION_CANCEL: if (mIsBeingDragged && getChildCount() > 0) { if (mScroller.springBack(mScrollX, mOwnScrollY, 0, 0, 0, getScrollRange())) { postInvalidateOnAnimation(); animateScroll(); } mActivePointerId = INVALID_POINTER; endDrag(); Loading Loading @@ -1589,16 +1590,12 @@ public class NotificationStackScrollLayout extends ViewGroup mFinishScrollingCallback = runnable; } @Override public void computeScroll() { private void animateScroll() { if (mScroller.computeScrollOffset()) { // This is called at drawing time by ViewGroup. int oldX = mScrollX; int oldY = mOwnScrollY; int x = mScroller.getCurrX(); int y = mScroller.getCurrY(); if (oldX != x || oldY != y) { if (oldY != y) { int range = getScrollRange(); if (y < 0 && oldY >= 0 || y > range && oldY <= range) { float currVelocity = mScroller.getCurrVelocity(); Loading @@ -1610,13 +1607,11 @@ public class NotificationStackScrollLayout extends ViewGroup if (mDontClampNextScroll) { range = Math.max(range, oldY); } overScrollBy(x - oldX, y - oldY, oldX, oldY, 0, range, 0, (int) (mMaxOverScroll), false); onScrollChanged(mScrollX, mOwnScrollY, oldX, oldY); customOverScrollBy(y - oldY, oldY, range, (int) (mMaxOverScroll)); } // Keep on drawing until the animation has finished. postInvalidateOnAnimation(); postOnAnimation(mAnimateScroll); } else { mDontClampNextScroll = false; if (mFinishScrollingCallback != null) { Loading @@ -1625,12 +1620,8 @@ public class NotificationStackScrollLayout extends ViewGroup } } @Override protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) { private boolean customOverScrollBy(int deltaY, int scrollY, int scrollRangeY, int maxOverScrollY) { int newScrollY = scrollY + deltaY; final int top = -maxOverScrollY; Loading @@ -1645,7 +1636,7 @@ public class NotificationStackScrollLayout extends ViewGroup clampedY = true; } onOverScrolled(0, newScrollY, false, clampedY); onCustomOverScrolled(newScrollY, clampedY); return clampedY; } Loading Loading @@ -1754,25 +1745,13 @@ public class NotificationStackScrollLayout extends ViewGroup } } private void customScrollTo(int y) { setOwnScrollY(y); updateChildren(); } @Override protected void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY) { private void onCustomOverScrolled(int scrollY, boolean clampedY) { // Treat animating scrolls differently; see #computeScroll() for why. if (!mScroller.isFinished()) { final int oldX = mScrollX; final int oldY = mOwnScrollY; mScrollX = scrollX; setOwnScrollY(scrollY); if (clampedY) { springBack(); } else { onScrollChanged(mScrollX, mOwnScrollY, oldX, oldY); invalidateParentIfNeeded(); updateChildren(); float overScrollTop = getCurrentOverScrollAmount(true); if (mOwnScrollY < 0) { notifyOverscrollTopListener(-mOwnScrollY, isRubberbanded(true)); Loading @@ -1781,8 +1760,7 @@ public class NotificationStackScrollLayout extends ViewGroup } } } else { customScrollTo(scrollY); scrollTo(scrollX, mScrollY); setOwnScrollY(scrollY); } } Loading Loading @@ -2291,10 +2269,10 @@ public class NotificationStackScrollLayout extends ViewGroup if (mExpandedInThisMotion) { minScrollY = Math.min(minScrollY, mMaxScrollAfterExpand); } mScroller.fling(mScrollX, mOwnScrollY, 1, velocityY, 0, 0, 0, minScrollY, 0, mExpandedInThisMotion && mOwnScrollY >= 0 ? 0 : Integer.MAX_VALUE / 2); mScroller.fling(mScrollX, mOwnScrollY, 1, velocityY, 0, 0, 0, minScrollY, 0, mExpandedInThisMotion && mOwnScrollY >= 0 ? 0 : Integer.MAX_VALUE / 2); postInvalidateOnAnimation(); animateScroll(); } } Loading Loading @@ -3149,7 +3127,7 @@ public class NotificationStackScrollLayout extends ViewGroup mActivePointerId = INVALID_POINTER; recycleVelocityTracker(); if (mScroller.springBack(mScrollX, mOwnScrollY, 0, 0, 0, getScrollRange())) { postInvalidateOnAnimation(); animateScroll(); } break; case MotionEvent.ACTION_POINTER_UP: Loading Loading @@ -3927,7 +3905,7 @@ public class NotificationStackScrollLayout extends ViewGroup Math.min(mOwnScrollY + direction * viewportHeight, getScrollRange())); if (targetScrollY != mOwnScrollY) { mScroller.startScroll(mScrollX, mOwnScrollY, 0, targetScrollY - mOwnScrollY); postInvalidateOnAnimation(); animateScroll(); return true; } break; Loading Loading @@ -4077,8 +4055,11 @@ public class NotificationStackScrollLayout extends ViewGroup public void setOwnScrollY(int ownScrollY) { if (ownScrollY != mOwnScrollY) { // We still want to call the normal scrolled changed for accessibility reasons onScrollChanged(mScrollX, ownScrollY, mScrollX, mOwnScrollY); mOwnScrollY = ownScrollY; updateForwardAndBackwardScrollability(); requestChildrenUpdate(); } } Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +28 −47 Original line number Diff line number Diff line Loading @@ -364,6 +364,7 @@ public class NotificationStackScrollLayout extends ViewGroup private boolean mHeadsUpAnimatingAway; private int mStatusBarState; private int mCachedBackgroundColor; private Runnable mAnimateScroll = this::animateScroll; public NotificationStackScrollLayout(Context context) { this(context, null); Loading Loading @@ -1169,7 +1170,7 @@ public class NotificationStackScrollLayout extends ViewGroup if (mOwnScrollY < targetScroll || outOfViewScroll < mOwnScrollY) { mScroller.startScroll(mScrollX, mOwnScrollY, 0, targetScroll - mOwnScrollY); mDontReportNextOverScroll = true; postInvalidateOnAnimation(); animateScroll(); return true; } return false; Loading Loading @@ -1209,7 +1210,7 @@ public class NotificationStackScrollLayout extends ViewGroup mScroller.startScroll(mScrollX, mOwnScrollY, 0, range - mOwnScrollY); mDontReportNextOverScroll = true; mDontClampNextScroll = true; postInvalidateOnAnimation(); animateScroll(); } }; Loading Loading @@ -1326,7 +1327,7 @@ public class NotificationStackScrollLayout extends ViewGroup newScrollY = range; } if (newScrollY != oldScrollY) { customScrollTo(newScrollY); setOwnScrollY(newScrollY); return true; } } Loading Loading @@ -1406,13 +1407,13 @@ public class NotificationStackScrollLayout extends ViewGroup scrollAmount = overScrollUp(deltaY, range); } // Calling overScrollBy will call onOverScrolled, which // calls onScrollChanged if applicable. // Calling customOverScrollBy will call onCustomOverScrolled, which // sets the scrolling if applicable. if (scrollAmount != 0.0f) { // The scrolling motion could not be compensated with the // existing overScroll, we have to scroll the view overScrollBy(0, (int) scrollAmount, 0, mOwnScrollY, 0, range, 0, getHeight() / 2, true); customOverScrollBy((int) scrollAmount, mOwnScrollY, range, getHeight() / 2); } } break; Loading @@ -1436,7 +1437,7 @@ public class NotificationStackScrollLayout extends ViewGroup } else { if (mScroller.springBack(mScrollX, mOwnScrollY, 0, 0, 0, getScrollRange())) { postInvalidateOnAnimation(); animateScroll(); } } } Loading @@ -1449,7 +1450,7 @@ public class NotificationStackScrollLayout extends ViewGroup case MotionEvent.ACTION_CANCEL: if (mIsBeingDragged && getChildCount() > 0) { if (mScroller.springBack(mScrollX, mOwnScrollY, 0, 0, 0, getScrollRange())) { postInvalidateOnAnimation(); animateScroll(); } mActivePointerId = INVALID_POINTER; endDrag(); Loading Loading @@ -1589,16 +1590,12 @@ public class NotificationStackScrollLayout extends ViewGroup mFinishScrollingCallback = runnable; } @Override public void computeScroll() { private void animateScroll() { if (mScroller.computeScrollOffset()) { // This is called at drawing time by ViewGroup. int oldX = mScrollX; int oldY = mOwnScrollY; int x = mScroller.getCurrX(); int y = mScroller.getCurrY(); if (oldX != x || oldY != y) { if (oldY != y) { int range = getScrollRange(); if (y < 0 && oldY >= 0 || y > range && oldY <= range) { float currVelocity = mScroller.getCurrVelocity(); Loading @@ -1610,13 +1607,11 @@ public class NotificationStackScrollLayout extends ViewGroup if (mDontClampNextScroll) { range = Math.max(range, oldY); } overScrollBy(x - oldX, y - oldY, oldX, oldY, 0, range, 0, (int) (mMaxOverScroll), false); onScrollChanged(mScrollX, mOwnScrollY, oldX, oldY); customOverScrollBy(y - oldY, oldY, range, (int) (mMaxOverScroll)); } // Keep on drawing until the animation has finished. postInvalidateOnAnimation(); postOnAnimation(mAnimateScroll); } else { mDontClampNextScroll = false; if (mFinishScrollingCallback != null) { Loading @@ -1625,12 +1620,8 @@ public class NotificationStackScrollLayout extends ViewGroup } } @Override protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) { private boolean customOverScrollBy(int deltaY, int scrollY, int scrollRangeY, int maxOverScrollY) { int newScrollY = scrollY + deltaY; final int top = -maxOverScrollY; Loading @@ -1645,7 +1636,7 @@ public class NotificationStackScrollLayout extends ViewGroup clampedY = true; } onOverScrolled(0, newScrollY, false, clampedY); onCustomOverScrolled(newScrollY, clampedY); return clampedY; } Loading Loading @@ -1754,25 +1745,13 @@ public class NotificationStackScrollLayout extends ViewGroup } } private void customScrollTo(int y) { setOwnScrollY(y); updateChildren(); } @Override protected void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY) { private void onCustomOverScrolled(int scrollY, boolean clampedY) { // Treat animating scrolls differently; see #computeScroll() for why. if (!mScroller.isFinished()) { final int oldX = mScrollX; final int oldY = mOwnScrollY; mScrollX = scrollX; setOwnScrollY(scrollY); if (clampedY) { springBack(); } else { onScrollChanged(mScrollX, mOwnScrollY, oldX, oldY); invalidateParentIfNeeded(); updateChildren(); float overScrollTop = getCurrentOverScrollAmount(true); if (mOwnScrollY < 0) { notifyOverscrollTopListener(-mOwnScrollY, isRubberbanded(true)); Loading @@ -1781,8 +1760,7 @@ public class NotificationStackScrollLayout extends ViewGroup } } } else { customScrollTo(scrollY); scrollTo(scrollX, mScrollY); setOwnScrollY(scrollY); } } Loading Loading @@ -2291,10 +2269,10 @@ public class NotificationStackScrollLayout extends ViewGroup if (mExpandedInThisMotion) { minScrollY = Math.min(minScrollY, mMaxScrollAfterExpand); } mScroller.fling(mScrollX, mOwnScrollY, 1, velocityY, 0, 0, 0, minScrollY, 0, mExpandedInThisMotion && mOwnScrollY >= 0 ? 0 : Integer.MAX_VALUE / 2); mScroller.fling(mScrollX, mOwnScrollY, 1, velocityY, 0, 0, 0, minScrollY, 0, mExpandedInThisMotion && mOwnScrollY >= 0 ? 0 : Integer.MAX_VALUE / 2); postInvalidateOnAnimation(); animateScroll(); } } Loading Loading @@ -3149,7 +3127,7 @@ public class NotificationStackScrollLayout extends ViewGroup mActivePointerId = INVALID_POINTER; recycleVelocityTracker(); if (mScroller.springBack(mScrollX, mOwnScrollY, 0, 0, 0, getScrollRange())) { postInvalidateOnAnimation(); animateScroll(); } break; case MotionEvent.ACTION_POINTER_UP: Loading Loading @@ -3927,7 +3905,7 @@ public class NotificationStackScrollLayout extends ViewGroup Math.min(mOwnScrollY + direction * viewportHeight, getScrollRange())); if (targetScrollY != mOwnScrollY) { mScroller.startScroll(mScrollX, mOwnScrollY, 0, targetScrollY - mOwnScrollY); postInvalidateOnAnimation(); animateScroll(); return true; } break; Loading Loading @@ -4077,8 +4055,11 @@ public class NotificationStackScrollLayout extends ViewGroup public void setOwnScrollY(int ownScrollY) { if (ownScrollY != mOwnScrollY) { // We still want to call the normal scrolled changed for accessibility reasons onScrollChanged(mScrollX, ownScrollY, mScrollX, mOwnScrollY); mOwnScrollY = ownScrollY; updateForwardAndBackwardScrollability(); requestChildrenUpdate(); } } Loading