HandwritingGesture


public abstract class HandwritingGesture
extends Object

java.lang.Object
   ↳ android.view.inputmethod.HandwritingGesture
InsertGesture A sub-class of HandwritingGesture for inserting text at the defined insertion point. 
InsertModeGesture A sub-class of HandwritingGesture for starting an insert mode which inserts a space in the editor to let users hand write freely at the designated insertion point. 
JoinOrSplitGesture A subclass of HandwritingGesture for deleting or inserting whitespace in text. 
PreviewableHandwritingGesture A HandwritingGesture that can be previewed
RemoveSpaceGesture A subclass of HandwritingGesture for removing whitespace from text. 
DeleteGesture A sub-class of HandwritingGesture for deleting an area of text using single rectangle. 
DeleteRangeGesture A subclass of HandwritingGesture for deleting a range of text by defining start and end rectangles. 
SelectGesture A sub-class of HandwritingGesture for selecting an area of text using single rectangle. 
SelectRangeGesture A subclass of HandwritingGesture for selecting a range of text by defining start and end rectangles. 


Base class for stylus handwriting gestures.

During a stylus handwriting session, user can perform a stylus gesture operation like SelectGesture, DeleteGesture, InsertGesture on an area of text. IME is responsible for listening to stylus MotionEvents using InputMethodService.onStylusHandwritingMotionEvent and interpret if it can translate to a gesture operation.

While creating gesture operations SelectGesture and DeleteGesture, Granularity helps pick the correct granular level of text like word level GRANULARITY_WORD, or character level GRANULARITY_CHARACTER.

Summary

Constants

int GRANULARITY_CHARACTER

Operate on text per character basis.

int GRANULARITY_WORD

Operate text per word basis.

Public methods

final String getFallbackText()

The fallback text that will be committed at current cursor position if there is no applicable text beneath the area of gesture.

Inherited methods

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

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

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Constants

GRANULARITY_CHARACTER

Added in API level 34
public static final int GRANULARITY_CHARACTER

Operate on text per character basis. i.e. each character is selected based on its intersection with selection rectangle.

Strategy of operating at a granular level is maintained in the UI toolkit. A character/word/line is included if its center is within the gesture rectangle. e.g. if a selection RectF with GRANULARITY_CHARACTER includes width-wise center of the character, it should be selected. Similarly, text in a line should be included in the operation if rectangle includes line height center.

Constant Value: 2 (0x00000002)

GRANULARITY_WORD

Added in API level 34
public static final int GRANULARITY_WORD

Operate text per word basis. e.g. if selection includes width-wise center of the word, whole word is selected.

Strategy of operating at a granular level is maintained in the UI toolkit. A character/word/line is included if its center is within the gesture rectangle. e.g. if a selection RectF with GRANULARITY_WORD includes width-wise center of the word, it should be selected. Similarly, text in a line should be included in the operation if rectangle includes line height center.

Refer to https://www.unicode.org/reports/tr29/#Word_Boundaries for more detail on how word breaks are decided.

Constant Value: 1 (0x00000001)

Public methods

getFallbackText

Added in API level 34
public final String getFallbackText ()

The fallback text that will be committed at current cursor position if there is no applicable text beneath the area of gesture. For example, select can fail if gesture is drawn over area that has no text beneath. example 2: join can fail if the gesture is drawn over text but there is no whitespace.

Returns
String This value may be null.