SelectionEvent


public final class SelectionEvent
extends Object implements Parcelable

java.lang.Object
   ↳ android.view.textclassifier.SelectionEvent


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

Summary

Constants

int ACTION_ABANDON

User abandoned the selection.

int ACTION_COPY

User copied the selection.

int ACTION_CUT

User cut the selection.

int ACTION_DRAG

User dragged+dropped the selection.

int ACTION_OTHER

User performed an action on the selection.

int ACTION_OVERTYPE

User typed over the selection.

int ACTION_PASTE

User pasted over the selection.

int ACTION_RESET

User reset the smart selection.

int ACTION_SELECT_ALL

User activated Select All

int ACTION_SHARE

User shared the selection.

int ACTION_SMART_SHARE

User clicked the textAssist menu item.

int EVENT_AUTO_SELECTION

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

int EVENT_SELECTION_MODIFIED

User modified an existing selection.

int EVENT_SELECTION_STARTED

User started a new selection.

int EVENT_SMART_SELECTION_MULTI

Smart selection triggered spanning multiple tokens (words).

int EVENT_SMART_SELECTION_SINGLE

Smart selection triggered for a single token (word).

int INVOCATION_LINK

Selection was invoked by the user tapping on a link.

int INVOCATION_MANUAL

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

int INVOCATION_UNKNOWN

Unknown invocation method

Inherited constants

Fields

public static final Creator<SelectionEvent> CREATOR

Public methods

static SelectionEvent createSelectionActionEvent(int start, int end, int actionType)

Creates an event specifying an action taken on a selection.

static SelectionEvent createSelectionActionEvent(int start, int end, int actionType, TextClassification classification)

Creates an event specifying an action taken on a selection.

static SelectionEvent createSelectionModifiedEvent(int start, int end)

Creates a "selection modified" event.

static SelectionEvent createSelectionModifiedEvent(int start, int end, TextClassification classification)

Creates a "selection modified" event.

static SelectionEvent createSelectionModifiedEvent(int start, int end, TextSelection selection)

Creates a "selection modified" event.

static SelectionEvent createSelectionStartedEvent(int invocationMethod, int start)

Creates a "selection started" event.

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

boolean equals(Object obj)

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

long getDurationSincePreviousEvent()

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

long getDurationSinceSessionStart()

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

int getEnd()

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

String getEntityType()

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

int getEventIndex()

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

long getEventTime()

Returns the time this event was triggered.

int getEventType()

Returns the type of event that was triggered.

int getInvocationMethod()

Returns the way the selection mode was invoked.

String getPackageName()

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

String getResultId()

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

TextClassificationSessionId getSessionId()

Returns the selection session id.

int getSmartEnd()

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

int getSmartStart()

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

int getStart()

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

String getWidgetType()

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

String getWidgetVersion()

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

int hashCode()

Returns a hash code value for the object.

static boolean isTerminal(int eventType)

Returns true if the eventType is a terminal event type.

String toString()

Returns a string representation of the object.

void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

Constants

ACTION_ABANDON

Added in API level 28
public static final int ACTION_ABANDON

User abandoned the selection.

Constant Value: 107 (0x0000006b)

ACTION_COPY

Added in API level 28
public static final int ACTION_COPY

User copied the selection.

Constant Value: 101 (0x00000065)

ACTION_CUT

Added in API level 28
public static final int ACTION_CUT

User cut the selection.

Constant Value: 103 (0x00000067)

ACTION_DRAG

Added in API level 28
public static final int ACTION_DRAG

User dragged+dropped the selection.

Constant Value: 106 (0x0000006a)

ACTION_OTHER

Added in API level 28
public static final int ACTION_OTHER

User performed an action on the selection.

Constant Value: 108 (0x0000006c)

ACTION_OVERTYPE

Added in API level 28
public static final int ACTION_OVERTYPE

User typed over the selection.

Constant Value: 100 (0x00000064)

ACTION_PASTE

Added in API level 28
public static final int ACTION_PASTE

User pasted over the selection.

Constant Value: 102 (0x00000066)

ACTION_RESET

