AssistStructure.ViewNode


public static class AssistStructure.ViewNode
extends Object

java.lang.Object
   ↳ android.app.assist.AssistStructure.ViewNode


Describes a single view in the assist data.

Summary

Constants

int TEXT_COLOR_UNDEFINED

Magic value for text color that has not been defined, which is very unlikely to be confused with a real text color.

int TEXT_STYLE_BOLD

int TEXT_STYLE_ITALIC

int TEXT_STYLE_STRIKE_THRU

int TEXT_STYLE_UNDERLINE

Public methods

float getAlpha()

Returns the alpha transformation of the view, used to reduce the overall opacity of the view's contents, as set by ViewStructure.setAlpha(float).

String[] getAutofillHints()

Describes the content of a view so that a autofill service can fill in the appropriate data.

AutofillId getAutofillId()

Gets the id that can be used to autofill the view contents.

CharSequence[] getAutofillOptions()

Gets the options that can be used to autofill this view.

int getAutofillType()

Gets the type of value that can be used to autofill the view contents.

AutofillValue getAutofillValue()

Gets the value of this view.

AssistStructure.ViewNode getChildAt(int index)

Return a child of this node, given an index value from 0 to getChildCount()-1.

int getChildCount()

Return the number of children this node has.

String getClassName()

Returns the class name of the node's implementation, indicating its behavior.

CharSequence getContentDescription()

Returns any content description associated with the node, which semantically describes its purpose for accessibility and other uses.

float getElevation()

Returns the visual elevation of the view, used for shadowing and other visual characterstics, as set by ViewStructure.setElevation(float).

Bundle getExtras()

Return a Bundle containing optional vendor-specific extension information.

int getHeight()

Returns the height of this view, in pixels.

String getHint()

Return additional hint text associated with the node; this is typically used with a node that takes user input, describing to the user what the input means.

String getHintIdEntry()

Gets the identifier used to set the hint associated with this view.

ViewStructure.HtmlInfo getHtmlInfo()

Returns the HTML properties associated with this view.

int getId()

Returns the ID associated with this view, as per View.getId().

String getIdEntry()

If getId() is a resource identifier, this is the entry name of that identifier.

String getIdPackage()

If getId() is a resource identifier, this is the package name of that identifier.

String getIdType()

If getId() is a resource identifier, this is the type name of that identifier.

int getImportantForAutofill()

Gets the importantForAutofill mode of the view associated with this node.

int getInputType()

Gets the InputType bits of this structure.

int getLeft()

Returns the left edge of this view, in pixels, relative to the left edge of its parent.

LocaleList getLocaleList()

Returns the list of locales associated with this view.

int getMaxTextEms()

Returns the maximum width in ems of the text associated with this node, or -1 if not supported by the node.

int getMaxTextLength()

Returns the maximum length of the text associated with this node, or -1 if not supported by the node or not set.

int getMinTextEms()

Returns the minimum width in ems of the text associated with this node, or -1 if not supported by the node.

String[] getReceiveContentMimeTypes()

Returns the MIME types accepted by View.performReceiveContent for this view.

int getScrollX()

Returns the current X scroll offset of this view, as per View.getScrollX().

int getScrollY()

Returns the current Y scroll offset of this view, as per View.getScrollY().

CharSequence getText()

Returns any text associated with the node that is displayed to the user, or null if there is none.

int getTextBackgroundColor()

If getText() is non-null, this is the main text background color associated with it.

int getTextColor()

If getText() is non-null, this is the main text color associated with it.

String getTextIdEntry()

Gets the identifier used to set the text associated with this view.

int[] getTextLineBaselines()

Return per-line baselines into the text returned by getText().

int[] getTextLineCharOffsets()

Return per-line offsets into the text returned by getText().

int getTextSelectionEnd()

If getText() is non-null, this is where the current selection starts.

int getTextSelectionStart()

If getText() is non-null, this is where the current selection starts.

float getTextSize()

If getText() is non-null, this is the main text size (in pixels) associated with it.

int getTextStyle()

