The Single Line Text Widget can operate in 3 modes: insertion, correction and box.
Insertion mode is designed to enable the user to write text in a continuous flow. The writing area scrolls automatically after a short delay, once the user has finished writing. Scrolling of the writing area is managed by the widget.
Correction mode is designed to enable the user to navigate and edit the text already entered. A cursor bar and a cursor handle are shown in the writing area. The handle can be dragged by the user directly from the writing area. The widget provides notifications when the handle is dragged, so that the input method synchronizes the movement of the cursors in the writing area and in the input field.
Box mode is designed to enable the user to write isolated characters in boxes, thanks to an ak-iso resource. Characters are recognized letter by letter, thus reducing recognition mistakes. It is useful for filling in form fields, especially with words that are not dictionary- or lexicon-related. If needed, input characters can also be hidden behind asterisks (e.g. for passwords).
The box mode is not supported by the following languages: Arabic, Farsi, Hebrew, Urdu and Thai.
Handwriting gestures are detected by the widget in correction mode. A set of listener callbacks is provided so that the input method can take action when some of the gestures are detected.
The following gestures are supported:
The widget simplifies text manipulation by providing a simple character-based method to edit the text. Whether text is represented as ink or as characters in the writing area, the widget handles all of this transparently.
A single method is provided to modify the text of the writing area:
public void replaceCharacters(int start, int end, String text).
start - Character index of the first character to replace.
end - Character index past the last character to replace.
text - Replacement text string (may be null).
This method is a versatile tool that handles text insertion, deletion and replacement.
Handwriting recognition candidate change is implemented as a simple text replacement.
In correction mode, the widget displays a cursor bar and a cursor handle in the writing area. The position of the handle is managed by the widget, while the position of the cursor bar is managed by the input method.
The input method can set the position of the cursor bar which is moved accordingly in the writing area.
When the user drags the cursor handle in the writing area, the widget notifies the input method of drag events. That way, it can move the cursor bar both in the input field and in the writing area.
Positioning the cursor inside the text automatically selects the word or character at the position of the cursor, depending on the current selection mode. This triggers a selection change event that notifies the input method of the available handwriting candidates.
The widget simplifies the setup of the handwriting recognition engine, and reconfiguration of the engine in case of language change for example.
public void configure(String locale, String resources, String lexicon, byte certificate)
locale - String representation of the handwriting recognition locale.
resources - Array of paths to handwriting resource files.
lexicon - Array of user lexicon entries. May be null.
certificate - Byte array containing the handwriting recognition certificate.
This function is non-blocking and performs configuration in the background to avoid blocking the UI thread. Listener callbacks are provided to monitor the beginning and end of the configuration process and update the UI of the input method accordingly.
A number of options are provided to customize the UI of the widget's writing area. The widget can be customized via the widget API or directly from an XML file, provided your layout uses the TextWidgetV3 widget view and links to the text-widget-v3 Android library.
The following items can be configured:
The Single Line Text Widget supports 64 languages.