-
public final class ViewBuilder
-
-
Field Summary
Fields Modifier and Type Field Description private BooleanuseUnmergedTree
-
Constructor Summary
Constructors Constructor Description ViewBuilder()
-
Method Summary
Modifier and Type Method Description final BooleangetUseUnmergedTree()final UnitsetUseUnmergedTree(Boolean useUnmergedTree)final UnitisEnabled()final UnitisNotEnabled()Returns whether the node is not enabled. final UnitisToggleable()Return whether the node is checkable. final UnitisOn()Returns whether the node is toggled. final UnitisOff()Returns whether the node is not toggled. final UnitisSelectable()Return whether the node is selectable. final UnitisSelected()Returns whether the node is selected. final UnitisNotSelected()Returns whether the node is not selected. final UnitisFocusable()Return whether the node is able to receive focus final UnitisNotFocusable()Return whether the node is not able to receive focus. final UnitisFocused()Returns whether the node is focused. final UnitisNotFocused()Returns whether the node is not focused. final UnithasClickAction()Return whether the node has a semantics click action defined. final UnithasNoClickAction()Return whether the node has no semantics click action defined. final UnithasScrollAction()Return whether the node has a semantics scrollable action defined. final UnithasNoScrollAction()Return whether the node has no semantics scrollable action defined. final UnithasContentDescription(String value, Boolean substring, Boolean ignoreCase)Returns whether the node's content description contains the given value. final UnithasContentDescriptionExactly(String values)Returns whether the node's content description contains exactly the given values and nothing else. final UnithasText(String text, Boolean substring, Boolean ignoreCase)Returns whether the node's text contains the given text. final UnithasTextExactly(String textValues, Boolean includeEditableText)Returns whether the node's text contains exactly the given values and nothing else. final UnithasStateDescription(String value)Returns whether the node's value matches exactly to the given accessibility value. final UnitisHeading()Returns whether the node is marked as an accessibility header. final UnithasProgressBarRangeInfo(ProgressBarRangeInfo rangeInfo)Returns whether the node's range info matches exactly to the given accessibility range info. final UnithasTestTag(String testTag)Returns whether the node is annotated by the given test tag. final UnitisDialog()Returns whether the node is a dialog. final UnitisPopup()Returns whether the node is a popup. final UnithasImeAction(ImeAction actionType)Returns whether the node defines the given IME action. final UnithasSetTextAction()Returns whether the node defines semantics action to set text to it. final UnithasScrollToIndexAction()Returns whether the node defines the ability to scroll to an item index. final UnithasScrollToKeyAction()Returns whether the node defines the ability to scroll to an item identified by a key, such as androidx.compose.foundation.lazy. final UnitisRoot()Return whether the node is the root semantics node. final UnithasParent(SemanticsMatcher matcher)Returns whether the node's parent satisfies the given matcher. final UnithasAnyChild(SemanticsMatcher matcher)Returns whether the node has at least one child that satisfies the given matcher. final UnithasAnySibling(SemanticsMatcher matcher)Returns whether the node has at least one sibling that satisfies the given matcher. final UnithasAnyAncestor(SemanticsMatcher matcher)Returns whether the node has at least one ancestor that satisfies the given matcher. final UnithasAnyDescendant(SemanticsMatcher matcher)Returns whether the node has at least one descendant that satisfies the given matcher. final UnitaddSemanticsMatcher(SemanticsMatcher matcher)Returns whether the node matches exactly to the given custom matcher. final UnithasPosition(Integer position)final NodeMatcherbuild()-
-
Method Detail
-
getUseUnmergedTree
final Boolean getUseUnmergedTree()
-
setUseUnmergedTree
final Unit setUseUnmergedTree(Boolean useUnmergedTree)
-
isNotEnabled
final Unit isNotEnabled()
Returns whether the node is not enabled.
-
isToggleable
final Unit isToggleable()
Return whether the node is checkable.
-
isSelectable
final Unit isSelectable()
Return whether the node is selectable.
-
isSelected
final Unit isSelected()
Returns whether the node is selected.
-
isNotSelected
final Unit isNotSelected()
Returns whether the node is not selected.
-
isFocusable
final Unit isFocusable()
Return whether the node is able to receive focus
-
isNotFocusable
final Unit isNotFocusable()
Return whether the node is not able to receive focus.
-
isNotFocused
final Unit isNotFocused()
Returns whether the node is not focused.
-
hasClickAction
final Unit hasClickAction()
Return whether the node has a semantics click action defined.
-
hasNoClickAction
final Unit hasNoClickAction()
Return whether the node has no semantics click action defined.
-
hasScrollAction
final Unit hasScrollAction()
Return whether the node has a semantics scrollable action defined.
-
hasNoScrollAction
final Unit hasNoScrollAction()
Return whether the node has no semantics scrollable action defined.
-
hasContentDescription
final Unit hasContentDescription(String value, Boolean substring, Boolean ignoreCase)
Returns whether the node's content description contains the given value.
Note that in merged semantics tree there can be a list of content descriptions that got merged from the child nodes. Typically an accessibility tooling will decide based on its heuristics which ones to announce.
- Parameters:
value- Value to match as one of the items in the list of content descriptions.substring- Whether to use substring matching.ignoreCase- Whether case should be ignored.
-
hasContentDescriptionExactly
final Unit hasContentDescriptionExactly(String values)
Returns whether the node's content description contains exactly the given values and nothing else.
Note that in merged semantics tree there can be a list of content descriptions that got merged from the child nodes. Typically an accessibility tooling will decide based on its heuristics which ones to announce.
- Parameters:
values- List of values to match (the order does not matter)
-
hasText
final Unit hasText(String text, Boolean substring, Boolean ignoreCase)
Returns whether the node's text contains the given text.
This will also search in SemanticsProperties.EditableText.
Note that in merged semantics tree there can be a list of text items that got merged from the child nodes. Typically an accessibility tooling will decide based on its heuristics which ones to use.
- Parameters:
text- Value to match as one of the items in the list of text values.substring- Whether to use substring matching.ignoreCase- Whether case should be ignored.
-
hasTextExactly
final Unit hasTextExactly(String textValues, Boolean includeEditableText)
Returns whether the node's text contains exactly the given values and nothing else.
This will also search in SemanticsProperties.EditableText by default.
Note that in merged semantics tree there can be a list of text items that got merged from the child nodes. Typically an accessibility tooling will decide based on its heuristics which ones to use.
- Parameters:
textValues- List of values to match (the order does not matter)includeEditableText- Whether to also assert against the editable text.
-
hasStateDescription
final Unit hasStateDescription(String value)
Returns whether the node's value matches exactly to the given accessibility value.
- Parameters:
value- Value to match.
-
hasProgressBarRangeInfo
final Unit hasProgressBarRangeInfo(ProgressBarRangeInfo rangeInfo)
Returns whether the node's range info matches exactly to the given accessibility range info.
- Parameters:
rangeInfo- range info to match.
-
hasTestTag
final Unit hasTestTag(String testTag)
Returns whether the node is annotated by the given test tag.
- Parameters:
testTag- Value to match.
-
isDialog
final Unit isDialog()
Returns whether the node is a dialog.
This only checks if the node itself is a dialog, not if it is part of a dialog. Use
hasAnyAncestorThat(isDialog())for that.
-
isPopup
final Unit isPopup()
Returns whether the node is a popup.
This only checks if the node itself is a popup, not if it is part of a popup. Use
hasAnyAncestorThat(isPopup())for that.
-
hasImeAction
final Unit hasImeAction(ImeAction actionType)
Returns whether the node defines the given IME action.
- Parameters:
actionType- the action to match.
-
hasSetTextAction
final Unit hasSetTextAction()
Returns whether the node defines semantics action to set text to it.
This can be used to for instance filter out text fields.
-
hasScrollToIndexAction
final Unit hasScrollToIndexAction()
Returns whether the node defines the ability to scroll to an item index.
Note that not all scrollable containers have item indices. For example, a androidx.compose.foundation.gestures.scrollable doesn't have items with an index, while androidx.compose.foundation.lazy.LazyColumn does.
-
hasScrollToKeyAction
final Unit hasScrollToKeyAction()
Returns whether the node defines the ability to scroll to an item identified by a key, such as androidx.compose.foundation.lazy.LazyColumn or androidx.compose.foundation.lazy.LazyRow.
-
isRoot
final Unit isRoot()
Return whether the node is the root semantics node.
There is always one root in every node tree, added implicitly by Compose.
-
hasParent
final Unit hasParent(SemanticsMatcher matcher)
Returns whether the node's parent satisfies the given matcher.
Returns false if no parent exists.
-
hasAnyChild
final Unit hasAnyChild(SemanticsMatcher matcher)
Returns whether the node has at least one child that satisfies the given matcher.
-
hasAnySibling
final Unit hasAnySibling(SemanticsMatcher matcher)
Returns whether the node has at least one sibling that satisfies the given matcher.
Sibling is defined as a any other node that shares the same parent.
-
hasAnyAncestor
final Unit hasAnyAncestor(SemanticsMatcher matcher)
Returns whether the node has at least one ancestor that satisfies the given matcher.
Example: For the following tree |-X |-A |-B |-C1 |-C2 In case of C1, we would check the matcher against A and B
-
hasAnyDescendant
final Unit hasAnyDescendant(SemanticsMatcher matcher)
Returns whether the node has at least one descendant that satisfies the given matcher.
Example: For the following tree |-X |-A |-B |-C1 |-C2 In case of A, we would check the matcher against B,C1 and C2
-
addSemanticsMatcher
final Unit addSemanticsMatcher(SemanticsMatcher matcher)
Returns whether the node matches exactly to the given custom matcher.
-
hasPosition
final Unit hasPosition(Integer position)
-
build
final NodeMatcher build()
-
-
-
-