If getText() is non-null, this is the main text style associated with it, containing a bit mask of TEXT_STYLE_BOLD, TEXT_STYLE_BOLD, TEXT_STYLE_STRIKE_THRU, and/or TEXT_STYLE_UNDERLINE.

int getTop()

Returns the top edge of this view, in pixels, relative to the top edge of its parent.

Matrix getTransformation()

Returns the transformation that has been applied to this view, such as a translation or scaling.

int getVisibility()

Returns the visibility mode of this view, as per View.getVisibility().

String getWebDomain()

Returns the domain of the HTML document represented by this view.

String getWebScheme()

Returns the scheme of the HTML document represented by this view.

int getWidth()

Returns the width of this view, in pixels.

boolean isAccessibilityFocused()

Returns true if this node currently had accessibility focus at the time that the structure was collected.

boolean isActivated()

Returns true if this node has currently been activated by the user.

boolean isAssistBlocked()

Returns true if assist data has been blocked starting at this node in the hierarchy.

boolean isCheckable()

Returns true if this node represents something that is checkable by the user.

boolean isChecked()

Returns true if this node is currently in a checked state.

boolean isClickable()

Returns true if this node is clickable by the user.

boolean isContextClickable()

Returns true if this node is something the user can perform a context click on.

boolean isEnabled()

Returns true if this node is in an enabled state.

boolean isFocusable()

Returns true if this node can take input focus.

boolean isFocused()

Returns true if this node currently had input focus at the time that the structure was collected.

boolean isLongClickable()

Returns true if this node is something the user can perform a long click/press on.

boolean isOpaque()

Returns true if this node is opaque.

boolean isSelected()

Returns true if this node has currently been selected by the user.

Inherited methods

Constants

TEXT_COLOR_UNDEFINED

Added in API level 23
public static final int TEXT_COLOR_UNDEFINED

Magic value for text color that has not been defined, which is very unlikely to be confused with a real text color.

Constant Value: 1 (0x00000001)

TEXT_STYLE_BOLD

Added in API level 23
public static final int TEXT_STYLE_BOLD

Constant Value: 1 (0x00000001)

TEXT_STYLE_ITALIC

Added in API level 23
public static final int TEXT_STYLE_ITALIC

Constant Value: 2 (0x00000002)

TEXT_STYLE_STRIKE_THRU

Added in API level 23
public static final int TEXT_STYLE_STRIKE_THRU

Constant Value: 8 (0x00000008)

TEXT_STYLE_UNDERLINE

Added in API level 23
public static final int TEXT_STYLE_UNDERLINE

Constant Value: 4 (0x00000004)

Public methods

getAlpha

Added in API level 23
public float getAlpha ()

Returns the alpha transformation of the view, used to reduce the overall opacity of the view's contents, as set by ViewStructure.setAlpha(float).

It's only relevant when the AssistStructure is used for assist purposes, not for autofill purposes.

Returns
float

getAutofillHints

Added in API level 26
public String[] getAutofillHints ()

Describes the content of a view so that a autofill service can fill in the appropriate data.

It's only relevant when the AssistStructure is used for autofill purposes, not for Assist - see View.getAutofillHints() for more info.

Returns
String[] The autofill hints for this view, or null if the structure was created for assist purposes.

getAutofillId

Added in API level 26
public AutofillId getAutofillId ()

Gets the id that can be used to autofill the view contents.

It's only relevant when the AssistStructure is used for autofill purposes.

Returns
AutofillId id that can be used to autofill the view contents, or null if the structure was created for assist purposes.

getAutofillOptions

Added in API level 26
public CharSequence[] getAutofillOptions ()

Gets the options that can be used to autofill this view.

Typically used by nodes whose View.getAutofillType() is a list to indicate the meaning of each possible value in the list.

It's relevant when the AssistStructure is used for autofill purposes, not for assist purposes.

Returns
CharSequence[] the options that can be used to autofill this view, or null if the structure was created for assist purposes.

getAutofillType

Added in API level 26
public int getAutofillType ()

Gets the type of value that can be used to autofill the view contents.

