diff --git a/core/api/current.txt b/core/api/current.txt index ffea55bda0452..00a28f2a8cf44 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -51750,10 +51750,11 @@ package android.view.accessibility { method public void setSpeechStateChangeTypes(int); method public void writeToParcel(android.os.Parcel, int); field public static final int CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION = 4; // 0x4 + field public static final int CONTENT_CHANGE_TYPE_CONTENT_INVALID = 1024; // 0x400 field public static final int CONTENT_CHANGE_TYPE_DRAG_CANCELLED = 512; // 0x200 field public static final int CONTENT_CHANGE_TYPE_DRAG_DROPPED = 256; // 0x100 field public static final int CONTENT_CHANGE_TYPE_DRAG_STARTED = 128; // 0x80 - field public static final int CONTENT_CHANGE_TYPE_INVALID = 1024; // 0x400 + field public static final int CONTENT_CHANGE_TYPE_ERROR = 2048; // 0x800 field public static final int CONTENT_CHANGE_TYPE_PANE_APPEARED = 16; // 0x10 field public static final int CONTENT_CHANGE_TYPE_PANE_DISAPPEARED = 32; // 0x20 field public static final int CONTENT_CHANGE_TYPE_PANE_TITLE = 8; // 0x8 diff --git a/core/java/android/view/accessibility/AccessibilityEvent.java b/core/java/android/view/accessibility/AccessibilityEvent.java index be2b7a6ec941e..1d4af51fc4dd9 100644 --- a/core/java/android/view/accessibility/AccessibilityEvent.java +++ b/core/java/android/view/accessibility/AccessibilityEvent.java @@ -24,7 +24,6 @@ import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import android.util.Log; -import android.widget.TextView; import com.android.internal.util.BitUtils; @@ -686,15 +685,27 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par /** * Change type for {@link #TYPE_WINDOW_CONTENT_CHANGED} event: - * It means the content is invalid or associated with an error. - * For example, text that sets an error message, such as when input isn't in a valid format, - * should send this event and use {@link AccessibilityNodeInfo#setError} to - * provide more context. + * The source node changed its content validity returned by + * {@link AccessibilityNodeInfo#isContentInvalid}. + * The view changing content validity should call + * {@link AccessibilityNodeInfo#setContentInvalid} and then send this event. * - * @see AccessibilityNodeInfo#setError - * @see TextView#setError + * @see AccessibilityNodeInfo#isContentInvalid + * @see AccessibilityNodeInfo#setContentInvalid */ - public static final int CONTENT_CHANGE_TYPE_INVALID = 0x0000400; + public static final int CONTENT_CHANGE_TYPE_CONTENT_INVALID = 0x0000400; + + /** + * Change type for {@link #TYPE_WINDOW_CONTENT_CHANGED} event: + * The source node changed its erroneous content's error message returned by + * {@link AccessibilityNodeInfo#getError}. + * The view changing erroneous content's error message should call + * {@link AccessibilityNodeInfo#setError} and then send this event. + * + * @see AccessibilityNodeInfo#getError + * @see AccessibilityNodeInfo#setError + */ + public static final int CONTENT_CHANGE_TYPE_ERROR = 0x0000800; /** Change type for {@link #TYPE_SPEECH_STATE_CHANGE} event: another service is speaking. */ public static final int SPEECH_STATE_SPEAKING_START = 0x00000001; @@ -821,7 +832,8 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par CONTENT_CHANGE_TYPE_DRAG_STARTED, CONTENT_CHANGE_TYPE_DRAG_DROPPED, CONTENT_CHANGE_TYPE_DRAG_CANCELLED, - CONTENT_CHANGE_TYPE_INVALID, + CONTENT_CHANGE_TYPE_CONTENT_INVALID, + CONTENT_CHANGE_TYPE_ERROR, }) public @interface ContentChangeTypes {} @@ -1088,7 +1100,9 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par case CONTENT_CHANGE_TYPE_DRAG_STARTED: return "CONTENT_CHANGE_TYPE_DRAG_STARTED"; case CONTENT_CHANGE_TYPE_DRAG_DROPPED: return "CONTENT_CHANGE_TYPE_DRAG_DROPPED"; case CONTENT_CHANGE_TYPE_DRAG_CANCELLED: return "CONTENT_CHANGE_TYPE_DRAG_CANCELLED"; - case CONTENT_CHANGE_TYPE_INVALID: return "CONTENT_CHANGE_TYPE_INVALID"; + case CONTENT_CHANGE_TYPE_CONTENT_INVALID: + return "CONTENT_CHANGE_TYPE_CONTENT_INVALID"; + case CONTENT_CHANGE_TYPE_ERROR: return "CONTENT_CHANGE_TYPE_ERROR"; default: return Integer.toHexString(type); } } diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index b78cbd9a07487..506caa8e6a6a4 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -7618,7 +7618,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener createEditorIfNeeded(); mEditor.setError(error, icon); notifyViewAccessibilityStateChangedIfNeeded( - AccessibilityEvent.CONTENT_CHANGE_TYPE_INVALID); + AccessibilityEvent.CONTENT_CHANGE_TYPE_ERROR + | AccessibilityEvent.CONTENT_CHANGE_TYPE_CONTENT_INVALID); } @Override