From 14b4b09e5f287d01e5f32085d9516c862826a6e1 Mon Sep 17 00:00:00 2001 From: Sally Date: Fri, 19 May 2023 00:15:51 +0000 Subject: [PATCH] Update setAccessibilityLiveRegion documentation Use a different example than incorrect passwords,and for the password example suggest setError and CONTENT_CHANGE_TYPE_ERROR instead. Bug: 283327862 Test: n/a Change-Id: Iad4f6445e7f80329a54c65ca0ee4f0a24349b48a --- core/java/android/view/View.java | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 71e9052627b93..141b1c3a3ff49 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -14619,19 +14619,31 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * to the view's content description or text, or to the content descriptions * or text of the view's children (where applicable). *

- * For example, in a login screen with a TextView that displays an "incorrect - * password" notification, that view should be marked as a live region with - * mode {@link #ACCESSIBILITY_LIVE_REGION_POLITE}. + * To indicate that the user should be notified of changes, use + * {@link #ACCESSIBILITY_LIVE_REGION_POLITE}. Announcements from this region are queued and + * do not disrupt ongoing speech. + *

+ * For example, selecting an option in a dropdown menu may update a panel below with the updated + * content. This panel may be marked as a live region with + * {@link #ACCESSIBILITY_LIVE_REGION_POLITE} to notify users of the change. + *

+ * For notifying users about errors, such as in a login screen with text that displays an + * "incorrect password" notification, that view should send an AccessibilityEvent of type + * {@link AccessibilityEvent#CONTENT_CHANGE_TYPE_ERROR} and set + * {@link AccessibilityNodeInfo#setError(CharSequence)} instead. Custom widgets should expose + * error-setting methods that support accessibility automatically. For example, instead of + * explicitly sending this event when using a TextView, use + * {@link android.widget.TextView#setError(CharSequence)}. *

* To disable change notifications for this view, use * {@link #ACCESSIBILITY_LIVE_REGION_NONE}. This is the default live region * mode for most views. *

- * To indicate that the user should be notified of changes, use - * {@link #ACCESSIBILITY_LIVE_REGION_POLITE}. - *

* If the view's changes should interrupt ongoing speech and notify the user - * immediately, use {@link #ACCESSIBILITY_LIVE_REGION_ASSERTIVE}. + * immediately, use {@link #ACCESSIBILITY_LIVE_REGION_ASSERTIVE}. This may result in disruptive + * announcements from an accessibility service, so it should generally be used only to convey + * information that is time-sensitive or critical for use of the application. Examples may + * include an incoming call or an emergency alert. *

* Note: Use {@link androidx.core.view.ViewCompat#setAccessibilityLiveRegion(View, int)} * for backwards-compatibility.