diff options
| author | 2012-05-07 16:57:53 -0700 | |
|---|---|---|
| committer | 2012-05-07 18:42:31 -0700 | |
| commit | 8eeefefc8451c97745add2b4d508116aaffbcb22 (patch) | |
| tree | 64a278b2b40672495f778b565969ef6f7e936c64 | |
| parent | 911b0c0b15ae4f14a6f755278679ef9c6a6e6c05 (diff) | |
Add performAccessibilityAction to AccessibilityDelegate.
Change-Id: I43dff2ced959af5d8a9ce9ed18858a6e74cb35c6
| -rw-r--r-- | api/current.txt | 1 | ||||
| -rw-r--r-- | core/java/android/view/View.java | 39 |
2 files changed, 40 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt index 13c972fc9f93..695ba766bdc9 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24381,6 +24381,7 @@ package android.view { method public void onInitializeAccessibilityNodeInfo(android.view.View, android.view.accessibility.AccessibilityNodeInfo); method public void onPopulateAccessibilityEvent(android.view.View, android.view.accessibility.AccessibilityEvent); method public boolean onRequestSendAccessibilityEvent(android.view.ViewGroup, android.view.View, android.view.accessibility.AccessibilityEvent); + method public boolean performAccessibilityAction(android.view.View, int, android.os.Bundle); method public void sendAccessibilityEvent(android.view.View, int); method public void sendAccessibilityEventUnchecked(android.view.View, android.view.accessibility.AccessibilityEvent); } diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 2972774ff86f..0e8723f73e0a 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -6463,12 +6463,31 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal /** * Performs the specified accessibility action on the view. For * possible accessibility actions look at {@link AccessibilityNodeInfo}. + * <p> + * If an {@link AccessibilityDelegate} has been specified via calling + * {@link #setAccessibilityDelegate(AccessibilityDelegate)} its + * {@link AccessibilityDelegate#performAccessibilityAction(View, int, Bundle)} + * is responsible for handling this call. + * </p> * * @param action The action to perform. * @param arguments Optional action arguments. * @return Whether the action was performed. */ public boolean performAccessibilityAction(int action, Bundle arguments) { + if (mAccessibilityDelegate != null) { + return mAccessibilityDelegate.performAccessibilityAction(this, action, arguments); + } else { + return performAccessibilityActionInternal(action, arguments); + } + } + + /** + * @see #performAccessibilityAction(int, Bundle) + * + * Note: Called from the default {@link AccessibilityDelegate}. + */ + boolean performAccessibilityActionInternal(int action, Bundle arguments) { switch (action) { case AccessibilityNodeInfo.ACTION_CLICK: { if (isClickable()) { @@ -17412,6 +17431,26 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal } /** + * Performs the specified accessibility action on the view. For + * possible accessibility actions look at {@link AccessibilityNodeInfo}. + * <p> + * The default implementation behaves as + * {@link View#performAccessibilityAction(int, Bundle) + * View#performAccessibilityAction(int, Bundle)} for the case of + * no accessibility delegate been set. + * </p> + * + * @param action The action to perform. + * @return Whether the action was performed. + * + * @see View#performAccessibilityAction(int, Bundle) + * View#performAccessibilityAction(int, Bundle) + */ + public boolean performAccessibilityAction(View host, int action, Bundle args) { + return host.performAccessibilityActionInternal(action, args); + } + + /** * Sends an accessibility event. This method behaves exactly as * {@link #sendAccessibilityEvent(View, int)} but takes as an argument an * empty {@link AccessibilityEvent} and does not perform a check whether |