Added in API level 28
public static final int ACTION_RESET

User reset the smart selection.

Constant Value: 201 (0x000000c9)

ACTION_SELECT_ALL

Added in API level 28
public static final int ACTION_SELECT_ALL

User activated Select All

Constant Value: 200 (0x000000c8)

ACTION_SHARE

Added in API level 28
public static final int ACTION_SHARE

User shared the selection.

Constant Value: 104 (0x00000068)

ACTION_SMART_SHARE

Added in API level 28
public static final int ACTION_SMART_SHARE

User clicked the textAssist menu item.

Constant Value: 105 (0x00000069)

EVENT_AUTO_SELECTION

Added in API level 28
public static final int EVENT_AUTO_SELECTION

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

Constant Value: 5 (0x00000005)

EVENT_SELECTION_MODIFIED

Added in API level 28
public static final int EVENT_SELECTION_MODIFIED

User modified an existing selection.

Constant Value: 2 (0x00000002)

EVENT_SELECTION_STARTED

Added in API level 28
public static final int EVENT_SELECTION_STARTED

User started a new selection.

Constant Value: 1 (0x00000001)

EVENT_SMART_SELECTION_MULTI

Added in API level 28
public static final int EVENT_SMART_SELECTION_MULTI

Smart selection triggered spanning multiple tokens (words).

Constant Value: 4 (0x00000004)

EVENT_SMART_SELECTION_SINGLE

Added in API level 28
public static final int EVENT_SMART_SELECTION_SINGLE

Smart selection triggered for a single token (word).

Constant Value: 3 (0x00000003)

Added in API level 28
public static final int INVOCATION_LINK

Selection was invoked by the user tapping on a link.

Constant Value: 2 (0x00000002)

INVOCATION_MANUAL

Added in API level 28
public static final int INVOCATION_MANUAL

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

Constant Value: 1 (0x00000001)

INVOCATION_UNKNOWN

Added in API level 28
public static final int INVOCATION_UNKNOWN

Unknown invocation method

Constant Value: 0 (0x00000000)

Fields

CREATOR

Added in API level 28
public static final Creator<SelectionEvent> CREATOR

Public methods

createSelectionActionEvent

Added in API level 28
public static SelectionEvent createSelectionActionEvent (int start, 
                int end, 
                int actionType)

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 ACTION_OVERTYPE, ACTION_COPY, ACTION_PASTE, ACTION_CUT, ACTION_SHARE, ACTION_SMART_SHARE, ACTION_DRAG, ACTION_ABANDON, ACTION_OTHER, ACTION_SELECT_ALL, or ACTION_RESET

Returns
SelectionEvent This value cannot be null.

Throws
IllegalArgumentException if end is less than start

createSelectionActionEvent

Added in API level 28
public static SelectionEvent createSelectionActionEvent (int start, 
                int end, 
                int actionType, 
                TextClassification classification)

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 ACTION_OVERTYPE, ACTION_COPY, ACTION_PASTE, ACTION_CUT, ACTION_SHARE, ACTION_SMART_SHARE, ACTION_DRAG, ACTION_ABANDON, ACTION_OTHER, ACTION_SELECT_ALL, or ACTION_RESET

classification TextClassification: the TextClassification object returned by the TextClassifier that classified the selected text This value cannot be null.

Returns
SelectionEvent This value cannot be null.

Throws
IllegalArgumentException if end is less than start
IllegalArgumentException If actionType is not a valid SelectionEvent actionType

createSelectionModifiedEvent

Added in API level 28
public static SelectionEvent createSelectionModifiedEvent (int start, 
                int end)

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

Returns
SelectionEvent This value cannot be null.

Throws
IllegalArgumentException if end is less than start

createSelectionModifiedEvent

Added in API level 28
public static SelectionEvent createSelectionModifiedEvent (int start, 
                int end, 
                TextClassification classification)

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.

Returns
SelectionEvent This value cannot be null.

Throws
IllegalArgumentException if end is less than start

createSelectionModifiedEvent

Added in API level 28
public static SelectionEvent createSelectionModifiedEvent (int start, 
                int end, 
                TextSelection selection)

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.