It's only relevant when the AssistStructure is used for autofill purposes.

Returns
int autofill type as defined by View.getAutofillType(), or View.AUTOFILL_TYPE_NONE if the structure was created for assist purposes. Value is View.AUTOFILL_TYPE_NONE, View.AUTOFILL_TYPE_TEXT, View.AUTOFILL_TYPE_TOGGLE, View.AUTOFILL_TYPE_LIST, or View.AUTOFILL_TYPE_DATE

getAutofillValue

Added in API level 26
public AutofillValue getAutofillValue ()

Gets the value of this view.

It's only relevant when the AssistStructure is used for autofill purposes, not for assist purposes.

Returns
AutofillValue the autofill value of this view, or null if the structure was created for assist purposes.

getChildAt

Added in API level 23
public AssistStructure.ViewNode getChildAt (int index)

Return a child of this node, given an index value from 0 to getChildCount()-1.

Parameters
index int

Returns
AssistStructure.ViewNode

getChildCount

Added in API level 23
public int getChildCount ()

Return the number of children this node has.

Returns
int

getClassName

Added in API level 23
public String getClassName ()

Returns the class name of the node's implementation, indicating its behavior. For example, a button will report "android.widget.Button" meaning it behaves like a Button.

Returns
String This value may be null.

getContentDescription

Added in API level 23
public CharSequence getContentDescription ()

Returns any content description associated with the node, which semantically describes its purpose for accessibility and other uses.

Returns
CharSequence This value may be null.

getElevation

Added in API level 23
public float getElevation ()

Returns the visual elevation of the view, used for shadowing and other visual characterstics, as set by ViewStructure.setElevation(float).

It's only relevant when the AssistStructure is used for assist purposes, not for autofill purposes.

Returns
float

getExtras

Added in API level 23
public Bundle getExtras ()

Return a Bundle containing optional vendor-specific extension information.

Returns
Bundle This value may be null.

getHeight

Added in API level 23
public int getHeight ()

Returns the height of this view, in pixels.

Returns
int

getHint

Added in API level 23
public String getHint ()

Return additional hint text associated with the node; this is typically used with a node that takes user input, describing to the user what the input means.

Returns
String This value may be null.

getHintIdEntry

Added in API level 30
public String getHintIdEntry ()

Gets the identifier used to set the hint associated with this view.

It's only relevant when the AssistStructure is used for autofill purposes, not for assist purposes.

Returns
String This value may be null.

getHtmlInfo

Added in API level 26
public ViewStructure.HtmlInfo getHtmlInfo ()

Returns the HTML properties associated with this view.

It's only relevant when the AssistStructure is used for autofill purposes, not for assist purposes.

Returns
ViewStructure.HtmlInfo the HTML properties associated with this view, or null if the structure was created for assist purposes.

getId

Added in API level 23
public int getId ()

Returns the ID associated with this view, as per View.getId().

Returns
int

getIdEntry

Added in API level 23
public String getIdEntry ()

If getId() is a resource identifier, this is the entry name of that identifier. See ViewStructure.setId for more information.

Returns
String This value may be null.

getIdPackage

Added in API level 23
public String getIdPackage ()

If getId() is a resource identifier, this is the package name of that identifier. See ViewStructure.setId for more information.

Returns
String This value may be null.

getIdType

Added in API level 23
public String getIdType ()

If getId() is a resource identifier, this is the type name of that identifier. See ViewStructure.setId for more information.

Returns
String This value may be null.

getImportantForAutofill

Added in API level 28
public int getImportantForAutofill ()

Gets the importantForAutofill mode of the view associated with this node.

It's only relevant when the AssistStructure is used for autofill purposes.

Returns
int Value is View.IMPORTANT_FOR_AUTOFILL_AUTO, View.IMPORTANT_FOR_AUTOFILL_YES, View.IMPORTANT_FOR_AUTOFILL_NO, View.IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS, or View.IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS

getInputType

Added in API level 26
public int getInputType ()

Gets the InputType bits of this structure.

Returns
int bits as defined by InputType.

