diff --git a/api/current.txt b/api/current.txt index 4821122472703..c1eeaf9d8ffd3 100644 --- a/api/current.txt +++ b/api/current.txt @@ -56155,7 +56155,7 @@ package android.view.accessibility { } public static final class AccessibilityNodeInfo.ExtraRenderingInfo { - method @Nullable public android.util.Size getLayoutParams(); + method @Nullable public android.util.Size getLayoutSize(); method public float getTextSizeInPx(); method public int getTextSizeUnit(); } diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index b6c46be667614..7d4ec3dcf2e78 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -3714,7 +3714,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager if (extraDataKey.equals(AccessibilityNodeInfo.EXTRA_DATA_RENDERING_INFO_KEY)) { final AccessibilityNodeInfo.ExtraRenderingInfo extraRenderingInfo = AccessibilityNodeInfo.ExtraRenderingInfo.obtain(); - extraRenderingInfo.setLayoutParams(getLayoutParams().width, getLayoutParams().height); + extraRenderingInfo.setLayoutSize(getLayoutParams().width, getLayoutParams().height); info.setExtraRenderingInfo(extraRenderingInfo); } } diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfo.java b/core/java/android/view/accessibility/AccessibilityNodeInfo.java index f2cbf895dfb66..9ebdbdf5857ce 100644 --- a/core/java/android/view/accessibility/AccessibilityNodeInfo.java +++ b/core/java/android/view/accessibility/AccessibilityNodeInfo.java @@ -649,7 +649,7 @@ public class AccessibilityNodeInfo implements Parcelable { * argument. *
* The data can be retrieved from the {@link ExtraRenderingInfo} returned by
- * {@link #getExtraRenderingInfo()} using {@link ExtraRenderingInfo#getLayoutParams},
+ * {@link #getExtraRenderingInfo()} using {@link ExtraRenderingInfo#getLayoutSize},
* {@link ExtraRenderingInfo#getTextSizeInPx()} and
* {@link ExtraRenderingInfo#getTextSizeUnit()}. For layout params, it is supported by both
* {@link TextView} and {@link ViewGroup}. For text size and unit, it is only supported by
@@ -657,7 +657,6 @@ public class AccessibilityNodeInfo implements Parcelable {
*
* @see #refreshWithExtraData(String, Bundle)
*/
-
public static final String EXTRA_DATA_RENDERING_INFO_KEY =
"android.view.accessibility.extra.DATA_RENDERING_INFO_KEY";
@@ -1038,8 +1037,8 @@ public class AccessibilityNodeInfo implements Parcelable {
* with this mechanism is generally expensive to retrieve, so should only be
* requested when needed. See
* {@link #EXTRA_DATA_RENDERING_INFO_KEY},
- * {@link #EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY} and
- * {@link #getAvailableExtraData()}.
+ * {@link #EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY},
+ * {@link #getAvailableExtraData()} and {@link #getExtraRenderingInfo()}.
* @param args A bundle of arguments for the request. These depend on the particular request.
*
* @return {@code true} if the refresh succeeded. {@code false} if the {@link View} represented
@@ -2437,9 +2436,13 @@ public class AccessibilityNodeInfo implements Parcelable {
}
/**
- * Gets the conformance info if the node is meant to be refreshed with extra data.
+ * Gets the {@link ExtraRenderingInfo extra rendering info} if the node is meant to be
+ * refreshed with extra data to examine rendering related accessibility issues.
*
- * @return The conformance info.
+ * @return The {@link ExtraRenderingInfo extra rendering info}.
+ *
+ * @see #EXTRA_DATA_RENDERING_INFO_KEY
+ * @see #refreshWithExtraData(String, Bundle)
*/
@Nullable
public ExtraRenderingInfo getExtraRenderingInfo() {
@@ -2447,14 +2450,15 @@ public class AccessibilityNodeInfo implements Parcelable {
}
/**
- * Sets the conformance info if the node is meant to be refreshed with extra data.
+ * Sets the extra rendering info,
* Note: Cannot be called from an
* {@link android.accessibilityservice.AccessibilityService}.
* This class is made immutable before being delivered to an AccessibilityService.
* extraRenderingInfo, if the node is meant to be
+ * refreshed with extra data.
* other.
*
* @param other The instance to clone.
*/
private ExtraRenderingInfo(@Nullable ExtraRenderingInfo other) {
if (other != null) {
- mLayoutParams = other.mLayoutParams;
+ mLayoutSize = other.mLayoutSize;
mTextSizeInPx = other.mTextSizeInPx;
mTextSizeUnit = other.mTextSizeUnit;
}
}
/**
+ * Gets the size object containing the height and the width of layout params if the node is
+ * a {@link ViewGroup} or a {@link TextView}, or null otherwise. Useful for accessibility
+ * scanning tool to understand whether the text is scalable and fits the view or not.
+ *
* @return a {@link Size} stores layout height and layout width of the view,
* or null otherwise.
*/
- public @Nullable Size getLayoutParams() {
- return mLayoutParams;
+ public @Nullable Size getLayoutSize() {
+ return mLayoutSize;
}
/**
@@ -5863,11 +5871,15 @@ public class AccessibilityNodeInfo implements Parcelable {
* @param height The layout height.
* @hide
*/
- public void setLayoutParams(int width, int height) {
- mLayoutParams = new Size(width, height);
+ public void setLayoutSize(int width, int height) {
+ mLayoutSize = new Size(width, height);
}
/**
+ * Gets the text size if the node is a {@link TextView}, or -1 otherwise. Useful for
+ * accessibility scanning tool to understand whether the text is scalable and fits the view
+ * or not.
+ *
* @return the text size of a {@code TextView}, or -1 otherwise.
*/
public float getTextSizeInPx() {
@@ -5885,6 +5897,11 @@ public class AccessibilityNodeInfo implements Parcelable {
}
/**
+ * Gets the text size unit if the node is a {@link TextView}, or -1 otherwise.
+ * Text size returned from {@link #getTextSizeInPx} in raw pixels may scale by factors and
+ * convert from other units. Useful for accessibility scanning tool to understand whether
+ * the text is scalable and fits the view or not.
+ *
* @return the text size unit which type is {@link TypedValue#TYPE_DIMENSION} of a
* {@code TextView}, or -1 otherwise.
*
@@ -5915,7 +5932,7 @@ public class AccessibilityNodeInfo implements Parcelable {
}
private void clear() {
- mLayoutParams = null;
+ mLayoutSize = null;
mTextSizeInPx = UNDEFINED_VALUE;
mTextSizeUnit = UNDEFINED_VALUE;
}
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index f3243aaf5b7de..ed5eeeae5bd14 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -11881,7 +11881,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
if (extraDataKey.equals(AccessibilityNodeInfo.EXTRA_DATA_RENDERING_INFO_KEY)) {
final AccessibilityNodeInfo.ExtraRenderingInfo extraRenderingInfo =
AccessibilityNodeInfo.ExtraRenderingInfo.obtain();
- extraRenderingInfo.setLayoutParams(getLayoutParams().width, getLayoutParams().height);
+ extraRenderingInfo.setLayoutSize(getLayoutParams().width, getLayoutParams().height);
extraRenderingInfo.setTextSizeInPx(getTextSize());
extraRenderingInfo.setTextSizeUnit(getTextSizeUnit());
info.setExtraRenderingInfo(extraRenderingInfo);