Added in API level 28

SelectionEvent


class SelectionEvent : Parcelable
kotlin.Any
   ↳ android.view.textclassifier.SelectionEvent

A selection event. Specify index parameters as word token indices.

Summary

Constants
static Int

User abandoned the selection.

static Int

User copied the selection.

static Int

User cut the selection.

static Int

User dragged+dropped the selection.

static Int

User performed an action on the selection.

static Int

User typed over the selection.

static Int

User pasted over the selection.

static Int

User reset the smart selection.

static Int

User activated Select All

static Int

User shared the selection.

static Int

User clicked the textAssist menu item.

static Int

Something else other than User or the default TextClassifier triggered a selection.

static Int

User modified an existing selection.

static Int

User started a new selection.

static Int

Smart selection triggered spanning multiple tokens (words).

static Int

Smart selection triggered for a single token (word).

static Int

Selection was invoked by the user tapping on a link.

static Int

Selection was invoked by the user long pressing, double tapping, or dragging to select.

static Int

Unknown invocation method

Inherited constants
Public methods
static SelectionEvent
createSelectionActionEvent(start: Int, end: Int, actionType: Int)

Creates an event specifying an action taken on a selection.

static SelectionEvent
createSelectionActionEvent(start: Int, end: Int, actionType: Int, classification: TextClassification)

Creates an event specifying an action taken on a selection.

static SelectionEvent

Creates a "selection modified" event.

static SelectionEvent
createSelectionModifiedEvent(start: Int, end: Int, classification: TextClassification)

Creates a "selection modified" event.

static SelectionEvent
createSelectionModifiedEvent(start: Int, end: Int, selection: TextSelection)

Creates a "selection modified" event.

static SelectionEvent
createSelectionStartedEvent(invocationMethod: Int, start: Int)

Creates a "selection started" event.

Int

Boolean
equals(other: Any?)

Indicates whether some other object is "equal to" this one.

Long

Returns the duration in ms between when this event was triggered and when the previous event in the selection session was triggered.

Long

Returns the duration in ms between when this event was triggered and when the first event in the selection session was triggered.

Int

Returns the end index of this events relative to the index of the start selection event in the selection session.

String

Returns the type of entity that is associated with this event.

Int

Returns the index (e.g. 1st event, 2nd event, etc.) of this event in the selection session.

Long

Returns the time this event was triggered.

Int

Returns the type of event that was triggered.

Int

Returns the way the selection mode was invoked.

String

Returns the package name of the app that this event originated in.

String?

Returns the id of the text classifier result associated with this event.

TextClassificationSessionId?

Returns the selection session id.

Int

Returns the end index of this events relative to the index of the smart selection event in the selection session.

Int

Returns the start index of this events relative to the index of the smart selection event in the selection session.

Int

Returns the start index of this events relative to the index of the start selection event in the selection session.

String

Returns the type of widget that was involved in triggering this event.

String?

Returns a string version info for the widget this event was triggered in.

Int

static Boolean
isTerminal(eventType: Int)

Returns true if the eventType is a terminal event type.

String

Unit
writeToParcel(dest: Parcel, flags: Int)

Properties
static Parcelable.Creator<SelectionEvent!>

Constants

ACTION_ABANDON

Added in API level 28
static val ACTION_ABANDON: Int

User abandoned the selection.

Value: 107

ACTION_COPY

Added in API level 28
static val ACTION_COPY: Int

User copied the selection.

Value: 101

ACTION_CUT

Added in API level 28
static val ACTION_CUT: Int

User cut the selection.

Value: 103

ACTION_DRAG

Added in API level 28
static val ACTION_DRAG: Int

User dragged+dropped the selection.

Value: 106

ACTION_OTHER

Added in API level 28
static val ACTION_OTHER: Int

User performed an action on the selection.

Value: 108

ACTION_OVERTYPE

Added in API level 28
static val ACTION_OVERTYPE: Int

User typed over the selection.

Value: 100

ACTION_PASTE

Added in API level 28
static val ACTION_PASTE: Int

User pasted over the selection.

Value: 102

ACTION_RESET

Added in API level 28
static val ACTION_RESET: Int

User reset the smart selection.

Value: 201

ACTION_SELECT_ALL

Added in API level 28
static val ACTION_SELECT_ALL: Int

User activated Select All

Value: 200

ACTION_SHARE

Added in API level 28
static val ACTION_SHARE: Int

User shared the selection.

Value: 104

ACTION_SMART_SHARE

Added in API level 28
static val ACTION_SMART_SHARE: Int

User clicked the textAssist menu item.

