summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Dieter Hsu <dieterhsu@google.com> 2020-03-10 03:08:50 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-03-10 03:08:50 +0000
commit04a579c6b750dc4cd3effbdfe92c54de237f7974 (patch)
treee58e5e817800d3b3390503c877e59a4b81f77cf5
parentd7e8b960421decd96ec0c68fa6d91e3f7a3a222d (diff)
parent809a286aefa8d7b0e54b0228761da7ca1eb0bf5c (diff)
Merge "Update API ExtraRenderingInfo by review feedback" into rvc-dev
-rw-r--r--api/current.txt2
-rw-r--r--core/java/android/view/ViewGroup.java2
-rw-r--r--core/java/android/view/accessibility/AccessibilityNodeInfo.java55
-rw-r--r--core/java/android/widget/TextView.java2
4 files changed, 39 insertions, 22 deletions
diff --git a/api/current.txt b/api/current.txt
index 482112247270..c1eeaf9d8ffd 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 b6c46be66761..7d4ec3dcf2e7 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 f2cbf895dfb6..9ebdbdf5857c 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.
* <p>
* 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 {@link ExtraRenderingInfo extra rendering info}.
*
- * @return The conformance 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, <code>extraRenderingInfo<code/>, if the node is meant to be
+ * refreshed with extra data.
* <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 extraRenderingInfo The conformance info.
+ * @param extraRenderingInfo The {@link ExtraRenderingInfo extra rendering info}.
* @hide
*/
public void setExtraRenderingInfo(@NonNull ExtraRenderingInfo extraRenderingInfo) {
@@ -3925,7 +3929,7 @@ public class AccessibilityNodeInfo implements Parcelable {
}
if (isBitSet(nonDefaultFields, fieldIndex++)) {
- parcel.writeValue(mExtraRenderingInfo.getLayoutParams());
+ parcel.writeValue(mExtraRenderingInfo.getLayoutSize());
parcel.writeFloat(mExtraRenderingInfo.getTextSizeInPx());
parcel.writeInt(mExtraRenderingInfo.getTextSizeUnit());
}
@@ -4189,7 +4193,7 @@ public class AccessibilityNodeInfo implements Parcelable {
if (isBitSet(nonDefaultFields, fieldIndex++)) {
if (mExtraRenderingInfo != null) mExtraRenderingInfo.recycle();
mExtraRenderingInfo = ExtraRenderingInfo.obtain();
- mExtraRenderingInfo.mLayoutParams = (Size) parcel.readValue(null);
+ mExtraRenderingInfo.mLayoutSize = (Size) parcel.readValue(null);
mExtraRenderingInfo.mTextSizeInPx = parcel.readFloat();
mExtraRenderingInfo.mTextSizeUnit = parcel.readInt();
}
@@ -5808,7 +5812,7 @@ public class AccessibilityNodeInfo implements Parcelable {
private static final SynchronizedPool<ExtraRenderingInfo> sPool =
new SynchronizedPool<>(MAX_POOL_SIZE);
- private Size mLayoutParams;
+ private Size mLayoutSize;
private float mTextSizeInPx = UNDEFINED_VALUE;
private int mTextSizeUnit = UNDEFINED_VALUE;
@@ -5828,32 +5832,36 @@ public class AccessibilityNodeInfo implements Parcelable {
/** Obtains a pooled instance that is a clone of another one. */
private static ExtraRenderingInfo obtain(ExtraRenderingInfo other) {
ExtraRenderingInfo extraRenderingInfo = ExtraRenderingInfo.obtain();
- extraRenderingInfo.mLayoutParams = other.mLayoutParams;
+ extraRenderingInfo.mLayoutSize = other.mLayoutSize;
extraRenderingInfo.mTextSizeInPx = other.mTextSizeInPx;
extraRenderingInfo.mTextSizeUnit = other.mTextSizeUnit;
return extraRenderingInfo;
}
/**
- * Creates a new conformance info of a view, and this new instance is initialized from
+ * Creates a new rendering info of a view, and this new instance is initialized from
* the given <code>other</code>.
*
* @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 f3243aaf5b7d..ed5eeeae5bd1 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);