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.

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

int ACTION_ABANDON

User abandoned the selection.

Constant Value: 107 (0x0000006b)

ACTION_COPY

int ACTION_COPY

User copied the selection.

Constant Value: 101 (0x00000065)

ACTION_CUT

int ACTION_CUT

User cut the selection.

Constant Value: 103 (0x00000067)

ACTION_DRAG

int ACTION_DRAG

User dragged+dropped the selection.

Constant Value: 106 (0x0000006a)

ACTION_OTHER

int ACTION_OTHER

User performed an action on the selection.

Constant Value: 108 (0x0000006c)

ACTION_OVERTYPE

int ACTION_OVERTYPE

User typed over the selection.

Constant Value: 100 (0x00000064)

ACTION_PASTE

int ACTION_PASTE

User pasted over the selection.

Constant Value: 102 (0x00000066)

ACTION_RESET

int ACTION_RESET

User reset the smart selection.

Constant Value: 201 (0x000000c9)

ACTION_SELECT_ALL

int ACTION_SELECT_ALL

User activated Select All

Constant Value: 200 (0x000000c8)

ACTION_SHARE

int ACTION_SHARE

User shared the selection.

Constant Value: 104 (0x00000068)

ACTION_SMART_SHARE

int ACTION_SMART_SHARE

User clicked the textAssist menu item.

Constant Value: 105 (0x00000069)

EVENT_AUTO_SELECTION

int EVENT_AUTO_SELECTION

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

Constant Value: 5 (0x00000005)

EVENT_SELECTION_MODIFIED

int EVENT_SELECTION_MODIFIED

User modified an existing selection.

Constant Value: 2 (0x00000002)

EVENT_SELECTION_STARTED

int EVENT_SELECTION_STARTED

User started a new selection.

Constant Value: 1 (0x00000001)

EVENT_SMART_SELECTION_MULTI

int EVENT_SMART_SELECTION_MULTI

Smart selection triggered spanning multiple tokens (words).

Constant Value: 4 (0x00000004)

EVENT_SMART_SELECTION_SINGLE

int EVENT_SMART_SELECTION_SINGLE

Smart selection triggered for a single token (word).

Constant Value: 3 (0x00000003)

INVOCATION_LINK

int INVOCATION_LINK

Selection was invoked by the user tapping on a link.

Constant Value: 2 (0x00000002)

INVOCATION_MANUAL

int INVOCATION_MANUAL

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

Constant Value: 1 (0x00000001)

INVOCATION_UNKNOWN

int INVOCATION_UNKNOWN

Unknown invocation method

Constant Value: 0 (0x00000000)

Fields

Public methods

createSelectionActionEvent

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

Returns
SelectionEvent

This value will never be null.

Throws
IllegalArgumentException if end is less than start

createSelectionActionEvent

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

classification TextClassification: the TextClassification object returned by the TextClassifier that classified the selected text

This value must never be null.

Returns
SelectionEvent

This value will never be null.

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

createSelectionModifiedEvent

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 will never be null.

Throws
IllegalArgumentException if end is less than start

createSelectionModifiedEvent

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 must never be null.

Returns
SelectionEvent

This value will never be null.

Throws
IllegalArgumentException if end is less than start

createSelectionModifiedEvent

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 must never be null.

Returns
SelectionEvent

This value will never be null.

Throws
IllegalArgumentException if end is less than start

createSelectionStartedEvent

SelectionEvent createSelectionStartedEvent (int invocationMethod, 
                int start)

Creates a "selection started" event.

Parameters
invocationMethod int: the way the selection was triggered

start int: the index of the selected text

Returns
SelectionEvent

This value will never be null.

describeContents

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(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.

equals

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.

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).

Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

Parameters
obj Object: the reference object with which to compare.

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

getDurationSincePreviousEvent

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

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

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

String getEntityType ()

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

Returns
String

Value is TYPE_UNKNOWN, TYPE_OTHER, TYPE_EMAIL, TYPE_PHONE, TYPE_ADDRESS, TYPE_URL, TYPE_DATE, TYPE_DATE_TIME or TYPE_FLIGHT_NUMBER.

This value will never be null.

getEventIndex

int getEventIndex ()

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

Returns
int

getEventTime

long getEventTime ()

Returns the time this event was triggered.

Returns
long

getEventType

int getEventType ()

Returns the type of event that was triggered. e.g. ACTION_COPY.

Returns
int

getInvocationMethod

int getInvocationMethod ()

Returns the way the selection mode was invoked.

Returns
int

getPackageName

String getPackageName ()

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

Returns
String

This value will never be null.

getResultId

String getResultId ()

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

Returns
String

This value may be null.

getSessionId

TextClassificationSessionId getSessionId ()

Returns the selection session id.

Returns
TextClassificationSessionId

This value may be null.

getSmartEnd

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

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

int getStart ()

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

Returns
int

getWidgetType

String getWidgetType ()

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

Returns
String

This value will never be null.

getWidgetVersion

String getWidgetVersion ()

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

Returns
String

This value may be null.

hashCode

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(Object) 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(java.lang.Object) 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.

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the Java™ programming language.)

Returns
int a hash code value for this object.

isTerminal

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

Returns
boolean

toString

String toString ()

Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Returns
String a string representation of the object.

writeToParcel

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.

flags int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.