Fixed a bug with the scrollability of notifications
am: ef40606eb9
Change-Id: I2a22947f11c25fa7ce203bb7bee65b19deea3fb8
This commit is contained in:
@@ -351,6 +351,8 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
private boolean mQsExpanded;
|
private boolean mQsExpanded;
|
||||||
|
private boolean mForwardScrollable;
|
||||||
|
private boolean mBackwardScrollable;
|
||||||
|
|
||||||
public NotificationStackScrollLayout(Context context) {
|
public NotificationStackScrollLayout(Context context) {
|
||||||
this(context, null);
|
this(context, null);
|
||||||
@@ -596,7 +598,7 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
if (startingPosition < mOwnScrollY) {
|
if (startingPosition < mOwnScrollY) {
|
||||||
// This child starts off screen, so let's keep it offscreen to keep the others visible
|
// This child starts off screen, so let's keep it offscreen to keep the others visible
|
||||||
|
|
||||||
mOwnScrollY += childHeight;
|
setOwnScrollY(mOwnScrollY + childHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -619,7 +621,7 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
// Only apply the scroll if we're scrolling the view upwards, or the view is so far up
|
// Only apply the scroll if we're scrolling the view upwards, or the view is so far up
|
||||||
// that it is not visible anymore.
|
// that it is not visible anymore.
|
||||||
if (mOwnScrollY < targetScroll || outOfViewScroll < mOwnScrollY) {
|
if (mOwnScrollY < targetScroll || outOfViewScroll < mOwnScrollY) {
|
||||||
mOwnScrollY = targetScroll;
|
setOwnScrollY(targetScroll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -639,7 +641,7 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
private void clampScrollPosition() {
|
private void clampScrollPosition() {
|
||||||
int scrollRange = getScrollRange();
|
int scrollRange = getScrollRange();
|
||||||
if (scrollRange < mOwnScrollY) {
|
if (scrollRange < mOwnScrollY) {
|
||||||
mOwnScrollY = scrollRange;
|
setOwnScrollY(scrollRange);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1406,7 +1408,7 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
false /* onTop */,
|
false /* onTop */,
|
||||||
false /* animate */);
|
false /* animate */);
|
||||||
}
|
}
|
||||||
mOwnScrollY = range;
|
setOwnScrollY(range);
|
||||||
scrollAmount = 0.0f;
|
scrollAmount = 0.0f;
|
||||||
}
|
}
|
||||||
return scrollAmount;
|
return scrollAmount;
|
||||||
@@ -1437,7 +1439,7 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
setOverScrolledPixels(currentTopPixels - newScrollY,
|
setOverScrolledPixels(currentTopPixels - newScrollY,
|
||||||
true /* onTop */,
|
true /* onTop */,
|
||||||
false /* animate */);
|
false /* animate */);
|
||||||
mOwnScrollY = 0;
|
setOwnScrollY(0);
|
||||||
scrollAmount = 0.0f;
|
scrollAmount = 0.0f;
|
||||||
}
|
}
|
||||||
return scrollAmount;
|
return scrollAmount;
|
||||||
@@ -1652,7 +1654,7 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void customScrollTo(int y) {
|
private void customScrollTo(int y) {
|
||||||
mOwnScrollY = y;
|
setOwnScrollY(y);
|
||||||
updateChildren();
|
updateChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1663,7 +1665,7 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
final int oldX = mScrollX;
|
final int oldX = mScrollX;
|
||||||
final int oldY = mOwnScrollY;
|
final int oldY = mOwnScrollY;
|
||||||
mScrollX = scrollX;
|
mScrollX = scrollX;
|
||||||
mOwnScrollY = scrollY;
|
setOwnScrollY(scrollY);
|
||||||
if (clampedY) {
|
if (clampedY) {
|
||||||
springBack();
|
springBack();
|
||||||
} else {
|
} else {
|
||||||
@@ -1693,12 +1695,12 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
if (overScrolledTop) {
|
if (overScrolledTop) {
|
||||||
onTop = true;
|
onTop = true;
|
||||||
newAmount = -mOwnScrollY;
|
newAmount = -mOwnScrollY;
|
||||||
mOwnScrollY = 0;
|
setOwnScrollY(0);
|
||||||
mDontReportNextOverScroll = true;
|
mDontReportNextOverScroll = true;
|
||||||
} else {
|
} else {
|
||||||
onTop = false;
|
onTop = false;
|
||||||
newAmount = mOwnScrollY - scrollRange;
|
newAmount = mOwnScrollY - scrollRange;
|
||||||
mOwnScrollY = scrollRange;
|
setOwnScrollY(scrollRange);
|
||||||
}
|
}
|
||||||
setOverScrollAmount(newAmount, onTop, false);
|
setOverScrollAmount(newAmount, onTop, false);
|
||||||
setOverScrollAmount(0.0f, onTop, true);
|
setOverScrollAmount(0.0f, onTop, true);
|
||||||
@@ -1826,6 +1828,19 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
if (scrollable != mScrollable) {
|
if (scrollable != mScrollable) {
|
||||||
mScrollable = scrollable;
|
mScrollable = scrollable;
|
||||||
setFocusable(scrollable);
|
setFocusable(scrollable);
|
||||||
|
updateForwardAndBackwardScrollability();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateForwardAndBackwardScrollability() {
|
||||||
|
boolean forwardScrollable = mScrollable && mOwnScrollY < getScrollRange();
|
||||||
|
boolean backwardsScrollable = mScrollable && mOwnScrollY > 0;
|
||||||
|
boolean changed = forwardScrollable != mForwardScrollable
|
||||||
|
|| backwardsScrollable != mBackwardScrollable;
|
||||||
|
mForwardScrollable = forwardScrollable;
|
||||||
|
mBackwardScrollable = backwardsScrollable;
|
||||||
|
if (changed) {
|
||||||
|
sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2084,13 +2099,13 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
float topAmount = getCurrentOverScrollAmount(true);
|
float topAmount = getCurrentOverScrollAmount(true);
|
||||||
float bottomAmount = getCurrentOverScrollAmount(false);
|
float bottomAmount = getCurrentOverScrollAmount(false);
|
||||||
if (velocityY < 0 && topAmount > 0) {
|
if (velocityY < 0 && topAmount > 0) {
|
||||||
mOwnScrollY -= (int) topAmount;
|
setOwnScrollY(mOwnScrollY - (int) topAmount);
|
||||||
mDontReportNextOverScroll = true;
|
mDontReportNextOverScroll = true;
|
||||||
setOverScrollAmount(0, true, false);
|
setOverScrollAmount(0, true, false);
|
||||||
mMaxOverScroll = Math.abs(velocityY) / 1000f * getRubberBandFactor(true /* onTop */)
|
mMaxOverScroll = Math.abs(velocityY) / 1000f * getRubberBandFactor(true /* onTop */)
|
||||||
* mOverflingDistance + topAmount;
|
* mOverflingDistance + topAmount;
|
||||||
} else if (velocityY > 0 && bottomAmount > 0) {
|
} else if (velocityY > 0 && bottomAmount > 0) {
|
||||||
mOwnScrollY += bottomAmount;
|
setOwnScrollY((int) (mOwnScrollY + bottomAmount));
|
||||||
setOverScrollAmount(0, false, false);
|
setOverScrollAmount(0, false, false);
|
||||||
mMaxOverScroll = Math.abs(velocityY) / 1000f
|
mMaxOverScroll = Math.abs(velocityY) / 1000f
|
||||||
* getRubberBandFactor(false /* onTop */) * mOverflingDistance
|
* getRubberBandFactor(false /* onTop */) * mOverflingDistance
|
||||||
@@ -2441,11 +2456,11 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
if (endPosition <= mOwnScrollY) {
|
if (endPosition <= mOwnScrollY) {
|
||||||
// This child is fully scrolled of the top, so we have to deduct its height from the
|
// This child is fully scrolled of the top, so we have to deduct its height from the
|
||||||
// scrollPosition
|
// scrollPosition
|
||||||
mOwnScrollY -= childHeight;
|
setOwnScrollY(mOwnScrollY - childHeight);
|
||||||
} else if (startingPosition < mOwnScrollY) {
|
} else if (startingPosition < mOwnScrollY) {
|
||||||
// This child is currently being scrolled into, set the scroll position to the start of
|
// This child is currently being scrolled into, set the scroll position to the start of
|
||||||
// this child
|
// this child
|
||||||
mOwnScrollY = startingPosition;
|
setOwnScrollY(startingPosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3026,7 +3041,7 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
public void onExpansionStopped() {
|
public void onExpansionStopped() {
|
||||||
mIsExpansionChanging = false;
|
mIsExpansionChanging = false;
|
||||||
if (!mIsExpanded) {
|
if (!mIsExpanded) {
|
||||||
mOwnScrollY = 0;
|
setOwnScrollY(0);
|
||||||
mPhoneStatusBar.resetUserExpandedStates();
|
mPhoneStatusBar.resetUserExpandedStates();
|
||||||
|
|
||||||
// lets make sure nothing is in the overlay / transient anymore
|
// lets make sure nothing is in the overlay / transient anymore
|
||||||
@@ -3059,7 +3074,7 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
|
|
||||||
public void resetScrollPosition() {
|
public void resetScrollPosition() {
|
||||||
mScroller.abortAnimation();
|
mScroller.abortAnimation();
|
||||||
mOwnScrollY = 0;
|
setOwnScrollY(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setIsExpanded(boolean isExpanded) {
|
private void setIsExpanded(boolean isExpanded) {
|
||||||
@@ -3128,7 +3143,7 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
}
|
}
|
||||||
int stackEnd = getStackEndPosition();
|
int stackEnd = getStackEndPosition();
|
||||||
if (endPosition > stackEnd) {
|
if (endPosition > stackEnd) {
|
||||||
mOwnScrollY += endPosition - stackEnd;
|
setOwnScrollY((int) (mOwnScrollY + endPosition - stackEnd));
|
||||||
mDisallowScrollingInThisMotion = true;
|
mDisallowScrollingInThisMotion = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3690,15 +3705,14 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
@Override
|
@Override
|
||||||
public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) {
|
public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) {
|
||||||
super.onInitializeAccessibilityNodeInfoInternal(info);
|
super.onInitializeAccessibilityNodeInfoInternal(info);
|
||||||
final int scrollRange = getScrollRange();
|
if (mScrollable) {
|
||||||
if (scrollRange > 0) {
|
|
||||||
info.setScrollable(true);
|
info.setScrollable(true);
|
||||||
if (mScrollY > 0) {
|
if (mBackwardScrollable) {
|
||||||
info.addAction(
|
info.addAction(
|
||||||
AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_BACKWARD);
|
AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_BACKWARD);
|
||||||
info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_UP);
|
info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_UP);
|
||||||
}
|
}
|
||||||
if (mScrollY < scrollRange) {
|
if (mForwardScrollable) {
|
||||||
info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD);
|
info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD);
|
||||||
info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_DOWN);
|
info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_DOWN);
|
||||||
}
|
}
|
||||||
@@ -3874,6 +3888,13 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
updateAlgorithmLayoutMinHeight();
|
updateAlgorithmLayoutMinHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOwnScrollY(int ownScrollY) {
|
||||||
|
if (ownScrollY != mOwnScrollY) {
|
||||||
|
mOwnScrollY = ownScrollY;
|
||||||
|
updateForwardAndBackwardScrollability();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A listener that is notified when some child locations might have changed.
|
* A listener that is notified when some child locations might have changed.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user