AccessibilityRecord
open class AccessibilityRecord
kotlin.Any | |
↳ | android.view.accessibility.AccessibilityRecord |
Represents a record in an AccessibilityEvent
and contains information about state change of its source android.view.View
. When a view fires an accessibility event it requests from its parent to dispatch the constructed event. The parent may optionally append a record for itself for providing more context to android.accessibilityservice.AccessibilityService
s. Hence, accessibility services can facilitate additional accessibility records to enhance feedback.
Once the accessibility event containing a record is dispatched the record is made immutable and calling a state mutation method generates an error.
Note: Not all properties are applicable to all accessibility event types. For detailed information please refer to AccessibilityEvent
.
Summary
Public constructors | |
---|---|
Creates a new |
|
AccessibilityRecord(record: AccessibilityRecord) Copy constructor. |
Public methods | |
---|---|
open Int |
Gets the number of added characters. |
open CharSequence? |
Gets the text before a change. |
open CharSequence? |
Gets the class name of the source. |
open CharSequence? |
Gets the description of the source. |
open Int |
Gets the index of the source in the list of items the can be visited. |
open Int |
Gets the id of the display from which the event comes from. |
open Int |
Gets the index of the first character of the changed sequence, or the beginning of a text selection or the index of the first visible item when scrolling. |
open Int |
Gets the number of items that can be visited. |
open Int |
Gets the max scroll offset of the source left edge in pixels. |
open Int |
Gets the max scroll offset of the source top edge in pixels. |
open Parcelable? |
Gets the |
open Int |
Gets the number of removed characters. |
open Int |
Gets the difference in pixels between the horizontal position before the scroll and the current horizontal position |
open Int |
Gets the difference in pixels between the vertical position before the scroll and the current vertical position |
open Int |
Gets the scroll offset of the source left edge in pixels. |
open Int |
Gets the scroll offset of the source top edge in pixels. |
open AccessibilityNodeInfo? |
Gets the |
open AccessibilityNodeInfo? |
Gets the |
open MutableList<CharSequence!> |
getText() Gets the text of the event. |
open Int |
Gets the index of text selection end or the index of the last visible item when scrolling. |
open Int |
Gets the id of the window from which the event comes from. |
open Boolean |
Gets if the source is checked. |
open Boolean |
Gets if the source is enabled. |
open Boolean |
Gets if the source is taking the entire screen. |
open Boolean |
Gets if the source is a password field. |
open Boolean |
Gets if the source is scrollable. |
open static AccessibilityRecord |
obtain() Instantiates a new record. |
open static AccessibilityRecord |
obtain(record: AccessibilityRecord) Instantiates a new record initialized with data from the given record. |
open Unit |
recycle() Would previously return an instance back to be reused. |
open Unit |
setAddedCount(addedCount: Int) Sets the number of added characters. |
open Unit |
setBeforeText(beforeText: CharSequence?) Sets the text before a change. |
open Unit |
setChecked(isChecked: Boolean) Sets if the source is checked. |
open Unit |
setClassName(className: CharSequence?) Sets the class name of the source. |
open Unit |
setContentDescription(contentDescription: CharSequence?) Sets the description of the source. |
open Unit |
setCurrentItemIndex(currentItemIndex: Int) Sets the index of the source in the list of items that can be visited. |
open Unit |
setEnabled(isEnabled: Boolean) Sets if the source is enabled. |
open Unit |
setFromIndex(fromIndex: Int) Sets the index of the first character of the changed sequence or the beginning of a text selection or the index of the first visible item when scrolling. |
open Unit |
setFullScreen(isFullScreen: Boolean) Sets if the source is taking the entire screen. |
open Unit |
setItemCount(itemCount: Int) Sets the number of items that can be visited. |
open Unit |
setMaxScrollX(maxScrollX: Int) Sets the max scroll offset of the source left edge in pixels. |
open Unit |
setMaxScrollY(maxScrollY: Int) Sets the max scroll offset of the source top edge in pixels. |
open Unit |
setParcelableData(parcelableData: Parcelable?) Sets the |
open Unit |
setPassword(isPassword: Boolean) Sets if the source is a password field. |
open Unit |
setRemovedCount(removedCount: Int) Sets the number of removed characters. |
open Unit |
setScrollDeltaX(scrollDeltaX: Int) Sets the difference in pixels between the horizontal position before the scroll and the current horizontal position |
open Unit |
setScrollDeltaY(scrollDeltaY: Int) Sets the difference in pixels between the vertical position before the scroll and the current vertical position |
open Unit |
setScrollX(scrollX: Int) Sets the scroll offset of the source left edge in pixels. |
open Unit |
setScrollY(scrollY: Int) Sets the scroll offset of the source top edge in pixels. |
open Unit |
setScrollable(scrollable: Boolean) Sets if the source is scrollable. |
open Unit |
Sets the event source. |
open Unit |
Sets the source to be a virtual descendant of the given |
open Unit |
setToIndex(toIndex: Int) Sets the index of text selection end or the index of the last visible item when scrolling. |
open String |
toString() |
Public constructors
AccessibilityRecord
AccessibilityRecord(record: AccessibilityRecord)
Copy constructor. Creates a new AccessibilityRecord
, and this instance is initialized with data from the given record
.
Parameters | |
---|---|
record |
AccessibilityRecord: The other record. This value cannot be null . |
Public methods
getAddedCount
open fun getAddedCount(): Int
Gets the number of added characters.
Return | |
---|---|
Int |
The number of added characters. |
getBeforeText
open fun getBeforeText(): CharSequence?
Gets the text before a change.
Return | |
---|---|
CharSequence? |
The text before the change. This value may be null . |
getClassName
open fun getClassName(): CharSequence?
Gets the class name of the source.
Return | |
---|---|
CharSequence? |
The class name. This value may be null . |
getContentDescription
open fun getContentDescription(): CharSequence?
Gets the description of the source.
Return | |
---|---|
CharSequence? |
The description. This value may be null . |
getCurrentItemIndex
open fun getCurrentItemIndex(): Int
Gets the index of the source in the list of items the can be visited.
Return | |
---|---|
Int |
The current item index. |
getDisplayId
open fun getDisplayId(): Int
Gets the id of the display from which the event comes from.
Return | |
---|---|
Int |
The display id. |
getFromIndex
open fun getFromIndex(): Int
Gets the index of the first character of the changed sequence, or the beginning of a text selection or the index of the first visible item when scrolling.
Return | |
---|---|
Int |
The index of the first character or selection start or the first visible item. |
getItemCount
open fun getItemCount(): Int
Gets the number of items that can be visited.
Return | |
---|---|
Int |
The number of items. |
getMaxScrollX
open fun getMaxScrollX(): Int
Gets the max scroll offset of the source left edge in pixels.
Return | |
---|---|
Int |
The max scroll. |
getMaxScrollY
open fun getMaxScrollY(): Int
Gets the max scroll offset of the source top edge in pixels.
Return | |
---|---|
Int |
The max scroll. |
getParcelableData
open fun getParcelableData(): Parcelable?
Gets the Parcelable
data.
Return | |
---|---|
Parcelable? |
The parcelable data. This value may be null . |
getRemovedCount
open fun getRemovedCount(): Int
Gets the number of removed characters.
Return | |
---|---|
Int |
The number of removed characters. |
getScrollDeltaX
open fun getScrollDeltaX(): Int
Gets the difference in pixels between the horizontal position before the scroll and the current horizontal position
Return | |
---|---|
Int |
the scroll delta x |
getScrollDeltaY
open fun getScrollDeltaY(): Int
Gets the difference in pixels between the vertical position before the scroll and the current vertical position
Return | |
---|---|
Int |
the scroll delta y |
getScrollX
open fun getScrollX(): Int
Gets the scroll offset of the source left edge in pixels.
Return | |
---|---|
Int |
The scroll. |
getScrollY
open fun getScrollY(): Int
Gets the scroll offset of the source top edge in pixels.
Return | |
---|---|
Int |
The scroll. |
getSource
open fun getSource(): AccessibilityNodeInfo?
Gets the AccessibilityNodeInfo
of the event source.
Note: It is a client responsibility to recycle the received info by calling AccessibilityNodeInfo#recycle()
to avoid creating of multiple instances.
Return | |
---|---|
AccessibilityNodeInfo? |
The info of the source. This value may be null . |
getSource
open fun getSource(prefetchingStrategy: Int): AccessibilityNodeInfo?
Gets the AccessibilityNodeInfo
of the event source.
Return | |
---|---|
AccessibilityNodeInfo? |
The info of the source. This value may be null . |
getText
open fun getText(): MutableList<CharSequence!>
Gets the text of the event. The index in the list represents the priority of the text. Specifically, the lower the index the higher the priority.
Return | |
---|---|
MutableList<CharSequence!> |
The text. This value cannot be null . |
getToIndex
open fun getToIndex(): Int
Gets the index of text selection end or the index of the last visible item when scrolling.
Return | |
---|---|
Int |
The index of selection end or last item index. |
getWindowId
open fun getWindowId(): Int
Gets the id of the window from which the event comes from.
Return | |
---|---|
Int |
The window id. |
isChecked
open fun isChecked(): Boolean
Gets if the source is checked.
Return | |
---|---|
Boolean |
True if the view is checked, false otherwise. |
isEnabled
open fun isEnabled(): Boolean
Gets if the source is enabled.
Return | |
---|---|
Boolean |
True if the view is enabled, false otherwise. |
isFullScreen
open fun isFullScreen(): Boolean
Gets if the source is taking the entire screen.
Return | |
---|---|
Boolean |
True if the source is full screen, false otherwise. |
isPassword
open fun isPassword(): Boolean
Gets if the source is a password field.
Return | |
---|---|
Boolean |
True if the view is a password field, false otherwise. |
isScrollable
open fun isScrollable(): Boolean
Gets if the source is scrollable.
Return | |
---|---|
Boolean |
True if the source is scrollable, false otherwise. |
obtain
open static funobtain(): AccessibilityRecord
Deprecated: Object pooling has been discontinued. Create a new instance using the constructor AccessibilityRecord()
instead.
Instantiates a new record.
Return | |
---|---|
AccessibilityRecord |
An instance. This value cannot be null . |
obtain
open static funobtain(record: AccessibilityRecord): AccessibilityRecord
Deprecated: Object pooling has been discontinued. Create a new instance using the constructor AccessibilityRecord()
instead.
Instantiates a new record initialized with data from the given record.
Parameters | |
---|---|
record |
AccessibilityRecord: This value cannot be null . |
Return | |
---|---|
AccessibilityRecord |
An instance. This value cannot be null . |
recycle
open funrecycle(): Unit
Deprecated: Object pooling has been discontinued. Calling this function now will have no effect.
Would previously return an instance back to be reused.
setAddedCount
open fun setAddedCount(addedCount: Int): Unit
Sets the number of added characters.
Parameters | |
---|---|
addedCount |
Int: The number of added characters. |
Exceptions | |
---|---|
java.lang.IllegalStateException |
If called from an AccessibilityService. |
setBeforeText
open fun setBeforeText(beforeText: CharSequence?): Unit
Sets the text before a change.
Parameters | |
---|---|
beforeText |
CharSequence?: The text before the change. This value may be null . |
Exceptions | |
---|---|
java.lang.IllegalStateException |
If called from an AccessibilityService. |
setChecked
open fun setChecked(isChecked: Boolean): Unit
Sets if the source is checked.
Parameters | |
---|---|
isChecked |
Boolean: True if the view is checked, false otherwise. |
Exceptions | |
---|---|
java.lang.IllegalStateException |
If called from an AccessibilityService. |
setClassName
open fun setClassName(className: CharSequence?): Unit
Sets the class name of the source.
Parameters | |
---|---|
className |
CharSequence?: The lass name. This value may be null . |
Exceptions | |
---|---|
java.lang.IllegalStateException |
If called from an AccessibilityService. |
setContentDescription
open fun setContentDescription(contentDescription: CharSequence?): Unit
Sets the description of the source.
Parameters | |
---|---|
contentDescription |
CharSequence?: The description. This value may be null . |
Exceptions | |
---|---|
java.lang.IllegalStateException |
If called from an AccessibilityService. |
setCurrentItemIndex
open fun setCurrentItemIndex(currentItemIndex: Int): Unit
Sets the index of the source in the list of items that can be visited.
Parameters | |
---|---|
currentItemIndex |
Int: The current item index. |
Exceptions | |
---|---|
java.lang.IllegalStateException |
If called from an AccessibilityService. |
setEnabled
open fun setEnabled(isEnabled: Boolean): Unit
Sets if the source is enabled.
Parameters | |
---|---|
isEnabled |
Boolean: True if the view is enabled, false otherwise. |
Exceptions | |
---|---|
java.lang.IllegalStateException |
If called from an AccessibilityService. |
setFromIndex
open fun setFromIndex(fromIndex: Int): Unit
Sets the index of the first character of the changed sequence or the beginning of a text selection or the index of the first visible item when scrolling.
Parameters | |
---|---|
fromIndex |
Int: The index of the first character or selection start or the first visible item. |
Exceptions | |
---|---|
java.lang.IllegalStateException |
If called from an AccessibilityService. |
setFullScreen
open fun setFullScreen(isFullScreen: Boolean): Unit
Sets if the source is taking the entire screen.
Parameters | |
---|---|
isFullScreen |
Boolean: True if the source is full screen, false otherwise. |
Exceptions | |
---|---|
java.lang.IllegalStateException |
If called from an AccessibilityService. |
setItemCount
open fun setItemCount(itemCount: Int): Unit
Sets the number of items that can be visited.
Parameters | |
---|---|
itemCount |
Int: The number of items. |
Exceptions | |
---|---|
java.lang.IllegalStateException |
If called from an AccessibilityService. |
setMaxScrollX
open fun setMaxScrollX(maxScrollX: Int): Unit
Sets the max scroll offset of the source left edge in pixels.
Parameters | |
---|---|
maxScrollX |
Int: The max scroll. |
setMaxScrollY
open fun setMaxScrollY(maxScrollY: Int): Unit
Sets the max scroll offset of the source top edge in pixels.
Parameters | |
---|---|
maxScrollY |
Int: The max scroll. |
setParcelableData
open fun setParcelableData(parcelableData: Parcelable?): Unit
Sets the Parcelable
data of the event.
Parameters | |
---|---|
parcelableData |
Parcelable?: The parcelable data. This value may be null . |
Exceptions | |
---|---|
java.lang.IllegalStateException |
If called from an AccessibilityService. |
setPassword
open fun setPassword(isPassword: Boolean): Unit
Sets if the source is a password field.
Parameters | |
---|---|
isPassword |
Boolean: True if the view is a password field, false otherwise. |
Exceptions | |
---|---|
java.lang.IllegalStateException |
If called from an AccessibilityService. |
setRemovedCount
open fun setRemovedCount(removedCount: Int): Unit
Sets the number of removed characters.
Parameters | |
---|---|
removedCount |
Int: The number of removed characters. |
Exceptions | |
---|---|
java.lang.IllegalStateException |
If called from an AccessibilityService. |
setScrollDeltaX
open fun setScrollDeltaX(scrollDeltaX: Int): Unit
Sets the difference in pixels between the horizontal position before the scroll and the current horizontal position
Parameters | |
---|---|
scrollDeltaX |
Int: the scroll delta x |
setScrollDeltaY
open fun setScrollDeltaY(scrollDeltaY: Int): Unit
Sets the difference in pixels between the vertical position before the scroll and the current vertical position
Parameters | |
---|---|
scrollDeltaY |
Int: the scroll delta y |
setScrollX
open fun setScrollX(scrollX: Int): Unit
Sets the scroll offset of the source left edge in pixels.
Parameters | |
---|---|
scrollX |
Int: The scroll. |
setScrollY
open fun setScrollY(scrollY: Int): Unit
Sets the scroll offset of the source top edge in pixels.
Parameters | |
---|---|
scrollY |
Int: The scroll. |
setScrollable
open fun setScrollable(scrollable: Boolean): Unit
Sets if the source is scrollable.
Parameters | |
---|---|
scrollable |
Boolean: True if the source is scrollable, false otherwise. |
Exceptions | |
---|---|
java.lang.IllegalStateException |
If called from an AccessibilityService. |
setSource
open fun setSource(source: View?): Unit
Sets the event source.
Parameters | |
---|---|
source |
View?: The source. This value may be null . |
Exceptions | |
---|---|
java.lang.IllegalStateException |
If called from an AccessibilityService. |
setSource
open fun setSource(
root: View?,
virtualDescendantId: Int
): Unit
Sets the source to be a virtual descendant of the given root
. If virtualDescendantId
equals to View.NO_ID
the root is set as the source.
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.
Parameters | |
---|---|
root |
View?: The root of the virtual subtree. This value may be null . |
virtualDescendantId |
Int: The id of the virtual descendant. |
setToIndex
open fun setToIndex(toIndex: Int): Unit
Sets the index of text selection end or the index of the last visible item when scrolling.
Parameters | |
---|---|
toIndex |
Int: The index of selection end or last item index. |
toString
open fun toString(): String
Return | |
---|---|
String |
a string representation of the object. |