getLeft

Added in API level 23
public int getLeft ()

Returns the left edge of this view, in pixels, relative to the left edge of its parent.

Returns
int

getLocaleList

Added in API level 26
public LocaleList getLocaleList ()

Returns the list of locales associated with this view.

Returns
LocaleList This value may be null.

getMaxTextEms

Added in API level 28
public int getMaxTextEms ()

Returns the maximum width in ems of the text associated with this node, or -1 if not supported by the node.

It's only relevant when the AssistStructure is used for autofill purposes, not for assist purposes.

Returns
int

getMaxTextLength

Added in API level 28
public int getMaxTextLength ()

Returns the maximum length of the text associated with this node, or -1 if not supported by the node or not set. System may set a default value if the text length is not set.

It's only relevant when the AssistStructure is used for autofill purposes, not for assist purposes.

Returns
int

getMinTextEms

Added in API level 28
public int getMinTextEms ()

Returns the minimum width in ems of the text associated with this node, or -1 if not supported by the node.

It's only relevant when the AssistStructure is used for autofill purposes, not for assist purposes.

Returns
int

getReceiveContentMimeTypes

Added in API level 31
public String[] getReceiveContentMimeTypes ()

Returns the MIME types accepted by View.performReceiveContent for this view. See View.getReceiveContentMimeTypes() for details.

Returns
String[] This value may be null.

getScrollX

Added in API level 23
public int getScrollX ()

Returns the current X scroll offset of this view, as per View.getScrollX().

Returns
int

getScrollY

Added in API level 23
public int getScrollY ()

Returns the current Y scroll offset of this view, as per View.getScrollY().

Returns
int

getText

Added in API level 23
public CharSequence getText ()

Returns any text associated with the node that is displayed to the user, or null if there is none.

The text will be stripped of any spans that could potentially contain reference to the activity context, to avoid memory leak. If the text contained a span, a plain string version of the text will be returned.

Returns
CharSequence

getTextBackgroundColor

Added in API level 23
public int getTextBackgroundColor ()

If getText() is non-null, this is the main text background color associated with it. If there is no text background color, TEXT_COLOR_UNDEFINED is returned. Note that the text may also contain style spans that modify the color of specific parts of the text.

It's only relevant when the AssistStructure is used for assist purposes, not for autofill purposes.

Returns
int

getTextColor

Added in API level 23
public int getTextColor ()

If getText() is non-null, this is the main text color associated with it. If there is no text color, TEXT_COLOR_UNDEFINED is returned. Note that the text may also contain style spans that modify the color of specific parts of the text.

Returns
int

getTextIdEntry

Added in API level 28
public String getTextIdEntry ()

Gets the identifier used to set the text associated with this view.

It's only relevant when the AssistStructure is used for autofill purposes, not for assist purposes.

Returns
String This value may be null.

getTextLineBaselines

Added in API level 23
public int[] getTextLineBaselines ()

Return per-line baselines into the text returned by getText(). Each entry in the array is a formatted line of text, and the value it contains is the baseline where that text appears in the view. May return null if there is no line information.

It's only relevant when the AssistStructure is used for assist purposes, not for autofill purposes.

Returns
int[]

getTextLineCharOffsets

Added in API level 23
public int[] getTextLineCharOffsets ()

Return per-line offsets into the text returned by getText(). Each entry in the array is a formatted line of text, and the value it contains is the offset into the text string where that line starts. May return null if there is no line information.

It's only relevant when the AssistStructure is used for assist purposes, not for autofill purposes.

Returns
int[]

getTextSelectionEnd

Added in API level 23
public int getTextSelectionEnd ()

If getText() is non-null, this is where the current selection starts. If there is no selection, returns the same value as getTextSelectionStart(), indicating the cursor position.

It's only relevant when the AssistStructure is used for assist purposes, not for autofill purposes.

Returns
int

getTextSelectionStart

Added in API level 23
public int getTextSelectionStart ()

If getText() is non-null, this is where the current selection starts.

It's only relevant when the AssistStructure is used for assist purposes, not for autofill purposes.

