From d9ee72fddb8be40e414a831fb80458dc48699613 Mon Sep 17 00:00:00 2001 From: Svetoslav Ganov Date: Wed, 5 Oct 2011 22:26:05 -0700 Subject: Fixing errors in position information of scrollable views reported for accessibility. 1. ScrollView/HorizontalScroll view were reporting only the scroll X and Y but failed to convey the max scroll along X and Y so the position can be determined. 2. WebView was not reporting correctly its scroll position for accessibility. 3. Some descendants of AdapterView were reporting incorrect position information. 4. Updated the accessibility docs with some details about the scroll information. 5. Cleaned up duplicated code. bug:5412132 bug:5412265 Change-Id: I165e73ecde027dad811425b9f395a3f758c923ba --- core/java/android/widget/ScrollView.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'core/java/android/widget/ScrollView.java') diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java index 3ac4e80379ff..767eaee62f0d 100644 --- a/core/java/android/widget/ScrollView.java +++ b/core/java/android/widget/ScrollView.java @@ -721,13 +721,18 @@ public class ScrollView extends FrameLayout { @Override public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); - info.setScrollable(true); + info.setScrollable(getScrollRange() > 0); } @Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); - event.setScrollable(true); + final boolean scrollable = getScrollRange() > 0; + event.setScrollable(scrollable); + event.setScrollX(mScrollX); + event.setScrollY(mScrollY); + event.setMaxScrollX(mScrollX); + event.setMaxScrollY(getScrollRange()); } private int getScrollRange() { -- cgit v1.2.3