Returns
SelectionEvent This value cannot be null.

Throws
IllegalArgumentException if end is less than start

createSelectionStartedEvent

Added in API level 28
public static SelectionEvent createSelectionStartedEvent (int invocationMethod, 
                int start)

Creates a "selection started" event.

Parameters
invocationMethod int: the way the selection was triggered Value is INVOCATION_MANUAL, INVOCATION_LINK, or INVOCATION_UNKNOWN

start int: the index of the selected text

Returns
SelectionEvent This value cannot be null.

describeContents

Added in API level 28
public int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(android.os.Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR

equals

Added in API level 28
public boolean equals (Object obj)

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 Object: This value may be null.

Returns
boolean true if this object is the same as the obj argument; false otherwise.

getDurationSincePreviousEvent

Added in API level 28
public long getDurationSincePreviousEvent ()

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

Returns
long

getDurationSinceSessionStart

Added in API level 28
public long getDurationSinceSessionStart ()

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

Returns
long

getEnd

Added in API level 28
public int getEnd ()

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

Returns
int

getEntityType

Added in API level 28
public String getEntityType ()

Returns the type of entity that is associated with this event. e.g. TextClassifier.TYPE_EMAIL.

Returns
String Value is TextClassifier.TYPE_UNKNOWN, TextClassifier.TYPE_OTHER, TextClassifier.TYPE_EMAIL, TextClassifier.TYPE_PHONE, TextClassifier.TYPE_ADDRESS, TextClassifier.TYPE_URL, TextClassifier.TYPE_DATE, TextClassifier.TYPE_DATE_TIME, TextClassifier.TYPE_FLIGHT_NUMBER, or android.view.textclassifier.TextClassifier.TYPE_DICTIONARY This value cannot be null.

getEventIndex

Added in API level 28
public int getEventIndex ()

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

Returns
int

getEventTime

Added in API level 28
public long getEventTime ()

Returns the time this event was triggered.

Returns
long

getInvocationMethod

Added in API level 28
public int getInvocationMethod ()

Returns the way the selection mode was invoked.

Returns
int Value is INVOCATION_MANUAL, INVOCATION_LINK, or INVOCATION_UNKNOWN

getPackageName

Added in API level 28
public String getPackageName ()

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

Returns
String This value cannot be null.

getResultId

Added in API level 28
public String getResultId ()

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

Returns
String This value may be null.

getSessionId

Added in API level 28
public TextClassificationSessionId getSessionId ()

Returns the selection session id.

Returns
TextClassificationSessionId This value may be null.

getSmartEnd

Added in API level 28
public int getSmartEnd ()

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

Returns
int

getSmartStart

Added in API level 28
public int getSmartStart ()

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

Returns
int

getStart

Added in API level 28
public int getStart ()

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

Returns
int

getWidgetVersion

Added in API level 28
public String getWidgetVersion ()

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

Returns
String This value may be null.

hashCode

Added in API level 28
public int hashCode ()

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

Returns
int a hash code value for this object.

isTerminal

Added in API level 28
public static boolean isTerminal (int eventType)

Returns true if the eventType is a terminal event type. Otherwise returns false. A terminal event is an event that ends a selection interaction.

Parameters
eventType int: Value is ACTION_OVERTYPE, ACTION_COPY, ACTION_PASTE, ACTION_CUT, ACTION_SHARE, ACTION_SMART_SHARE, ACTION_DRAG, ACTION_ABANDON, ACTION_OTHER, ACTION_SELECT_ALL, ACTION_RESET, EVENT_SELECTION_STARTED, EVENT_SELECTION_MODIFIED, EVENT_SMART_SELECTION_SINGLE, EVENT_SMART_SELECTION_MULTI, or EVENT_AUTO_SELECTION

Returns
boolean

toString

Added in API level 28
public String toString ()

Returns a string representation of the object.

Returns
String a string representation of the object.

writeToParcel

Added in API level 28
public void writeToParcel (Parcel dest, 
                int flags)

Flatten this object in to a Parcel.

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.PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES