diff options
author | Svetoslav Ganov <svetoslavganov@google.com> | 2012-05-15 10:10:00 -0700 |
---|---|---|
committer | Svetoslav Ganov <svetoslavganov@google.com> | 2012-05-15 11:21:32 -0700 |
commit | 48d1586f4065fc9ab97a679da1e4f7c327c943f2 (patch) | |
tree | 561346718f92462f2bb5d8a20f6ca2c8333c10bb /core/java/android/widget | |
parent | 78cb7cf7d1d82834c4405650a17e387370004570 (diff) | |
download | frameworks_base-48d1586f4065fc9ab97a679da1e4f7c327c943f2.zip frameworks_base-48d1586f4065fc9ab97a679da1e4f7c327c943f2.tar.gz frameworks_base-48d1586f4065fc9ab97a679da1e4f7c327c943f2.tar.bz2 |
Add accessibility scroll support to some widgets.
1. Added support for accessibility scroll action to
some widgets that are scrollable.
2. Making the super call when handling an accessibility
action in the views to call super first to allow
an accessibility delegate to intercept the call.
bug:5932640
Change-Id: I5eb37d64bf9fba1d5c596981132e0df717e2a18a
Diffstat (limited to 'core/java/android/widget')
-rw-r--r-- | core/java/android/widget/AbsListView.java | 5 | ||||
-rw-r--r-- | core/java/android/widget/Gallery.java | 30 | ||||
-rw-r--r-- | core/java/android/widget/HorizontalScrollView.java | 5 | ||||
-rw-r--r-- | core/java/android/widget/NumberPicker.java | 18 | ||||
-rw-r--r-- | core/java/android/widget/ScrollView.java | 5 | ||||
-rw-r--r-- | core/java/android/widget/StackView.java | 30 |
6 files changed, 90 insertions, 3 deletions
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index ab9d370..04c8cdc 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -1480,6 +1480,9 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te @Override public boolean performAccessibilityAction(int action, Bundle arguments) { + if (super.performAccessibilityAction(action, arguments)) { + return true; + } switch (action) { case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD: { if (getLastVisiblePosition() < getCount() - 1) { @@ -1496,7 +1499,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te } } return false; } - return super.performAccessibilityAction(action, arguments); + return false; } /** diff --git a/core/java/android/widget/Gallery.java b/core/java/android/widget/Gallery.java index 03fdc39..b2c8164 100644 --- a/core/java/android/widget/Gallery.java +++ b/core/java/android/widget/Gallery.java @@ -20,6 +20,7 @@ import android.annotation.Widget; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Rect; +import android.os.Bundle; import android.util.AttributeSet; import android.util.Log; import android.view.ContextMenu.ContextMenuInfo; @@ -1367,6 +1368,35 @@ public class Gallery extends AbsSpinner implements GestureDetector.OnGestureList public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); info.setClassName(Gallery.class.getName()); + info.setScrollable(mItemCount > 1); + if (mItemCount > 0 && mSelectedPosition < mItemCount - 1) { + info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); + } + if (mItemCount > 0 && mSelectedPosition > 0) { + info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD); + } + } + + @Override + public boolean performAccessibilityAction(int action, Bundle arguments) { + if (super.performAccessibilityAction(action, arguments)) { + return true; + } + switch (action) { + case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD: { + if (mItemCount > 0 && mSelectedPosition < mItemCount - 1) { + final int currentChildIndex = mSelectedPosition - mFirstPosition; + return scrollToChild(currentChildIndex + 1); + } + } return false; + case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD: { + if (mItemCount > 0 && mSelectedPosition > 0) { + final int currentChildIndex = mSelectedPosition - mFirstPosition; + return scrollToChild(currentChildIndex - 1); + } + } return false; + } + return false; } /** diff --git a/core/java/android/widget/HorizontalScrollView.java b/core/java/android/widget/HorizontalScrollView.java index ffabd1d..f889cb7 100644 --- a/core/java/android/widget/HorizontalScrollView.java +++ b/core/java/android/widget/HorizontalScrollView.java @@ -739,6 +739,9 @@ public class HorizontalScrollView extends FrameLayout { @Override public boolean performAccessibilityAction(int action, Bundle arguments) { + if (super.performAccessibilityAction(action, arguments)) { + return true; + } switch (action) { case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD: { final int viewportWidth = getWidth() - mPaddingLeft - mPaddingRight; @@ -757,7 +760,7 @@ public class HorizontalScrollView extends FrameLayout { } } return false; } - return super.performAccessibilityAction(action, arguments); + return false; } @Override diff --git a/core/java/android/widget/NumberPicker.java b/core/java/android/widget/NumberPicker.java index 78d570e..b825e1b 100644 --- a/core/java/android/widget/NumberPicker.java +++ b/core/java/android/widget/NumberPicker.java @@ -2172,6 +2172,18 @@ public class NumberPicker extends LinearLayout { } return false; } + case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD: { + if (getWrapSelectorWheel() || getValue() < getMaxValue()) { + changeValueByOne(true); + return true; + } + } return false; + case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD: { + if (getWrapSelectorWheel() || getValue() > getMinValue()) { + changeValueByOne(false); + return true; + } + } return false; } } break; case VIRTUAL_VIEW_ID_INPUT: { @@ -2497,6 +2509,12 @@ public class NumberPicker extends LinearLayout { if (mAccessibilityFocusedView == View.NO_ID) { info.addAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS); } + if (getWrapSelectorWheel() || getValue() < getMaxValue()) { + info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); + } + if (getWrapSelectorWheel() || getValue() > getMinValue()) { + info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD); + } return info; } diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java index b398ce4..a499743 100644 --- a/core/java/android/widget/ScrollView.java +++ b/core/java/android/widget/ScrollView.java @@ -742,6 +742,9 @@ public class ScrollView extends FrameLayout { @Override public boolean performAccessibilityAction(int action, Bundle arguments) { + if (super.performAccessibilityAction(action, arguments)) { + return true; + } switch (action) { case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD: { final int viewportHeight = getHeight() - mPaddingBottom - mPaddingTop; @@ -760,7 +763,7 @@ public class ScrollView extends FrameLayout { } } return false; } - return super.performAccessibilityAction(action, arguments); + return false; } @Override diff --git a/core/java/android/widget/StackView.java b/core/java/android/widget/StackView.java index 22df3bc..dd0915b 100644 --- a/core/java/android/widget/StackView.java +++ b/core/java/android/widget/StackView.java @@ -32,6 +32,7 @@ import android.graphics.Rect; import android.graphics.RectF; import android.graphics.Region; import android.graphics.TableMaskFilter; +import android.os.Bundle; import android.util.AttributeSet; import android.util.Log; import android.view.InputDevice; @@ -1228,6 +1229,35 @@ public class StackView extends AdapterViewAnimator { public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); info.setClassName(StackView.class.getName()); + info.setScrollable(getChildCount() > 1); + if (getDisplayedChild() < getChildCount() - 1) { + info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); + } + if (getDisplayedChild() > 0) { + info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD); + } + } + + @Override + public boolean performAccessibilityAction(int action, Bundle arguments) { + if (super.performAccessibilityAction(action, arguments)) { + return true; + } + switch (action) { + case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD: { + if (getDisplayedChild() < getChildCount() - 1) { + showNext(); + return true; + } + } return false; + case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD: { + if (getDisplayedChild() > 0) { + showPrevious(); + return true; + } + } return false; + } + return false; } class LayoutParams extends ViewGroup.LayoutParams { |