Merge "Add to AccessibilityEvent#TYPE_ANNOUNCEMENT with suggestion to avoid using it."

This commit is contained in:
Sally Yuen
2022-11-17 20:08:25 +00:00
committed by Android (Google) Code Review
2 changed files with 16 additions and 0 deletions

View File

@@ -8457,6 +8457,18 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* accurately supplying the semantics of their UI.
* They should not need to specify what exactly is announced to users.
*
* <p>
* In general, only announce transitions and don’t generate a confirmation message for simple
* actions like a button press. Label your controls concisely and precisely instead, and for
* significant UI changes like window changes, use
* {@link android.app.Activity#setTitle(CharSequence)} and
* {@link View#setAccessibilityPaneTitle(CharSequence)}.
*
* <p>
* Use {@link View#setAccessibilityLiveRegion(int)} to inform the user of changes to critical
* views within the user interface. These should still be used sparingly as they may generate
* announcements every time a View is updated.
*
* @param text The announcement text.
*/
public void announceForAccessibility(CharSequence text) {

View File

@@ -24,6 +24,7 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import com.android.internal.util.BitUtils;
@@ -519,6 +520,9 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par
/**
* Represents the event of an application making an announcement.
* <p>
* In general, follow the practices described in
* {@link View#announceForAccessibility(CharSequence)}.
*/
public static final int TYPE_ANNOUNCEMENT = 0x00004000;