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

Commit 0a78adea authored by Phil Weaver's avatar Phil Weaver Committed by Android (Google) Code Review
Browse files

Merge "Provide hint text to accessibility."

parents 5feafb1f 776afc21
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -45102,6 +45102,7 @@ package android.view.accessibility {
    method public int getDrawingOrder();
    method public java.lang.CharSequence getError();
    method public android.os.Bundle getExtras();
    method public java.lang.CharSequence getHintText();
    method public int getInputType();
    method public android.view.accessibility.AccessibilityNodeInfo getLabelFor();
    method public android.view.accessibility.AccessibilityNodeInfo getLabeledBy();
@@ -45136,6 +45137,7 @@ package android.view.accessibility {
    method public boolean isPassword();
    method public boolean isScrollable();
    method public boolean isSelected();
    method public boolean isShowingHintText();
    method public boolean isVisibleToUser();
    method public static android.view.accessibility.AccessibilityNodeInfo obtain(android.view.View);
    method public static android.view.accessibility.AccessibilityNodeInfo obtain(android.view.View, int);
@@ -45169,6 +45171,7 @@ package android.view.accessibility {
    method public void setError(java.lang.CharSequence);
    method public void setFocusable(boolean);
    method public void setFocused(boolean);
    method public void setHintText(java.lang.CharSequence);
    method public void setImportantForAccessibility(boolean);
    method public void setInputType(int);
    method public void setLabelFor(android.view.View);
@@ -45187,6 +45190,7 @@ package android.view.accessibility {
    method public void setRangeInfo(android.view.accessibility.AccessibilityNodeInfo.RangeInfo);
    method public void setScrollable(boolean);
    method public void setSelected(boolean);
    method public void setShowingHintText(boolean);
    method public void setSource(android.view.View);
    method public void setSource(android.view.View, int);
    method public void setText(java.lang.CharSequence);
+4 −0
Original line number Diff line number Diff line
@@ -48333,6 +48333,7 @@ package android.view.accessibility {
    method public int getDrawingOrder();
    method public java.lang.CharSequence getError();
    method public android.os.Bundle getExtras();
    method public java.lang.CharSequence getHintText();
    method public int getInputType();
    method public android.view.accessibility.AccessibilityNodeInfo getLabelFor();
    method public android.view.accessibility.AccessibilityNodeInfo getLabeledBy();
@@ -48367,6 +48368,7 @@ package android.view.accessibility {
    method public boolean isPassword();
    method public boolean isScrollable();
    method public boolean isSelected();
    method public boolean isShowingHintText();
    method public boolean isVisibleToUser();
    method public static android.view.accessibility.AccessibilityNodeInfo obtain(android.view.View);
    method public static android.view.accessibility.AccessibilityNodeInfo obtain(android.view.View, int);
@@ -48400,6 +48402,7 @@ package android.view.accessibility {
    method public void setError(java.lang.CharSequence);
    method public void setFocusable(boolean);
    method public void setFocused(boolean);
    method public void setHintText(java.lang.CharSequence);
    method public void setImportantForAccessibility(boolean);
    method public void setInputType(int);
    method public void setLabelFor(android.view.View);
@@ -48418,6 +48421,7 @@ package android.view.accessibility {
    method public void setRangeInfo(android.view.accessibility.AccessibilityNodeInfo.RangeInfo);
    method public void setScrollable(boolean);
    method public void setSelected(boolean);
    method public void setShowingHintText(boolean);
    method public void setSource(android.view.View);
    method public void setSource(android.view.View, int);
    method public void setText(java.lang.CharSequence);
+4 −0
Original line number Diff line number Diff line
@@ -45398,6 +45398,7 @@ package android.view.accessibility {
    method public int getDrawingOrder();
    method public java.lang.CharSequence getError();
    method public android.os.Bundle getExtras();
    method public java.lang.CharSequence getHintText();
    method public int getInputType();
    method public android.view.accessibility.AccessibilityNodeInfo getLabelFor();
    method public android.view.accessibility.AccessibilityNodeInfo getLabeledBy();
@@ -45432,6 +45433,7 @@ package android.view.accessibility {
    method public boolean isPassword();
    method public boolean isScrollable();
    method public boolean isSelected();
    method public boolean isShowingHintText();
    method public boolean isVisibleToUser();
    method public static android.view.accessibility.AccessibilityNodeInfo obtain(android.view.View);
    method public static android.view.accessibility.AccessibilityNodeInfo obtain(android.view.View, int);
@@ -45465,6 +45467,7 @@ package android.view.accessibility {
    method public void setError(java.lang.CharSequence);
    method public void setFocusable(boolean);
    method public void setFocused(boolean);
    method public void setHintText(java.lang.CharSequence);
    method public void setImportantForAccessibility(boolean);
    method public void setInputType(int);
    method public void setLabelFor(android.view.View);
@@ -45484,6 +45487,7 @@ package android.view.accessibility {
    method public void setRangeInfo(android.view.accessibility.AccessibilityNodeInfo.RangeInfo);
    method public void setScrollable(boolean);
    method public void setSelected(boolean);
    method public void setShowingHintText(boolean);
    method public void setSource(android.view.View);
    method public void setSource(android.view.View, int);
    method public void setText(java.lang.CharSequence);
+60 −0
Original line number Diff line number Diff line
@@ -557,6 +557,8 @@ public class AccessibilityNodeInfo implements Parcelable {

    private static final int BOOLEAN_PROPERTY_IMPORTANCE = 0x0040000;

    private static final int BOOLEAN_PROPERTY_IS_SHOWING_HINT = 0x0100000;

    /**
     * Bits that provide the id of a virtual descendant of a view.
     */
@@ -645,6 +647,7 @@ public class AccessibilityNodeInfo implements Parcelable {
    // Hidden, unparceled value used to hold the original value passed to setText
    private CharSequence mOriginalText;
    private CharSequence mText;
    private CharSequence mHintText;
    private CharSequence mError;
    private CharSequence mContentDescription;
    private String mViewIdResourceName;
@@ -2175,6 +2178,33 @@ public class AccessibilityNodeInfo implements Parcelable {
        setBooleanProperty(BOOLEAN_PROPERTY_IMPORTANCE, important);
    }

    /**
     * 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.
     *
     * @return {@code true} if the text in the node represents a hint to the user, {@code false}
     * otherwise.
     */
    public boolean isShowingHintText() {
        return getBooleanProperty(BOOLEAN_PROPERTY_IS_SHOWING_HINT);
    }

    /**
     * Sets 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.
     * <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 showingHintText {@code true} if the text in the node represents a hint to the user,
     * {@code false} otherwise.
     */
    public void setShowingHintText(boolean showingHintText) {
        setBooleanProperty(BOOLEAN_PROPERTY_IS_SHOWING_HINT, showingHintText);
    }

    /**
     * Gets the package this node comes from.
     *
@@ -2316,6 +2346,32 @@ public class AccessibilityNodeInfo implements Parcelable {
        mText = (text == null) ? null : text.subSequence(0, text.length());
    }

    /**
     * Gets the hint text of this node. Only applies to nodes where text can be entered.
     *
     * @return The hint text.
     */
    public CharSequence getHintText() {
        return mHintText;
    }

    /**
     * Sets the hint text of this node. Only applies to nodes where text can be entered.
     * <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 hintText The hint text for this mode.
     *
     * @throws IllegalStateException If called from an AccessibilityService.
     */
    public void setHintText(CharSequence hintText) {
        enforceNotSealed();
        mHintText = (hintText == null) ? null : hintText.subSequence(0, hintText.length());
    }

    /**
     * Sets the error text of this node.
     * <p>
@@ -2889,6 +2945,7 @@ public class AccessibilityNodeInfo implements Parcelable {
        parcel.writeCharSequence(mPackageName);
        parcel.writeCharSequence(mClassName);
        parcel.writeCharSequence(mText);
        parcel.writeCharSequence(mHintText);
        parcel.writeCharSequence(mError);
        parcel.writeCharSequence(mContentDescription);
        parcel.writeString(mViewIdResourceName);
@@ -2963,6 +3020,7 @@ public class AccessibilityNodeInfo implements Parcelable {
        mPackageName = other.mPackageName;
        mClassName = other.mClassName;
        mText = other.mText;
        mHintText = other.mHintText;
        mError = other.mError;
        mContentDescription = other.mContentDescription;
        mViewIdResourceName = other.mViewIdResourceName;
@@ -3066,6 +3124,7 @@ public class AccessibilityNodeInfo implements Parcelable {
        mPackageName = parcel.readCharSequence();
        mClassName = parcel.readCharSequence();
        mText = parcel.readCharSequence();
        mHintText = parcel.readCharSequence();
        mError = parcel.readCharSequence();
        mContentDescription = parcel.readCharSequence();
        mViewIdResourceName = parcel.readString();
@@ -3137,6 +3196,7 @@ public class AccessibilityNodeInfo implements Parcelable {
        mPackageName = null;
        mClassName = null;
        mText = null;
        mHintText = null;
        mError = null;
        mContentDescription = null;
        mViewIdResourceName = null;
+2 −0
Original line number Diff line number Diff line
@@ -9632,6 +9632,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        final boolean isPassword = hasPasswordTransformationMethod();
        info.setPassword(isPassword);
        info.setText(getTextForAccessibility());
        info.setHintText(mHint);
        info.setShowingHintText(isShowingHint());

        if (mBufferType == BufferType.EDITABLE) {
            info.setEditable(true);