{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

FiltersKt

public final class FiltersKt


Summary

Public methods

static final @NonNull SemanticsMatcher

Returns whether the node has at least one ancestor that satisfies the given matcher.

static final @NonNull SemanticsMatcher

Returns whether the node has at least one child that satisfies the given matcher.

static final @NonNull SemanticsMatcher

Returns whether the node has at least one descendant that satisfies the given matcher.

static final @NonNull SemanticsMatcher

Returns whether the node has at least one sibling that satisfies the given matcher.

static final @NonNull SemanticsMatcher

Return whether the node has a semantics click action defined.

static final @NonNull SemanticsMatcher
hasContentDescription(
    @NonNull String value,
    boolean substring,
    boolean ignoreCase
)

Returns whether the node's content description contains the given value.

static final @NonNull SemanticsMatcher

Returns whether the node's content description contains exactly the given values and nothing else.

static final @NonNull SemanticsMatcher

Returns whether the node defines the given IME action.

static final @NonNull SemanticsMatcher

Returns whether the node defines a semantics action to insert text on it.

static final @NonNull SemanticsMatcher

Return whether the node has no semantics click action defined.

static final @NonNull SemanticsMatcher

Return whether the node has no semantics scrollable action defined.

static final @NonNull SemanticsMatcher

Returns whether the node's parent satisfies the given matcher.

static final @NonNull SemanticsMatcher

Returns whether the node defines a semantics action to perform the IME action on it.

static final @NonNull SemanticsMatcher

Returns whether the node's range info matches exactly to the given accessibility range info.

static final @NonNull SemanticsMatcher

Returns whether the node defines a semantics action to request focus.

static final @NonNull SemanticsMatcher

Return whether the node has a semantics scrollable action defined.

static final @NonNull SemanticsMatcher

Returns whether the node defines the ability to scroll to an item index.

static final @NonNull SemanticsMatcher

Returns whether the node defines the ability to scroll to an item identified by a key, such as LazyColumn or LazyRow.

static final @NonNull SemanticsMatcher

Returns whether the node defines the ability to scroll to content identified by a matcher.

static final @NonNull SemanticsMatcher

Returns whether the node defines a semantics action to set text on it.

static final @NonNull SemanticsMatcher

Returns whether the node's value matches exactly to the given accessibility value.

static final @NonNull SemanticsMatcher

Returns whether the node is annotated by the given test tag.

static final @NonNull SemanticsMatcher
hasText(@NonNull String text, boolean substring, boolean ignoreCase)

Returns whether the node's text contains the given text.

static final @NonNull SemanticsMatcher
hasTextExactly(
    @NonNull String textValues,
    boolean includeEditableText
)

Returns whether the node's text contains exactly the given textValues and nothing else.

static final @NonNull SemanticsMatcher

Returns whether the node is a dialog.

static final @NonNull SemanticsMatcher

Returns whether the node is enabled.

static final @NonNull SemanticsMatcher

Return whether the node is able to receive focus

static final @NonNull SemanticsMatcher

Returns whether the node is focused.

static final @NonNull SemanticsMatcher

Returns whether the node is marked as an accessibility header.

static final @NonNull SemanticsMatcher

Returns whether the node is not enabled.

static final @NonNull SemanticsMatcher

Return whether the node is not able to receive focus.

static final @NonNull SemanticsMatcher

Returns whether the node is not focused.

static final @NonNull SemanticsMatcher

Returns whether the node is not selected.

static final @NonNull SemanticsMatcher

Returns whether the node is not toggled.

static final @NonNull SemanticsMatcher

Returns whether the node is toggled.

static final @NonNull SemanticsMatcher

Returns whether the node is a popup.

static final @NonNull SemanticsMatcher

Return whether the node is the root semantics node.

static final @NonNull SemanticsMatcher

Return whether the node is selectable.

static final @NonNull SemanticsMatcher

Returns whether the node is selected.

static final @NonNull SemanticsMatcher

Return whether the node is checkable.

Public methods

hasAnyAncestor

public static final @NonNull SemanticsMatcher hasAnyAncestor(@NonNull 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

hasAnyChild

public static final @NonNull SemanticsMatcher hasAnyChild(@NonNull SemanticsMatcher matcher)

Returns whether the node has at least one child that satisfies the given matcher.

hasAnyDescendant

public static final @NonNull SemanticsMatcher hasAnyDescendant(@NonNull 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

hasAnySibling

public static final @NonNull SemanticsMatcher hasAnySibling(@NonNull 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.

hasClickAction

public static final @NonNull SemanticsMatcher hasClickAction()

Return whether the node has a semantics click action defined.

See also
OnClick

hasContentDescription

public static final @NonNull SemanticsMatcher hasContentDescription(
    @NonNull 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
@NonNull String value

Value to match as one of the items in the list of content descriptions.

boolean substring

Whether to use substring matching.

boolean ignoreCase

Whether case should be ignored.

hasContentDescriptionExactly

public static final @NonNull SemanticsMatcher hasContentDescriptionExactly(@NonNull 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
@NonNull String values

List of values to match (the order does not matter)

hasImeAction

public static final @NonNull SemanticsMatcher hasImeAction(@NonNull ImeAction actionType)

Returns whether the node defines the given IME action.

Parameters
@NonNull ImeAction actionType

the action to match.

hasInsertTextAtCursorAction

public static final @NonNull SemanticsMatcher hasInsertTextAtCursorAction()

Returns whether the node defines a semantics action to insert text on it.

This can be used to, for instance, filter out text fields.

hasNoClickAction

public static final @NonNull SemanticsMatcher hasNoClickAction()

Return whether the node has no semantics click action defined.

See also
OnClick

hasNoScrollAction

public static final @NonNull SemanticsMatcher hasNoScrollAction()

Return whether the node has no semantics scrollable action defined.

See also
ScrollBy

hasParent

public static final @NonNull SemanticsMatcher hasParent(@NonNull SemanticsMatcher matcher)

Returns whether the node's parent satisfies the given matcher.

Returns false if no parent exists.

hasPerformImeAction

public static final @NonNull SemanticsMatcher hasPerformImeAction()

Returns whether the node defines a semantics action to perform the IME action on it.

See also
PerformImeAction

hasProgressBarRangeInfo

public static final @NonNull SemanticsMatcher hasProgressBarRangeInfo(@NonNull ProgressBarRangeInfo rangeInfo)

Returns whether the node's range info matches exactly to the given accessibility range info.

Parameters
@NonNull ProgressBarRangeInfo rangeInfo

range info to match.

hasRequestFocusAction

public static final @NonNull SemanticsMatcher hasRequestFocusAction()

Returns whether the node defines a semantics action to request focus.

See also
RequestFocus

hasScrollAction

public static final @NonNull SemanticsMatcher hasScrollAction()

Return whether the node has a semantics scrollable action defined.

See also
ScrollBy

hasScrollToIndexAction

public static final @NonNull SemanticsMatcher 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 scrollable doesn't have items with an index, while LazyColumn does.

hasScrollToKeyAction

public static final @NonNull SemanticsMatcher hasScrollToKeyAction()

Returns whether the node defines the ability to scroll to an item identified by a key, such as LazyColumn or LazyRow.

hasScrollToNodeAction

public static final @NonNull SemanticsMatcher hasScrollToNodeAction()

Returns whether the node defines the ability to scroll to content identified by a matcher.

hasSetTextAction

public static final @NonNull SemanticsMatcher hasSetTextAction()

Returns whether the node defines a semantics action to set text on it.

This can be used to, for instance, filter out text fields.

See also
SetText

hasStateDescription

public static final @NonNull SemanticsMatcher hasStateDescription(@NonNull String value)

Returns whether the node's value matches exactly to the given accessibility value.

Parameters
@NonNull String value

Value to match.

See also
StateDescription

hasTestTag

public static final @NonNull SemanticsMatcher hasTestTag(@NonNull String testTag)

Returns whether the node is annotated by the given test tag.

Parameters
@NonNull String testTag

Value to match.

See also
TestTag

hasText

public static final @NonNull SemanticsMatcher hasText(@NonNull 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
@NonNull String text

Value to match as one of the items in the list of text values.

boolean substring

Whether to use substring matching.

boolean ignoreCase

Whether case should be ignored.

See also
Text
EditableText

hasTextExactly

public static final @NonNull SemanticsMatcher hasTextExactly(
    @NonNull String textValues,
    boolean includeEditableText
)

Returns whether the node's text contains exactly the given textValues 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
@NonNull String textValues

List of values to match (the order does not matter)

boolean includeEditableText

Whether to also assert against the editable text

See also
Text
EditableText

isDialog

public static final @NonNull SemanticsMatcher 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.

See also
IsDialog

isEnabled

public static final @NonNull SemanticsMatcher isEnabled()

Returns whether the node is enabled.

See also
Disabled

isFocusable

public static final @NonNull SemanticsMatcher isFocusable()

Return whether the node is able to receive focus

See also
Focused

isFocused

public static final @NonNull SemanticsMatcher isFocused()

Returns whether the node is focused.

See also
Focused

isHeading

public static final @NonNull SemanticsMatcher isHeading()

Returns whether the node is marked as an accessibility header.

See also
Heading

isNotEnabled

public static final @NonNull SemanticsMatcher isNotEnabled()

Returns whether the node is not enabled.

See also
Disabled

isNotFocusable

public static final @NonNull SemanticsMatcher isNotFocusable()

Return whether the node is not able to receive focus.

See also
Focused

isNotFocused

public static final @NonNull SemanticsMatcher isNotFocused()

Returns whether the node is not focused.

See also
Focused

isNotSelected

public static final @NonNull SemanticsMatcher isNotSelected()

Returns whether the node is not selected.

See also
Selected

isOff

public static final @NonNull SemanticsMatcher isOff()

Returns whether the node is not toggled.

See also
ToggleableState

isOn

public static final @NonNull SemanticsMatcher isOn()

Returns whether the node is toggled.

See also
ToggleableState

isPopup

public static final @NonNull SemanticsMatcher 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.

See also
IsPopup

isRoot

public static final @NonNull SemanticsMatcher isRoot()

Return whether the node is the root semantics node.

There is always one root in every node tree, added implicitly by Compose.

isSelectable

public static final @NonNull SemanticsMatcher isSelectable()

Return whether the node is selectable.

See also
Selected

isSelected

public static final @NonNull SemanticsMatcher isSelected()

Returns whether the node is selected.

See also
Selected

isToggleable

public static final @NonNull SemanticsMatcher isToggleable()

Return whether the node is checkable.

See also
ToggleableState