Loading core/java/android/view/View.java +5 −2 Original line number Diff line number Diff line Loading @@ -8219,6 +8219,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * <li>{@link ViewStructure#newHtmlInfoBuilder(String)} * <li>{@link ViewStructure#setHtmlInfo(android.view.ViewStructure.HtmlInfo)} * <li>{@link ViewStructure#setDataIsSensitive(boolean)} * <li>{@link ViewStructure#setAlpha(float)} * <li>{@link ViewStructure#setElevation(float)} * <li>{@link ViewStructure#setTransformation(Matrix)} * * </ul> */ public void onProvideContentCaptureStructure(@NonNull ViewStructure structure, int flags) { Loading Loading @@ -8283,8 +8287,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, structure.setDimens(ignoredParentLeft + mLeft, ignoredParentTop + mTop, mScrollX, mScrollY, mRight - mLeft, mBottom - mTop); if (viewFor == VIEW_STRUCTURE_FOR_ASSIST || viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) { if (viewFor == VIEW_STRUCTURE_FOR_ASSIST) { if (!hasIdentityMatrix()) { structure.setTransformation(getMatrix()); } core/java/android/view/contentcapture/ViewNode.java +15 −74 Original line number Diff line number Diff line Loading @@ -45,7 +45,6 @@ import com.android.internal.util.Preconditions; public final class ViewNode extends AssistStructure.ViewNode { private static final String TAG = ViewNode.class.getSimpleName(); private static final boolean VERBOSE = false; private static final long FLAGS_HAS_TEXT = 1L << 0; private static final long FLAGS_HAS_COMPLEX_TEXT = 1L << 1; Loading @@ -69,21 +68,18 @@ public final class ViewNode extends AssistStructure.ViewNode { private static final long FLAGS_SELECTED = 1L << 20; private static final long FLAGS_ACTIVATED = 1L << 21; private static final long FLAGS_OPAQUE = 1L << 22; private static final long FLAGS_HAS_MATRIX = 1L << 23; private static final long FLAGS_HAS_ELEVATION = 1L << 24; private static final long FLAGS_HAS_ALPHA = 1L << 25; private static final long FLAGS_HAS_CONTENT_DESCRIPTION = 1L << 26; private static final long FLAGS_HAS_EXTRAS = 1L << 27; private static final long FLAGS_HAS_LOCALE_LIST = 1L << 28; private static final long FLAGS_HAS_INPUT_TYPE = 1L << 29; private static final long FLAGS_HAS_MIN_TEXT_EMS = 1L << 30; private static final long FLAGS_HAS_MAX_TEXT_EMS = 1L << 31; private static final long FLAGS_HAS_MAX_TEXT_LENGTH = 1L << 32; private static final long FLAGS_HAS_TEXT_ID_ENTRY = 1L << 33; private static final long FLAGS_HAS_AUTOFILL_TYPE = 1L << 34; private static final long FLAGS_HAS_AUTOFILL_VALUE = 1L << 35; private static final long FLAGS_HAS_AUTOFILL_HINTS = 1L << 36; private static final long FLAGS_HAS_AUTOFILL_OPTIONS = 1L << 37; private static final long FLAGS_HAS_CONTENT_DESCRIPTION = 1L << 23; private static final long FLAGS_HAS_EXTRAS = 1L << 24; private static final long FLAGS_HAS_LOCALE_LIST = 1L << 25; private static final long FLAGS_HAS_INPUT_TYPE = 1L << 26; private static final long FLAGS_HAS_MIN_TEXT_EMS = 1L << 27; private static final long FLAGS_HAS_MAX_TEXT_EMS = 1L << 28; private static final long FLAGS_HAS_MAX_TEXT_LENGTH = 1L << 29; private static final long FLAGS_HAS_TEXT_ID_ENTRY = 1L << 30; private static final long FLAGS_HAS_AUTOFILL_TYPE = 1L << 31; private static final long FLAGS_HAS_AUTOFILL_VALUE = 1L << 32; private static final long FLAGS_HAS_AUTOFILL_HINTS = 1L << 33; private static final long FLAGS_HAS_AUTOFILL_OPTIONS = 1L << 34; /** Flags used to optimize what's written to the parcel */ private long mFlags; Loading @@ -103,9 +99,6 @@ public final class ViewNode extends AssistStructure.ViewNode { private int mScrollY; private int mWidth; private int mHeight; private Matrix mMatrix; private float mElevation; private float mAlpha = 1.0f; private CharSequence mContentDescription; private Bundle mExtras; private LocaleList mLocaleList; Loading Loading @@ -165,18 +158,6 @@ public final class ViewNode extends AssistStructure.ViewNode { mScrollX = parcel.readInt(); mScrollY = parcel.readInt(); } if ((nodeFlags & FLAGS_HAS_MATRIX) != 0) { mMatrix = new Matrix(); final float[] tmpMatrix = new float[9]; parcel.readFloatArray(tmpMatrix); mMatrix.setValues(tmpMatrix); } if ((nodeFlags & FLAGS_HAS_ELEVATION) != 0) { mElevation = parcel.readFloat(); } if ((nodeFlags & FLAGS_HAS_ALPHA) != 0) { mAlpha = parcel.readFloat(); } if ((nodeFlags & FLAGS_HAS_CONTENT_DESCRIPTION) != 0) { mContentDescription = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel); } Loading Loading @@ -354,21 +335,6 @@ public final class ViewNode extends AssistStructure.ViewNode { return (mFlags & FLAGS_OPAQUE) != 0; } @Override public Matrix getTransformation() { return mMatrix; } @Override public float getElevation() { return mElevation; } @Override public float getAlpha() { return mAlpha; } @Override public CharSequence getContentDescription() { return mContentDescription; Loading Loading @@ -509,15 +475,6 @@ public final class ViewNode extends AssistStructure.ViewNode { if (mScrollX != 0 || mScrollY != 0) { nodeFlags |= FLAGS_HAS_SCROLL; } if (mMatrix != null) { nodeFlags |= FLAGS_HAS_MATRIX; } if (mElevation != 0) { nodeFlags |= FLAGS_HAS_ELEVATION; } if (mAlpha != 1.0f) { nodeFlags |= FLAGS_HAS_ALPHA; } if (mContentDescription != null) { nodeFlags |= FLAGS_HAS_CONTENT_DESCRIPTION; } Loading Loading @@ -591,18 +548,6 @@ public final class ViewNode extends AssistStructure.ViewNode { parcel.writeInt(mScrollX); parcel.writeInt(mScrollY); } if ((nodeFlags & FLAGS_HAS_MATRIX) != 0) { //TODO(b/122484602): use a singleton tmpMatrix (if logic is not moved to superclass) final float[] tmpMatrix = new float[9]; mMatrix.getValues(tmpMatrix); parcel.writeFloatArray(tmpMatrix); } if ((nodeFlags & FLAGS_HAS_ELEVATION) != 0) { parcel.writeFloat(mElevation); } if ((nodeFlags & FLAGS_HAS_ALPHA) != 0) { parcel.writeFloat(mAlpha); } if ((nodeFlags & FLAGS_HAS_CONTENT_DESCRIPTION) != 0) { TextUtils.writeToParcel(mContentDescription, parcel, 0); } Loading Loading @@ -702,21 +647,17 @@ public final class ViewNode extends AssistStructure.ViewNode { @Override public void setTransformation(Matrix matrix) { if (matrix == null) { mNode.mMatrix = null; } else { mNode.mMatrix = new Matrix(matrix); } Log.w(TAG, "setTransformation() is not supported"); } @Override public void setElevation(float elevation) { mNode.mElevation = elevation; Log.w(TAG, "setElevation() is not supported"); } @Override public void setAlpha(float alpha) { mNode.mAlpha = alpha; Log.w(TAG, "setAlpha() is not supported"); } @Override Loading core/tests/coretests/src/android/view/contentcapture/ViewNodeTest.java +8 −10 Original line number Diff line number Diff line Loading @@ -181,6 +181,14 @@ public class ViewNodeTest { structure.setDataIsSensitive(true); assertThat(structure.getTempRect()).isNull(); // Graphic properties structure.setElevation(6.66f); assertThat(node.getElevation()).isWithin(1.0e-10f).of(0f); structure.setAlpha(66.6f); assertThat(node.getAlpha()).isWithin(1.0e-10f).of(1.0f); structure.setTransformation(Matrix.IDENTITY_MATRIX); assertThat(node.getTransformation()).isNull(); } @Test Loading Loading @@ -279,11 +287,6 @@ public class ViewNodeTest { structure.setAutofillOptions(new String[] { "Maybe" }); structure.setAutofillValue(AutofillValue.forText("Malkovich")); // Graphic properties structure.setElevation(6.66f); structure.setAlpha(66.6f); structure.setTransformation(Matrix.IDENTITY_MATRIX); // Extra text properties structure.setMinTextEms(6); structure.setMaxTextLength(66); Loading Loading @@ -340,11 +343,6 @@ public class ViewNodeTest { assertThat(node.getAutofillOptions()).asList().containsExactly("Maybe").inOrder(); assertThat(node.getAutofillValue().getTextValue()).isEqualTo("Malkovich"); // Graphic properties assertThat(node.getElevation()).isWithin(1.0e-10f).of(6.66f); assertThat(node.getAlpha()).isWithin(1.0e-10f).of(66.6f); assertThat(node.getTransformation()).isEqualTo(Matrix.IDENTITY_MATRIX); // Extra text properties assertThat(node.getMinTextEms()).isEqualTo(6); assertThat(node.getMaxTextLength()).isEqualTo(66); Loading Loading
core/java/android/view/View.java +5 −2 Original line number Diff line number Diff line Loading @@ -8219,6 +8219,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * <li>{@link ViewStructure#newHtmlInfoBuilder(String)} * <li>{@link ViewStructure#setHtmlInfo(android.view.ViewStructure.HtmlInfo)} * <li>{@link ViewStructure#setDataIsSensitive(boolean)} * <li>{@link ViewStructure#setAlpha(float)} * <li>{@link ViewStructure#setElevation(float)} * <li>{@link ViewStructure#setTransformation(Matrix)} * * </ul> */ public void onProvideContentCaptureStructure(@NonNull ViewStructure structure, int flags) { Loading Loading @@ -8283,8 +8287,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, structure.setDimens(ignoredParentLeft + mLeft, ignoredParentTop + mTop, mScrollX, mScrollY, mRight - mLeft, mBottom - mTop); if (viewFor == VIEW_STRUCTURE_FOR_ASSIST || viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) { if (viewFor == VIEW_STRUCTURE_FOR_ASSIST) { if (!hasIdentityMatrix()) { structure.setTransformation(getMatrix()); }
core/java/android/view/contentcapture/ViewNode.java +15 −74 Original line number Diff line number Diff line Loading @@ -45,7 +45,6 @@ import com.android.internal.util.Preconditions; public final class ViewNode extends AssistStructure.ViewNode { private static final String TAG = ViewNode.class.getSimpleName(); private static final boolean VERBOSE = false; private static final long FLAGS_HAS_TEXT = 1L << 0; private static final long FLAGS_HAS_COMPLEX_TEXT = 1L << 1; Loading @@ -69,21 +68,18 @@ public final class ViewNode extends AssistStructure.ViewNode { private static final long FLAGS_SELECTED = 1L << 20; private static final long FLAGS_ACTIVATED = 1L << 21; private static final long FLAGS_OPAQUE = 1L << 22; private static final long FLAGS_HAS_MATRIX = 1L << 23; private static final long FLAGS_HAS_ELEVATION = 1L << 24; private static final long FLAGS_HAS_ALPHA = 1L << 25; private static final long FLAGS_HAS_CONTENT_DESCRIPTION = 1L << 26; private static final long FLAGS_HAS_EXTRAS = 1L << 27; private static final long FLAGS_HAS_LOCALE_LIST = 1L << 28; private static final long FLAGS_HAS_INPUT_TYPE = 1L << 29; private static final long FLAGS_HAS_MIN_TEXT_EMS = 1L << 30; private static final long FLAGS_HAS_MAX_TEXT_EMS = 1L << 31; private static final long FLAGS_HAS_MAX_TEXT_LENGTH = 1L << 32; private static final long FLAGS_HAS_TEXT_ID_ENTRY = 1L << 33; private static final long FLAGS_HAS_AUTOFILL_TYPE = 1L << 34; private static final long FLAGS_HAS_AUTOFILL_VALUE = 1L << 35; private static final long FLAGS_HAS_AUTOFILL_HINTS = 1L << 36; private static final long FLAGS_HAS_AUTOFILL_OPTIONS = 1L << 37; private static final long FLAGS_HAS_CONTENT_DESCRIPTION = 1L << 23; private static final long FLAGS_HAS_EXTRAS = 1L << 24; private static final long FLAGS_HAS_LOCALE_LIST = 1L << 25; private static final long FLAGS_HAS_INPUT_TYPE = 1L << 26; private static final long FLAGS_HAS_MIN_TEXT_EMS = 1L << 27; private static final long FLAGS_HAS_MAX_TEXT_EMS = 1L << 28; private static final long FLAGS_HAS_MAX_TEXT_LENGTH = 1L << 29; private static final long FLAGS_HAS_TEXT_ID_ENTRY = 1L << 30; private static final long FLAGS_HAS_AUTOFILL_TYPE = 1L << 31; private static final long FLAGS_HAS_AUTOFILL_VALUE = 1L << 32; private static final long FLAGS_HAS_AUTOFILL_HINTS = 1L << 33; private static final long FLAGS_HAS_AUTOFILL_OPTIONS = 1L << 34; /** Flags used to optimize what's written to the parcel */ private long mFlags; Loading @@ -103,9 +99,6 @@ public final class ViewNode extends AssistStructure.ViewNode { private int mScrollY; private int mWidth; private int mHeight; private Matrix mMatrix; private float mElevation; private float mAlpha = 1.0f; private CharSequence mContentDescription; private Bundle mExtras; private LocaleList mLocaleList; Loading Loading @@ -165,18 +158,6 @@ public final class ViewNode extends AssistStructure.ViewNode { mScrollX = parcel.readInt(); mScrollY = parcel.readInt(); } if ((nodeFlags & FLAGS_HAS_MATRIX) != 0) { mMatrix = new Matrix(); final float[] tmpMatrix = new float[9]; parcel.readFloatArray(tmpMatrix); mMatrix.setValues(tmpMatrix); } if ((nodeFlags & FLAGS_HAS_ELEVATION) != 0) { mElevation = parcel.readFloat(); } if ((nodeFlags & FLAGS_HAS_ALPHA) != 0) { mAlpha = parcel.readFloat(); } if ((nodeFlags & FLAGS_HAS_CONTENT_DESCRIPTION) != 0) { mContentDescription = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel); } Loading Loading @@ -354,21 +335,6 @@ public final class ViewNode extends AssistStructure.ViewNode { return (mFlags & FLAGS_OPAQUE) != 0; } @Override public Matrix getTransformation() { return mMatrix; } @Override public float getElevation() { return mElevation; } @Override public float getAlpha() { return mAlpha; } @Override public CharSequence getContentDescription() { return mContentDescription; Loading Loading @@ -509,15 +475,6 @@ public final class ViewNode extends AssistStructure.ViewNode { if (mScrollX != 0 || mScrollY != 0) { nodeFlags |= FLAGS_HAS_SCROLL; } if (mMatrix != null) { nodeFlags |= FLAGS_HAS_MATRIX; } if (mElevation != 0) { nodeFlags |= FLAGS_HAS_ELEVATION; } if (mAlpha != 1.0f) { nodeFlags |= FLAGS_HAS_ALPHA; } if (mContentDescription != null) { nodeFlags |= FLAGS_HAS_CONTENT_DESCRIPTION; } Loading Loading @@ -591,18 +548,6 @@ public final class ViewNode extends AssistStructure.ViewNode { parcel.writeInt(mScrollX); parcel.writeInt(mScrollY); } if ((nodeFlags & FLAGS_HAS_MATRIX) != 0) { //TODO(b/122484602): use a singleton tmpMatrix (if logic is not moved to superclass) final float[] tmpMatrix = new float[9]; mMatrix.getValues(tmpMatrix); parcel.writeFloatArray(tmpMatrix); } if ((nodeFlags & FLAGS_HAS_ELEVATION) != 0) { parcel.writeFloat(mElevation); } if ((nodeFlags & FLAGS_HAS_ALPHA) != 0) { parcel.writeFloat(mAlpha); } if ((nodeFlags & FLAGS_HAS_CONTENT_DESCRIPTION) != 0) { TextUtils.writeToParcel(mContentDescription, parcel, 0); } Loading Loading @@ -702,21 +647,17 @@ public final class ViewNode extends AssistStructure.ViewNode { @Override public void setTransformation(Matrix matrix) { if (matrix == null) { mNode.mMatrix = null; } else { mNode.mMatrix = new Matrix(matrix); } Log.w(TAG, "setTransformation() is not supported"); } @Override public void setElevation(float elevation) { mNode.mElevation = elevation; Log.w(TAG, "setElevation() is not supported"); } @Override public void setAlpha(float alpha) { mNode.mAlpha = alpha; Log.w(TAG, "setAlpha() is not supported"); } @Override Loading
core/tests/coretests/src/android/view/contentcapture/ViewNodeTest.java +8 −10 Original line number Diff line number Diff line Loading @@ -181,6 +181,14 @@ public class ViewNodeTest { structure.setDataIsSensitive(true); assertThat(structure.getTempRect()).isNull(); // Graphic properties structure.setElevation(6.66f); assertThat(node.getElevation()).isWithin(1.0e-10f).of(0f); structure.setAlpha(66.6f); assertThat(node.getAlpha()).isWithin(1.0e-10f).of(1.0f); structure.setTransformation(Matrix.IDENTITY_MATRIX); assertThat(node.getTransformation()).isNull(); } @Test Loading Loading @@ -279,11 +287,6 @@ public class ViewNodeTest { structure.setAutofillOptions(new String[] { "Maybe" }); structure.setAutofillValue(AutofillValue.forText("Malkovich")); // Graphic properties structure.setElevation(6.66f); structure.setAlpha(66.6f); structure.setTransformation(Matrix.IDENTITY_MATRIX); // Extra text properties structure.setMinTextEms(6); structure.setMaxTextLength(66); Loading Loading @@ -340,11 +343,6 @@ public class ViewNodeTest { assertThat(node.getAutofillOptions()).asList().containsExactly("Maybe").inOrder(); assertThat(node.getAutofillValue().getTextValue()).isEqualTo("Malkovich"); // Graphic properties assertThat(node.getElevation()).isWithin(1.0e-10f).of(6.66f); assertThat(node.getAlpha()).isWithin(1.0e-10f).of(66.6f); assertThat(node.getTransformation()).isEqualTo(Matrix.IDENTITY_MATRIX); // Extra text properties assertThat(node.getMinTextEms()).isEqualTo(6); assertThat(node.getMaxTextLength()).isEqualTo(66); Loading