diff options
| author | Svetoslav Ganov <svetoslavganov@google.com> | 2012-03-09 10:54:49 -0800 |
|---|---|---|
| committer | Svetoslav Ganov <svetoslavganov@google.com> | 2012-03-09 11:47:17 -0800 |
| commit | 51ab90cab1609cf0ddd2dfe5a660f020d823d4d5 (patch) | |
| tree | 7e12773923ee63d0c081d08e6eadd5f45a7319c4 /core/java/android/view/View.java | |
| parent | 4b97257979034a8031040b84d8f016d8f3175313 (diff) | |
| download | frameworks_base-51ab90cab1609cf0ddd2dfe5a660f020d823d4d5.zip frameworks_base-51ab90cab1609cf0ddd2dfe5a660f020d823d4d5.tar.gz frameworks_base-51ab90cab1609cf0ddd2dfe5a660f020d823d4d5.tar.bz2 | |
Adding an announcement type accessibility event and a method on View to announce.
1. The need for sending an accessibility event to announce a context change
which does not cleanly fit into the existing UI transition UI events has
come quite a few time in application development. To avoid retrofitting
accessibility event types that do not semantically match the intent to
just announce a short message this patch is adding specialized event type.
Also a helper method on View is added to sheild developers from knowing
how to construct and send such an event.
bug:5977979
Change-Id: Iaf5f620426f8616be67fbf243a02ad5b606c949b
Diffstat (limited to 'core/java/android/view/View.java')
| -rw-r--r-- | core/java/android/view/View.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index ecfca74..7cadee8 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -3934,6 +3934,24 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal } /** + * Convenience method for sending a {@link AccessibilityEvent#TYPE_ANNOUNCEMENT} + * {@link AccessibilityEvent} to make an announcement which is related to some + * sort of a context change for which none of the events representing UI transitions + * is a good fit. For example, announcing a new page in a book. If accessibility + * is not enabled this method does nothing. + * + * @param text The announcement text. + */ + public void announceForAccessibility(CharSequence text) { + if (AccessibilityManager.getInstance(mContext).isEnabled()) { + AccessibilityEvent event = AccessibilityEvent.obtain( + AccessibilityEvent.TYPE_ANNOUNCEMENT); + event.getText().add(text); + sendAccessibilityEventUnchecked(event); + } + } + + /** * @see #sendAccessibilityEvent(int) * * Note: Called from the default {@link AccessibilityDelegate}. |
