am 5bf925d9: am 5a99c276: am a9ac89a3: Merge "Correctly advertise accessibility scrolling actions" into lmp-dev

* commit '5bf925d93afc314b727ca0a06d022e2fed05032b':
  Correctly advertise accessibility scrolling actions
This commit is contained in:
Alan Viverette
2014-09-26 04:55:33 +00:00
committed by Android Git Automerger

View File

@@ -1493,11 +1493,11 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
super.onInitializeAccessibilityNodeInfo(info);
info.setClassName(AbsListView.class.getName());
if (isEnabled()) {
if (getFirstVisiblePosition() > 0) {
if (canScrollUp()) {
info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
info.setScrollable(true);
}
if (getLastVisiblePosition() < getCount() - 1) {
if (canScrollDown()) {
info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
info.setScrollable(true);
}
@@ -2203,38 +2203,46 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
void updateScrollIndicators() {
if (mScrollUp != null) {
boolean canScrollUp;
// 0th element is not visible
canScrollUp = mFirstPosition > 0;
// ... Or top of 0th element is not visible
if (!canScrollUp) {
if (getChildCount() > 0) {
View child = getChildAt(0);
canScrollUp = child.getTop() < mListPadding.top;
}
}
mScrollUp.setVisibility(canScrollUp ? View.VISIBLE : View.INVISIBLE);
mScrollUp.setVisibility(canScrollUp() ? View.VISIBLE : View.INVISIBLE);
}
if (mScrollDown != null) {
boolean canScrollDown;
int count = getChildCount();
// Last item is not visible
canScrollDown = (mFirstPosition + count) < mItemCount;
// ... Or bottom of the last element is not visible
if (!canScrollDown && count > 0) {
View child = getChildAt(count - 1);
canScrollDown = child.getBottom() > mBottom - mListPadding.bottom;
}
mScrollDown.setVisibility(canScrollDown ? View.VISIBLE : View.INVISIBLE);
mScrollDown.setVisibility(canScrollDown() ? View.VISIBLE : View.INVISIBLE);
}
}
private boolean canScrollUp() {
boolean canScrollUp;
// 0th element is not visible
canScrollUp = mFirstPosition > 0;
// ... Or top of 0th element is not visible
if (!canScrollUp) {
if (getChildCount() > 0) {
View child = getChildAt(0);
canScrollUp = child.getTop() < mListPadding.top;
}
}
return canScrollUp;
}
private boolean canScrollDown() {
boolean canScrollDown;
int count = getChildCount();
// Last item is not visible
canScrollDown = (mFirstPosition + count) < mItemCount;
// ... Or bottom of the last element is not visible
if (!canScrollDown && count > 0) {
View child = getChildAt(count - 1);
canScrollDown = child.getBottom() > mBottom - mListPadding.bottom;
}
return canScrollDown;
}
@Override
@ViewDebug.ExportedProperty
public View getSelectedView() {