AccessibilityNodeProviderCompat

Added in 1.1.0

class AccessibilityNodeProviderCompat


Helper for accessing android.view.accessibility.AccessibilityNodeProvider.

Consider using a , a utility extension of AccessibilityNodeProvider, to simplify many aspects of providing information to accessibility services and managing accessibility focus.

Summary

Constants

const Int

The virtual id for the hosting View.

Public constructors

Creates a new instance.

Creates a new instance wrapping an android.view.accessibility.AccessibilityNodeProvider.

Public functions

Unit
addExtraDataToAccessibilityNodeInfo(
    virtualViewId: Int,
    info: AccessibilityNodeInfoCompat,
    extraDataKey: String,
    arguments: Bundle?
)

Adds extra data to an AccessibilityNodeInfoCompat based on an explicit request for the additional data.

AccessibilityNodeInfoCompat?

Returns an AccessibilityNodeInfoCompat representing a virtual view, i.e. a descendant of the host View, with the given virtualViewId or the host View itself if virtualViewId equals to HOST_VIEW_ID.

(Mutable)List<AccessibilityNodeInfoCompat!>?
findAccessibilityNodeInfosByText(text: String, virtualViewId: Int)

Finds AccessibilityNodeInfoCompats by text.

AccessibilityNodeInfoCompat?
findFocus(focus: Int)

Find the virtual view, i.e. a descendant of the host View, that has the specified focus type.

Any?
Boolean
performAction(virtualViewId: Int, action: Int, arguments: Bundle?)

Performs an accessibility action on a virtual view, i.e. a descendant of the host View, with the given virtualViewId or the host View itself if virtualViewId equals to HOST_VIEW_ID.

Constants

HOST_VIEW_ID

Added in 1.1.0
const val HOST_VIEW_ID = -1: Int

The virtual id for the hosting View.

Public constructors

AccessibilityNodeProviderCompat

Added in 1.1.0
AccessibilityNodeProviderCompat()

Creates a new instance.

AccessibilityNodeProviderCompat

Added in 1.1.0
AccessibilityNodeProviderCompat(provider: Any?)

Creates a new instance wrapping an android.view.accessibility.AccessibilityNodeProvider.

Parameters
provider: Any?

The provider.

Public functions

addExtraDataToAccessibilityNodeInfo

Added in 1.5.0
fun addExtraDataToAccessibilityNodeInfo(
    virtualViewId: Int,
    info: AccessibilityNodeInfoCompat,
    extraDataKey: String,
    arguments: Bundle?
): Unit

Adds extra data to an AccessibilityNodeInfoCompat based on an explicit request for the additional data.

This method only needs to be implemented if a virtual view offers to provide additional data.

Parameters
virtualViewId: Int

The virtual view id used to create the node

info: AccessibilityNodeInfoCompat

The info to which to add the extra data

extraDataKey: String

A key specifying the type of extra data to add to the info. The extra data should be added to the Bundle returned by the info's getExtras method.

arguments: Bundle?

A Bundle holding any arguments relevant for this request.

createAccessibilityNodeInfo

Added in 1.1.0
fun createAccessibilityNodeInfo(virtualViewId: Int): AccessibilityNodeInfoCompat?

Returns an AccessibilityNodeInfoCompat representing a virtual view, i.e. a descendant of the host View, with the given virtualViewId or the host View itself if virtualViewId equals to HOST_VIEW_ID.

A virtual descendant is an imaginary View that is reported as a part of the view hierarchy for accessibility purposes. This enables custom views that draw complex content to report them selves as a tree of virtual views, thus conveying their logical structure.

The implementer is responsible for obtaining an accessibility node info from the pool of reusable instances and setting the desired properties of the node info before returning it.

Parameters
virtualViewId: Int

A client defined virtual view id.

Returns
AccessibilityNodeInfoCompat?

A populated AccessibilityNodeInfoCompat for a virtual descendant or the host View.

findAccessibilityNodeInfosByText

Added in 1.1.0
fun findAccessibilityNodeInfosByText(text: String, virtualViewId: Int): (Mutable)List<AccessibilityNodeInfoCompat!>?

Finds AccessibilityNodeInfoCompats by text. The match is case insensitive containment. The search is relative to the virtual view, i.e. a descendant of the host View, with the given virtualViewId or the host View itself virtualViewId equals to HOST_VIEW_ID.

Parameters
text: String

The searched text.

virtualViewId: Int

A client defined virtual view id which defined the root of the tree in which to perform the search.

Returns
(Mutable)List<AccessibilityNodeInfoCompat!>?

A list of node info.

findFocus

Added in 1.1.0
fun findFocus(focus: Int): AccessibilityNodeInfoCompat?

Find the virtual view, i.e. a descendant of the host View, that has the specified focus type.

Parameters
focus: Int

The focus to find. One of FOCUS_INPUT or FOCUS_ACCESSIBILITY.

Returns
AccessibilityNodeInfoCompat?

The node info of the focused view or null.

getProvider

Added in 1.1.0
fun getProvider(): Any?

performAction

Added in 1.1.0
fun performAction(virtualViewId: Int, action: Int, arguments: Bundle?): Boolean

Performs an accessibility action on a virtual view, i.e. a descendant of the host View, with the given virtualViewId or the host View itself if virtualViewId equals to HOST_VIEW_ID.

Parameters
virtualViewId: Int

A client defined virtual view id.

action: Int

The action to perform.

arguments: Bundle?

Optional arguments.

Returns
Boolean

True if the action was performed.