Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2bff6407 authored by Svetoslav Ganov's avatar Svetoslav Ganov Committed by Android (Google) Code Review
Browse files

Merge "Adding an announcement type accessibility event and a method on View to announce."

parents c68bbe6a 51ab90ca
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -23119,6 +23119,7 @@ package android.view {
    method public void addOnLayoutChangeListener(android.view.View.OnLayoutChangeListener);
    method public void addTouchables(java.util.ArrayList<android.view.View>);
    method public android.view.ViewPropertyAnimator animate();
    method public void announceForAccessibility(java.lang.CharSequence);
    method protected boolean awakenScrollBars();
    method protected boolean awakenScrollBars(int);
    method protected boolean awakenScrollBars(int, boolean);
@@ -24343,6 +24344,7 @@ package android.view.accessibility {
    field public static final int INVALID_POSITION = -1; // 0xffffffff
    field public static final deprecated int MAX_TEXT_LENGTH = 500; // 0x1f4
    field public static final int TYPES_ALL_MASK = -1; // 0xffffffff
    field public static final int TYPE_ANNOUNCEMENT = 16384; // 0x4000
    field public static final int TYPE_NOTIFICATION_STATE_CHANGED = 64; // 0x40
    field public static final int TYPE_TOUCH_EXPLORATION_GESTURE_END = 1024; // 0x400
    field public static final int TYPE_TOUCH_EXPLORATION_GESTURE_START = 512; // 0x200
+18 −0
Original line number Diff line number Diff line
@@ -3951,6 +3951,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)
     *
+28 −0
Original line number Diff line number Diff line
@@ -429,6 +429,26 @@ import java.util.List;
 * view.</br>
 * </p>
 * <p>
 * <b>MISCELLANEOUS TYPES</b></br>
 * </p>
 * <p>
 * <b>Announcement</b> - represents the event of an application making an
 * announcement. Usually this announcement 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.</br>
 * <em>Type:</em> {@link #TYPE_ANNOUNCEMENT}</br>
 * <em>Properties:</em></br>
 * <ul>
 *   <li>{@link #getEventType()} - The type of the event.</li>
 *   <li>{@link #getSource()} - The source info (for registered clients).</li>
 *   <li>{@link #getClassName()} - The class name of the source.</li>
 *   <li>{@link #getPackageName()} - The package name of the source.</li>
 *   <li>{@link #getEventTime()}  - The event time.</li>
 *   <li>{@link #getText()} - The text of the announcement.</li>
 *   <li>{@link #isEnabled()} - Whether the source is enabled.</li>
 * </ul>
 * </p>
 * <p>
 * <b>Security note</b>
 * <p>
 * Since an event contains the text of its source privacy can be compromised by leaking
@@ -537,6 +557,11 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par
     */
    public static final int TYPE_VIEW_TEXT_SELECTION_CHANGED = 0x00002000;

    /**
     * Represents the event of an application making an announcement.
     */
    public static final int TYPE_ANNOUNCEMENT = 0x00004000;

    /**
     * Mask for {@link AccessibilityEvent} all types.
     *
@@ -554,6 +579,7 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par
     * @see #TYPE_WINDOW_CONTENT_CHANGED
     * @see #TYPE_VIEW_SCROLLED
     * @see #TYPE_VIEW_TEXT_SELECTION_CHANGED
     * @see #TYPE_ANNOUNCEMENT
     */
    public static final int TYPES_ALL_MASK = 0xFFFFFFFF;

@@ -984,6 +1010,8 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par
                return "TYPE_VIEW_TEXT_SELECTION_CHANGED";
            case TYPE_VIEW_SCROLLED:
                return "TYPE_VIEW_SCROLLED";
            case TYPE_ANNOUNCEMENT:
                return "TYPE_ANNOUNCEMENT";
            default:
                return null;
        }