Value: 105

EVENT_AUTO_SELECTION

Added in API level 28
static val EVENT_AUTO_SELECTION: Int

Something else other than User or the default TextClassifier triggered a selection.

Value: 5

EVENT_SELECTION_MODIFIED

Added in API level 28
static val EVENT_SELECTION_MODIFIED: Int

User modified an existing selection.

Value: 2

EVENT_SELECTION_STARTED

Added in API level 28
static val EVENT_SELECTION_STARTED: Int

User started a new selection.

Value: 1

EVENT_SMART_SELECTION_MULTI

Added in API level 28
static val EVENT_SMART_SELECTION_MULTI: Int

Smart selection triggered spanning multiple tokens (words).

Value: 4

EVENT_SMART_SELECTION_SINGLE

Added in API level 28
static val EVENT_SMART_SELECTION_SINGLE: Int

Smart selection triggered for a single token (word).

Value: 3
Added in API level 28
static val INVOCATION_LINK: Int

Selection was invoked by the user tapping on a link.

Value: 2

INVOCATION_MANUAL

Added in API level 28
static val INVOCATION_MANUAL: Int

Selection was invoked by the user long pressing, double tapping, or dragging to select.

Value: 1

INVOCATION_UNKNOWN

Added in API level 28
static val INVOCATION_UNKNOWN: Int

Unknown invocation method

Value: 0

Public methods

createSelectionActionEvent

Added in API level 28
static fun createSelectionActionEvent(
    start: Int,
    end: Int,
    actionType: Int
): SelectionEvent

Creates an event specifying an action taken on a selection. Use when the user clicks on an action to act on the selected text.

Parameters
start Int: the start (inclusive) index of the selection
end Int: the end (exclusive) index of the selection
actionType Int: the action that was performed on the selection Value is android.view.textclassifier.SelectionEvent#ACTION_OVERTYPE, android.view.textclassifier.SelectionEvent#ACTION_COPY, android.view.textclassifier.SelectionEvent#ACTION_PASTE, android.view.textclassifier.SelectionEvent#ACTION_CUT, android.view.textclassifier.SelectionEvent#ACTION_SHARE, android.view.textclassifier.SelectionEvent#ACTION_SMART_SHARE, android.view.textclassifier.SelectionEvent#ACTION_DRAG, android.view.textclassifier.SelectionEvent#ACTION_ABANDON, android.view.textclassifier.SelectionEvent#ACTION_OTHER, android.view.textclassifier.SelectionEvent#ACTION_SELECT_ALL, or android.view.textclassifier.SelectionEvent#ACTION_RESET
Return
SelectionEvent This value cannot be null.
Exceptions
java.lang.IllegalArgumentException if end is less than start

createSelectionActionEvent

Added in API level 28
static fun createSelectionActionEvent(
    start: Int,
    end: Int,
    actionType: Int,
    classification: TextClassification
): SelectionEvent

Creates an event specifying an action taken on a selection. Use when the user clicks on an action to act on the selected text and the selection's entity type is known.

Parameters
start Int: the start (inclusive) index of the selection
end Int: the end (exclusive) index of the selection
actionType Int: the action that was performed on the selection Value is android.view.textclassifier.SelectionEvent#ACTION_OVERTYPE, android.view.textclassifier.SelectionEvent#ACTION_COPY, android.view.textclassifier.SelectionEvent#ACTION_PASTE, android.view.textclassifier.SelectionEvent#ACTION_CUT, android.view.textclassifier.SelectionEvent#ACTION_SHARE, android.view.textclassifier.SelectionEvent#ACTION_SMART_SHARE, android.view.textclassifier.SelectionEvent#ACTION_DRAG, android.view.textclassifier.SelectionEvent#ACTION_ABANDON, android.view.textclassifier.SelectionEvent#ACTION_OTHER, android.view.textclassifier.SelectionEvent#ACTION_SELECT_ALL, or android.view.textclassifier.SelectionEvent#ACTION_RESET
classification TextClassification: the TextClassification object returned by the TextClassifier that classified the selected text This value cannot be null.
Return
SelectionEvent This value cannot be null.
Exceptions
java.lang.IllegalArgumentException If actionType is not a valid SelectionEvent actionType

createSelectionModifiedEvent

Added in API level 28
static fun createSelectionModifiedEvent(
    start: Int,
    end: Int
): SelectionEvent

Creates a "selection modified" event. Use when the user modifies the selection.

Parameters
start Int: the start (inclusive) index of the selection
end Int: the end (exclusive) index of the selection
Return
SelectionEvent This value cannot be null.
Exceptions
java.lang.IllegalArgumentException if end is less than start

