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

Commit 68081e7e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "New API to specify accessibility focus grouping"

parents 01e42ae2 1e6ecc69
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -1119,6 +1119,7 @@ package android {
    field public static final int scheme = 16842791; // 0x1010027
    field public static final int scheme = 16842791; // 0x1010027
    field public static final int screenDensity = 16843467; // 0x10102cb
    field public static final int screenDensity = 16843467; // 0x10102cb
    field public static final int screenOrientation = 16842782; // 0x101001e
    field public static final int screenOrientation = 16842782; // 0x101001e
    field public static final int screenReaderFocusable = 16844148; // 0x1010574
    field public static final int screenSize = 16843466; // 0x10102ca
    field public static final int screenSize = 16843466; // 0x10102ca
    field public static final int scrollHorizontally = 16843099; // 0x101015b
    field public static final int scrollHorizontally = 16843099; // 0x101015b
    field public static final int scrollIndicators = 16844006; // 0x10104e6
    field public static final int scrollIndicators = 16844006; // 0x10104e6
@@ -46331,6 +46332,7 @@ package android.view {
    method public boolean isPressed();
    method public boolean isPressed();
    method public boolean isSaveEnabled();
    method public boolean isSaveEnabled();
    method public boolean isSaveFromParentEnabled();
    method public boolean isSaveFromParentEnabled();
    method public boolean isScreenReaderFocusable();
    method public boolean isScrollContainer();
    method public boolean isScrollContainer();
    method public boolean isScrollbarFadingEnabled();
    method public boolean isScrollbarFadingEnabled();
    method public boolean isSelected();
    method public boolean isSelected();
@@ -46550,6 +46552,7 @@ package android.view {
    method public void setSaveFromParentEnabled(boolean);
    method public void setSaveFromParentEnabled(boolean);
    method public void setScaleX(float);
    method public void setScaleX(float);
    method public void setScaleY(float);
    method public void setScaleY(float);
    method public void setScreenReaderFocusable(boolean);
    method public void setScrollBarDefaultDelayBeforeFade(int);
    method public void setScrollBarDefaultDelayBeforeFade(int);
    method public void setScrollBarFadeDuration(int);
    method public void setScrollBarFadeDuration(int);
    method public void setScrollBarSize(int);
    method public void setScrollBarSize(int);
@@ -47968,6 +47971,7 @@ package android.view.accessibility {
    method public boolean isLongClickable();
    method public boolean isLongClickable();
    method public boolean isMultiLine();
    method public boolean isMultiLine();
    method public boolean isPassword();
    method public boolean isPassword();
    method public boolean isScreenReaderFocusable();
    method public boolean isScrollable();
    method public boolean isScrollable();
    method public boolean isSelected();
    method public boolean isSelected();
    method public boolean isShowingHintText();
    method public boolean isShowingHintText();
@@ -48023,6 +48027,7 @@ package android.view.accessibility {
    method public void setParent(android.view.View, int);
    method public void setParent(android.view.View, int);
    method public void setPassword(boolean);
    method public void setPassword(boolean);
    method public void setRangeInfo(android.view.accessibility.AccessibilityNodeInfo.RangeInfo);
    method public void setRangeInfo(android.view.accessibility.AccessibilityNodeInfo.RangeInfo);
    method public void setScreenReaderFocusable(boolean);
    method public void setScrollable(boolean);
    method public void setScrollable(boolean);
    method public void setSelected(boolean);
    method public void setSelected(boolean);
    method public void setShowingHintText(boolean);
    method public void setShowingHintText(boolean);
+52 −0
Original line number Original line Diff line number Diff line
@@ -2929,6 +2929,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     *        1                          PFLAG3_TEMPORARY_DETACH
     *        1                          PFLAG3_TEMPORARY_DETACH
     *       1                           PFLAG3_NO_REVEAL_ON_FOCUS
     *       1                           PFLAG3_NO_REVEAL_ON_FOCUS
     *      1                            PFLAG3_NOTIFY_AUTOFILL_ENTER_ON_LAYOUT
     *      1                            PFLAG3_NOTIFY_AUTOFILL_ENTER_ON_LAYOUT
     *     1                             PFLAG3_SCREEN_READER_FOCUSABLE
     * |-------|-------|-------|-------|
     * |-------|-------|-------|-------|
     */
     */
@@ -3209,6 +3210,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
     */
    static final int PFLAG3_NOTIFY_AUTOFILL_ENTER_ON_LAYOUT = 0x8000000;
    static final int PFLAG3_NOTIFY_AUTOFILL_ENTER_ON_LAYOUT = 0x8000000;
    /**
     * Works like focusable for screen readers, but without the side effects on input focus.
     * @see #setScreenReaderFocusable(boolean)
     */
    private static final int PFLAG3_SCREEN_READER_FOCUSABLE = 0x10000000;
    /* End of masks for mPrivateFlags3 */
    /* End of masks for mPrivateFlags3 */
    /**
    /**
@@ -5344,6 +5351,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                        setDefaultFocusHighlightEnabled(a.getBoolean(attr, true));
                        setDefaultFocusHighlightEnabled(a.getBoolean(attr, true));
                    }
                    }
                    break;
                    break;
                case R.styleable.View_screenReaderFocusable:
                    if (a.peekValue(attr) != null) {
                        setScreenReaderFocusable(a.getBoolean(attr, false));
                    }
                    break;
            }
            }
        }
        }
@@ -8394,6 +8406,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        info.setEnabled(isEnabled());
        info.setEnabled(isEnabled());
        info.setClickable(isClickable());
        info.setClickable(isClickable());
        info.setFocusable(isFocusable());
        info.setFocusable(isFocusable());
        info.setScreenReaderFocusable(isScreenReaderFocusable());
        info.setFocused(isFocused());
        info.setFocused(isFocused());
        info.setAccessibilityFocused(isAccessibilityFocused());
        info.setAccessibilityFocused(isAccessibilityFocused());
        info.setSelected(isSelected());
        info.setSelected(isSelected());
@@ -10349,6 +10362,45 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        return FOCUSABLE_IN_TOUCH_MODE == (mViewFlags & FOCUSABLE_IN_TOUCH_MODE);
        return FOCUSABLE_IN_TOUCH_MODE == (mViewFlags & FOCUSABLE_IN_TOUCH_MODE);
    }
    }
    /**
     * Returns whether the view should be treated as a focusable unit by screen reader
     * accessibility tools.
     * @see #setScreenReaderFocusable(boolean)
     *
     * @return Whether the view should be treated as a focusable unit by screen reader.
     */
    public boolean isScreenReaderFocusable() {
        return (mPrivateFlags3 & PFLAG3_SCREEN_READER_FOCUSABLE) != 0;
    }
    /**
     * When screen readers (one type of accessibility tool) decide what should be read to the
     * user, they typically look for input focusable ({@link #isFocusable()}) parents of
     * non-focusable text items, and read those focusable parents and their non-focusable children
     * as a unit. In some situations, this behavior is desirable for views that should not take
     * input focus. Setting an item to be screen reader focusable requests that the view be
     * treated as a unit by screen readers without any effect on input focusability. The default
     * value of {@code false} lets screen readers use other signals, like focusable, to determine
     * how to group items.
     *
     * @param screenReaderFocusable Whether the view should be treated as a unit by screen reader
     *                              accessibility tools.
     */
    public void setScreenReaderFocusable(boolean screenReaderFocusable) {
        int pflags3 = mPrivateFlags3;
        if (screenReaderFocusable) {
            pflags3 |= PFLAG3_SCREEN_READER_FOCUSABLE;
        } else {
            pflags3 &= ~PFLAG3_SCREEN_READER_FOCUSABLE;
        }
        if (pflags3 != mPrivateFlags3) {
            mPrivateFlags3 = pflags3;
            notifyViewAccessibilityStateChangedIfNeeded(
                    AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED);
        }
    }
    /**
    /**
     * Find the nearest view in the specified direction that can take focus.
     * Find the nearest view in the specified direction that can take focus.
     * This does not actually give focus to that view.
     * This does not actually give focus to that view.
+1 −1
Original line number Original line Diff line number Diff line
@@ -2591,7 +2591,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
            boolean alreadyDispatchedToNewTouchTarget = false;
            boolean alreadyDispatchedToNewTouchTarget = false;
            if (!canceled && !intercepted) {
            if (!canceled && !intercepted) {


                // If the event is targeting accessiiblity focus we give it to the
                // If the event is targeting accessibility focus we give it to the
                // view that has accessibility focus and if it does not handle it
                // view that has accessibility focus and if it does not handle it
                // we clear the flag and dispatch the event to all children as usual.
                // we clear the flag and dispatch the event to all children as usual.
                // We are looking up the accessibility focused host to avoid keeping
                // We are looking up the accessibility focused host to avoid keeping
+33 −0
Original line number Original line Diff line number Diff line
@@ -635,6 +635,8 @@ public class AccessibilityNodeInfo implements Parcelable {


    private static final int BOOLEAN_PROPERTY_IMPORTANCE = 0x0040000;
    private static final int BOOLEAN_PROPERTY_IMPORTANCE = 0x0040000;


    private static final int BOOLEAN_PROPERTY_SCREEN_READER_FOCUSABLE = 0x0080000;

    private static final int BOOLEAN_PROPERTY_IS_SHOWING_HINT = 0x0100000;
    private static final int BOOLEAN_PROPERTY_IS_SHOWING_HINT = 0x0100000;


    /**
    /**
@@ -2320,6 +2322,37 @@ public class AccessibilityNodeInfo implements Parcelable {
        setBooleanProperty(BOOLEAN_PROPERTY_IMPORTANCE, important);
        setBooleanProperty(BOOLEAN_PROPERTY_IMPORTANCE, important);
    }
    }


    /**
     * Returns whether the node is explicitly marked as a focusable unit by a screen reader. Note
     * that {@code false} indicates that it is not explicitly marked, not that the node is not
     * a focusable unit. Screen readers should generally used other signals, such as
     * {@link #isFocusable()}, or the presence of text in a node, to determine what should receive
     * focus.
     *
     * @return {@code true} if the node is specifically marked as a focusable unit for screen
     *         readers, {@code false} otherwise.
     *
     * @see View#isScreenReaderFocusable()
     */
    public boolean isScreenReaderFocusable() {
        return getBooleanProperty(BOOLEAN_PROPERTY_SCREEN_READER_FOCUSABLE);
    }

    /**
     * Sets whether the node should be considered a focusable unit by a screen reader.
     * <p>
     *   <strong>Note:</strong> Cannot be called from an
     *   {@link android.accessibilityservice.AccessibilityService}.
     *   This class is made immutable before being delivered to an AccessibilityService.
     * </p>
     *
     * @param screenReaderFocusable {@code true} if the node is a focusable unit for screen readers,
     *                              {@code false} otherwise.
     */
    public void setScreenReaderFocusable(boolean screenReaderFocusable) {
        setBooleanProperty(BOOLEAN_PROPERTY_SCREEN_READER_FOCUSABLE, screenReaderFocusable);
    }

    /**
    /**
     * Returns whether the node's text represents a hint for the user to enter text. It should only
     * Returns whether the node's text represents a hint for the user to enter text. It should only
     * be {@code true} if the node has editable text.
     * be {@code true} if the node has editable text.
+6 −0
Original line number Original line Diff line number Diff line
@@ -3021,6 +3021,12 @@
        <!-- Whether this View should use a default focus highlight when it gets focused but
        <!-- Whether this View should use a default focus highlight when it gets focused but
             doesn't have {@link android.R.attr#state_focused} defined in its background. -->
             doesn't have {@link android.R.attr#state_focused} defined in its background. -->
        <attr name="defaultFocusHighlightEnabled" format="boolean" />
        <attr name="defaultFocusHighlightEnabled" format="boolean" />

        <!-- Whether this view should be treated as a focusable unit by screen reader accessibility
             tools. See {@link android.view.View#setScreenReaderFocusable(boolean)}. The default
             value, {@code false}, leaves the screen reader to consider other signals, such as
             focusability or the presence of text, to decide what it focus.-->
        <attr name="screenReaderFocusable" format="boolean" />
    </declare-styleable>
    </declare-styleable>


    <!-- Attributes that can be assigned to a tag for a particular View. -->
    <!-- Attributes that can be assigned to a tag for a particular View. -->
Loading