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/StackView.java | |
| parent | 78cb7cf7d1d82834c4405650a17e387370004570 (diff) | |
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/StackView.java')
| -rw-r--r-- | core/java/android/widget/StackView.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/core/java/android/widget/StackView.java b/core/java/android/widget/StackView.java index 22df3bc23883..dd0915ba47e3 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 { |
