diff options
| -rw-r--r-- | api/current.txt | 4 | ||||
| -rw-r--r-- | api/system-current.txt | 4 | ||||
| -rw-r--r-- | api/test-current.txt | 4 | ||||
| -rw-r--r-- | core/java/android/view/accessibility/AccessibilityNodeInfo.java | 60 | ||||
| -rw-r--r-- | core/java/android/widget/TextView.java | 2 |
5 files changed, 74 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt index 6da09e35fe5e..7f8693d86089 100644 --- a/api/current.txt +++ b/api/current.txt @@ -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); diff --git a/api/system-current.txt b/api/system-current.txt index 5640eafcee1f..f7c7d4154447 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -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); diff --git a/api/test-current.txt b/api/test-current.txt index 714cac9fc559..c4d17e286721 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -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); diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfo.java b/core/java/android/view/accessibility/AccessibilityNodeInfo.java index 91468dae703e..f0bf7e5cc4d5 100644 --- a/core/java/android/view/accessibility/AccessibilityNodeInfo.java +++ b/core/java/android/view/accessibility/AccessibilityNodeInfo.java @@ -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; @@ -2176,6 +2179,33 @@ public class AccessibilityNodeInfo implements Parcelable { } /** + * 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. * * @return The package name. @@ -2317,6 +2347,32 @@ public class AccessibilityNodeInfo implements Parcelable { } /** + * 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> * <strong>Note:</strong> Cannot be called from an @@ -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; diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 984fa04127b1..345896aeef6e 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -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); |