Returns
int

getTextSize

Added in API level 23
public float getTextSize ()

If getText() is non-null, this is the main text size (in pixels) associated with it. Note that the text may also contain style spans that modify the size of specific parts of the text.

It's only relevant when the AssistStructure is used for assist purposes, not for autofill purposes.

Returns
float

getTextStyle

Added in API level 23
public int getTextStyle ()

If getText() is non-null, this is the main text style associated with it, containing a bit mask of TEXT_STYLE_BOLD, TEXT_STYLE_BOLD, TEXT_STYLE_STRIKE_THRU, and/or TEXT_STYLE_UNDERLINE. Note that the text may also contain style spans that modify the style of specific parts of the text.

It's only relevant when the AssistStructure is used for assist purposes, not for autofill purposes.

Returns
int

getTop

Added in API level 23
public int getTop ()

Returns the top edge of this view, in pixels, relative to the top edge of its parent.

Returns
int

getTransformation

Added in API level 23
public Matrix getTransformation ()

Returns the transformation that has been applied to this view, such as a translation or scaling. The returned Matrix object is owned by ViewNode; do not modify it. Returns null if there is no transformation applied to the view.

It's only relevant when the AssistStructure is used for assist purposes, not for autofill purposes.

Returns
Matrix

getVisibility

Added in API level 23
public int getVisibility ()

Returns the visibility mode of this view, as per View.getVisibility().

Returns
int

getWebDomain

Added in API level 26
public String getWebDomain ()

Returns the domain of the HTML document represented by this view.

Typically used when the view associated with the view is a container for an HTML document.

Warning: an autofill service cannot trust the value reported by this method without verifing its authenticity—see the "Web security" section of AutofillService for more details.

Returns
String domain-only part of the document. For example, if the full URL is https://example.com/login?user=my_user, it returns example.com. This value may be null.

getWebScheme

Added in API level 28
public String getWebScheme ()

Returns the scheme of the HTML document represented by this view.

Typically used when the view associated with the view is a container for an HTML document.

Returns
String scheme-only part of the document. For example, if the full URL is https://example.com/login?user=my_user, it returns https. This value may be null.

getWidth

Added in API level 23
public int getWidth ()

Returns the width of this view, in pixels.

Returns
int

isAccessibilityFocused

Added in API level 23
public boolean isAccessibilityFocused ()

Returns true if this node currently had accessibility focus at the time that the structure was collected.

Returns
boolean

isActivated

Added in API level 23
public boolean isActivated ()

Returns true if this node has currently been activated by the user.

Returns
boolean

isAssistBlocked

Added in API level 23
public boolean isAssistBlocked ()

Returns true if assist data has been blocked starting at this node in the hierarchy.

Returns
boolean

isCheckable

Added in API level 23
public boolean isCheckable ()

Returns true if this node represents something that is checkable by the user.

Returns
boolean

isChecked

Added in API level 23
public boolean isChecked ()

Returns true if this node is currently in a checked state.

Returns
boolean

isClickable

Added in API level 23
public boolean isClickable ()

Returns true if this node is clickable by the user.

Returns
boolean

isContextClickable

Added in API level 23
public boolean isContextClickable ()

Returns true if this node is something the user can perform a context click on.

Returns
boolean

isEnabled

Added in API level 23
public boolean isEnabled ()

Returns true if this node is in an enabled state.

Returns
boolean

isFocusable

Added in API level 23
public boolean isFocusable ()

Returns true if this node can take input focus.

Returns
boolean

isFocused

Added in API level 23
public boolean isFocused ()

Returns true if this node currently had input focus at the time that the structure was collected.

Returns
boolean

isLongClickable

Added in API level 23
public boolean isLongClickable ()

Returns true if this node is something the user can perform a long click/press on.

Returns
boolean

isOpaque

Added in API level 26
public boolean isOpaque ()

Returns true if this node is opaque.

Returns
boolean

isSelected

Added in API level 23
public boolean isSelected ()

Returns true if this node has currently been selected by the user.

Returns
boolean