createSelectionModifiedEvent

Added in API level 28
static fun createSelectionModifiedEvent(
    start: Int,
    end: Int,
    classification: TextClassification
): SelectionEvent

Creates a "selection modified" event. Use when the user modifies the selection and the selection's entity type is known.

Parameters
start Int: the start (inclusive) index of the selection
end Int: the end (exclusive) index of the selection
classification TextClassification: the TextClassification object returned by the TextClassifier that classified the selected text This value cannot be null.
Return
SelectionEvent This value cannot be null.
Exceptions
java.lang.IllegalArgumentException if end is less than start

createSelectionModifiedEvent

Added in API level 28
static fun createSelectionModifiedEvent(
    start: Int,
    end: Int,
    selection: TextSelection
): SelectionEvent

Creates a "selection modified" event. Use when a TextClassifier modifies the selection.

Parameters
start Int: the start (inclusive) index of the selection
end Int: the end (exclusive) index of the selection
selection TextSelection: the TextSelection object returned by the TextClassifier for the specified selection This value cannot be null.
Return
SelectionEvent This value cannot be null.
Exceptions
java.lang.IllegalArgumentException if end is less than start

createSelectionStartedEvent

Added in API level 28
static fun createSelectionStartedEvent(
    invocationMethod: Int,
    start: Int
): SelectionEvent

Creates a "selection started" event.

Parameters
invocationMethod Int: the way the selection was triggered Value is android.view.textclassifier.SelectionEvent#INVOCATION_MANUAL, android.view.textclassifier.SelectionEvent#INVOCATION_LINK, or android.view.textclassifier.SelectionEvent#INVOCATION_UNKNOWN
start Int: the index of the selected text
Return
SelectionEvent This value cannot be null.

describeContents

Added in API level 28
fun describeContents(): Int
Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

equals

Added in API level 28
fun equals(other: Any?): Boolean

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj This value may be null.
Return
Boolean true if this object is the same as the obj argument; false otherwise.

getDurationSincePreviousEvent

Added in API level 28
fun getDurationSincePreviousEvent(): Long

Returns the duration in ms between when this event was triggered and when the previous event in the selection session was triggered.

getDurationSinceSessionStart

Added in API level 28
fun getDurationSinceSessionStart(): Long

Returns the duration in ms between when this event was triggered and when the first event in the selection session was triggered.

getEnd

Added in API level 28
fun getEnd(): Int

Returns the end index of this events relative to the index of the start selection event in the selection session.

getEventIndex

Added in API level 28
fun getEventIndex(): Int

Returns the index (e.g. 1st event, 2nd event, etc.) of this event in the selection session.

getEventTime

Added in API level 28
fun getEventTime(): Long

Returns the time this event was triggered.

getInvocationMethod

Added in API level 28
fun getInvocationMethod(): Int

Returns the way the selection mode was invoked.

Return
Int Value is android.view.textclassifier.SelectionEvent#INVOCATION_MANUAL, android.view.textclassifier.SelectionEvent#INVOCATION_LINK, or android.view.textclassifier.SelectionEvent#INVOCATION_UNKNOWN

getPackageName

Added in API level 28
fun getPackageName(): String

Returns the package name of the app that this event originated in.

Return
String This value cannot be null.

getResultId

Added in API level 28
fun getResultId(): String?

Returns the id of the text classifier result associated with this event.

Return
String? This value may be null.

getSessionId

Added in API level 28
fun getSessionId(): TextClassificationSessionId?

Returns the selection session id.

Return
TextClassificationSessionId? This value may be null.

getSmartEnd

Added in API level 28
fun getSmartEnd(): Int

Returns the end index of this events relative to the index of the smart selection event in the selection session.

getSmartStart

Added in API level 28
fun getSmartStart(): Int

Returns the start index of this events relative to the index of the smart selection event in the selection session.

getStart

Added in API level 28
fun getStart(): Int

Returns the start index of this events relative to the index of the start selection event in the selection session.

getWidgetVersion

Added in API level 28
fun getWidgetVersion(): String?

Returns a string version info for the widget this event was triggered in.

Return
String? This value may be null.

hashCode

Added in API level 28
fun hashCode(): Int
Return
Int a hash code value for this object.

toString

Added in API level 28
fun toString(): String
Return
String a string representation of the object.

writeToParcel

Added in API level 28
fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit
Parameters
dest Parcel: The Parcel in which the object should be written. This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Properties

CREATOR

Added in API level 28
static val CREATOR: Parcelable.Creator<SelectionEvent!>