EventBus

A bus for event notifications.

The eventBus instance can be retrieved only from the KeyboardService after calling super.onCreate.

Summary

Event Description
configurationEvent A publisher for configuration related events
dictionaryEvent A publisher for dictionary related events
engineEvent A publisher for engine related events
monitorEvent A publisher for monitor related events
serviceEvent A publisher for service related events
activityEvent A publisher for activity related events
predictionsEvent A publisher for prediction events
genericDataEvent A publisher for generic data events
eventBasedDataCapture A publisher for event based data capture events

Example:

eventBus.configuration.subscribe {
    when (it) {
        is ConfigurationEvent.CurrentLanguageChanged -> {
            mySettings.setCurrentLanguage(it.locale)
        }
    }
}

ConfigurationEvent

A ConfigurationEvent is sent every time a user makes a configuration change on the keyboard through gestures or buttons. It is advised to store the configuration change in permanent storage, such as SharedPreferences and use that value in the createConfiguration method of the KeyboardService.

CurrentLanguageChanged The user switched to another language.
AutoCorrectionChanged The user toggled the auto correction setting.
LanguageNotAvailable The engine failed to load a language.

CurrentLanguageChanged

Inherits from ConfigurationEvent.

The user switched to another language from the list of userLanguages provided in the LanguageConfiguration.

data class CurrentLanguageChanged(val locale: String)

Fields:

Name Type Description
locale String The locale of the language that the user switched to.

AutoCorrectionChanged

Inherits from ConfigurationEvent.

The user toggled the auto correction.

data class AutoCorrectionChanged(val enabled: Boolean)

Fields:

Name Type Description
enabled Boolean Whether the auto correction has been enabled or not.

LanguageNotAvailable

Inherits from ConfigurationEvent.

An attempt to load a new language has failed and is not recoverable. The next language in the list of userLanguages will be loaded, falling back to the default language (en-US) when the list of available languages is empty.

Notes:

  • The brokenLocale should be removed from the userLanguages in the LanguageConfiguration upon receiving this event. No updateConfiguration call is needed.
data class LanguageNotAvailable(val brokenLocale: String, val nextLocale: String)

Fields:

Name Type Description
brokenLocale String The locale of the language that was not loaded.
nextLocale String The locale of the language that was loaded after the failed attempt.

DictionaryEvent

A DictionaryEvent is sent every time a user makes a change to the user dictionary. Chnages can happen via the suggestion gestures to add or remove a word, or via automatic learning when the user corrects words manually.

AddUserWord The user added a word to their dictionary.
RemoveUserWord The user removed a word from their dictionary.
AutoLearnedWord The engine learned a new user word automatically.

AddUserWord

Inherits from ConfigurationEvent.

The user added a new word to their dictionary.

data class AddUserWord(val word: String)
Name Type Description
word String The word that the user added

RemoveUserWord

Inherits from ConfigurationEvent.

The user removed a word from their dictionary.

data class RemoveUserWord(val word: String)
Name Type Description
word String The word that the user removed

AutoLearnedWord

Inherits from ConfigurationEvent.

The engine learned a new user word automatically. This event is sent when the user changes an autocorrected word.

data class AutoLearnedWord(val word: String)
Name Type Description
word String The word that the engine has learned automatically.

EngineEvent

An EngineEvent is sent when the engine has a new tracking message, usually for debugging purposes, when tracking is enabled in the PrivacyConfiguration.

MessageReceived The engine has sent a message for debugging purposes.
ReportAnalytics The engine has sent an analytics report related to autocorrection.

MessageReceived

Inherits from EngineEvent.

The engine sent a tracking message.

data class MessageReceived(val message: String)
Name Type Description
message String The contents of the message.

ReportAnalytics

Inherits from EngineEvent.

The engine sent an AC analytics report.

data class ReportAnalytics( 
        val languageCode: String?,
        val none: Int,
        val missingSpace: Int,
        val missTypedSpace: Int,
        val eliminated: Int,
        val transposition: Int,
        val missingTaps: Int,
        val others: Int
)
Name Type Description
languageCode String? The language code that the report is intended for.
none Int Number of words not corrected
missingSpace Int Number of corrections done due to missing a space
missTypedSpace Int Number of corrections done due to typing an unwanted space
eliminated Int Number of corrections done to eliminate characters
transposition Int Number of corrections done by changing order or characters
missingTaps Int Number of corrections done when a word misses taps (characters)
others Int Number of corrections not related to all other cases. This includes those corrected directly from the dictionary and other outcome types.

MonitorEvent

A MonitorEvent is sent when the content extraction is enabled via the MonitorConfiguration.

PartialExtraction The underlying editor sent a partial extraction
TextExtraction The underlying editor sent a non-partial extraction.
ComposingExtraction The engine sent a composition operation
ComposingCorrection The engine sent a composition correction operation
Input A soft input has been performed.
EditorChanged The current editor has changed within the keyboard.

PartialExtraction

Inherits from MonitorEvent.

The underlying editor sent a partial extraction. This event is sent when the extraction mode is set to EXTRACTED.

data class PartialExtraction(
val text: CharSequence, 
val startOffset: Int, 
val partialStartOffset: Int, 
val partialEndOffset: Int
)
Name Type Description
text CharSequence The contents of the partial extracted text.
startOffset Int The starting position within the content.
partialStartOffset Int The starting position after the startOffset where the partial extraction occurs.
partialEndOffset Int The final position after the startOffset where the partial extraction occurs.

TextExtraction

Inherits from MonitorEvent.

When the extraction mode is set to EXTRACTED, the underlying editor sends a non-partial extraction. When the extraction mode is set to AGGREGATE, the extracted text from the underlying editor has been aggregated. It is then sent as a complete text extraction.

data class TextExtraction(
val text: CharSequence, 
val startOffset: Int, 
val partialStartOffset: Int, 
val partialEndOffset: Int
)
Name Type Description
text CharSequence The contents of the extracted text.
startOffset Int The starting position within the content. In aggregate extraction mode, this value is always 0.

ComposingExtraction

Inherits from MonitorEvent.

When composing is enabled in the MonitorConfiguration, engine composing operations are delivered as events.

Notes:

  • Spaces and punctuation symbols are not composed.
  • Compositions might not reflect the entire word being edited.
data class ComposingExtraction(
val text: CharSequence, 
val start: Int, 
val end: Int
)
Name Type Description
text CharSequence The contents of the current composition.
start Int The starting position of the current composition
end Int The end position of the current composition

ComposingCorrection

Inherits from MonitorEvent.

When an auto correction is triggered during a composition, an event is sent with the correction and the previous text is used.

data class ComposingCorrection(
val corrected: CharSequence, 
val original: CharSequence
)
Name Type Description
corrected CharSequence The corrected composition that replaced the original composition
original CharSequence The original composition that has been replaced
end Int The end position of the current composition

Input

Inherits from MonitorEvent.

When a soft input operation has been performed, such as tapping a letter or spacebar button, an Input event is set, only when MonitorConfiguration has been configured to emit these events. See InputValidator for details on what labels and key codes are sent.

Note:

  • These events are sent after the operation has been performed on the underlying editor and only when the input validation passes.
data class Input(
val label: String, 
val keyCode: Int,
val startTimestamp: Long,
val endTimestamp: Long
)
Name Type Description
label String The label of the key or button pressed
keyCode Int The code point for the key or button pressed
startTimestamp Long Timestamp of the start of the event, in milliseconds
endTimestamp Long Timestamp of the end of the event, in milliseconds

EditorChanged

Inherits from MonitorEvent.

When a user switches to a temporary editor (i.e. search box inside a keyboard app), an EditorChanged event is sent with the full contents of the current editor.

Note:

  • This event is not delivered when the user changes editors within a mobile application or across mobile applications.
data class EditorChanged(
val text: String
)
Name Type Description
text String The contents of the new editor when the keyboard switched between the main editable and a temporary editable inside a keyboard app.

ServiceEvent

A ServiceEvent is a propagated event that the keyboard service receives.

PackageNameChanged The keyboard service has been opened in a new application.
CurrentThemeChanged The keyboard service has received and performed a theme change.
WindowInsetsChanged The keyboard service has received and performed a window insets change.

PackageNameChanged

Inherits from ServiceEvent.

The engine has received new editor information for a new application package.

data class PackageNameChanged(val packageName: String)
Name Type Description
packageName String The new package name.

CurrentThemeChanged

Inherits from ServiceEvent.

The engine has received and processed a theme change request.

data class CurrentThemeChanged(val theme: KeyboardTheme)
Name Type Description
theme KeyboardTheme The new theme that has been applied.

WindowInsetsChanged

Inherits from ServiceEvent.

The engine has received and processed a window insets change request.

data class WindowInsetsChanged(val windowInsets: KeyboardInsets)
Name Type Description
windowInsets KeyboardInsets The new insets applied to the keyboard window.
Note: this does not include the configured keyboard insets that are set in the KeyboardConfiguration.

ActivityEvent

An ActivityEvent is used to report user actions.

KeyboardAction A button or gesture performed on the keyboard layout.
LanguageChanged The user changed the language via a gesture.
EmojiSent The user selected an emoji from the emoji panel.
KeyboardShown The keyboard became visible.
KeyboardHidden The keyboard was hidden.
MagicHold The user pressed the magic button.
Prediction The user tapped on a prediction.

KeyboardAction

Inherits from ActivityEvent

The user performed an action or gesture on the keyboard.

data class KeyboardAction(val type: ActionType) : ActivityEvent() {
    enum class ActionType {
        BACKSPACE,
        SPACEBAR,
        MICROPHONE,
        SWIPE_LEFT,
        SWIPE_RIGHT,
        PUNCTUATION_HOLD,
        SHIFT_HOLD,
        SHOW_EMOJIS,
        SHOW_STT,
        SHOW_TRACKPAD,
        HIDE_EMOJIS,
        HIDE_TRACKPAD,
        HIDE_STT
    }
}
Name Type Description
type ActionType The action performed

LanguageChanged

Inherits from ActivityEvent

The user performed a language change via a gesture.

data class LanguageChanged(val locale: String) : ActivityEvent()
Name Type Description
locale String The locale of the new selected language

EmojiSent

Inherits from ActivityEvent

The user selected an emoji from the emoji panel. The variationSource field determines the base emoji, if any, which should be used when sending the emoji variations configuration.

data class EmojiSent(
val emoji: String, 
val variationSource: String? = null
) : ActivityEvent()
Name Type Description
emoji String The emoji that has been selected
variationSource String The variation source, if any, of the selected emoji.

KeyboardShown

Inherits from ActivityEvent

An event sent every time the input view becomes visible.

data class KeyboardShown(val start: Long) : ActivityEvent()
Name Type Description
start Long The current system timestamp, in milliseconds.

KeyboardHidden

Inherits from ActivityEvent

An event which is sent every time the input view is hidden.

data class KeyboardHidden(
val start: Long, 
val end: Long, 
val duration: Long
) : ActivityEvent()
Name Type Description
start Long The system timestamp identifying when the keyboard became visible, in milliseconds.
end Long
duration Long The duration that the view was kept visible, in milliseconds.

MagicHold

Inherits from ActivityEvent

An event sent every time the user holds down the magic button.

data class MagicHold(val icon: Icon) : ActivityEvent()
Name Type Description
icon Icon The icon that was configured for the magic button.

Prediction

Inherits from ActivityEvent

An event sent every time the user taps on a word or emoji prediction.

sealed class Prediction : ActivityEvent() {
    data class Emoji(val emoji: String) : Prediction()
    data class Word(val word: String) : Prediction()
}
Name Type Description
Emoji(emoji) String The emoji prediction content that was selected.
Word(word) String The word prediction content that was selected.

PredictionsEvent

A PredictionEvent is a propagated event for the predictions being displayed.

Note:

  • Prediction Events should only be consumed for advanced prediction management.
Suggestions A list of suggested words for the previous word.
CurrentWordPredictions A list of suggested words for the current word.
HighlightSuggestions A list of suggested words for the next word.

Suggestions

Inherits from PredictionEvent

The engine has received a list of suggestions for the previous word.

data class Suggestions(
  val suggestions: List<String>, 
  val selectedIndex: Int, 
  val type: Int
)
Name Type Description
suggestions List The suggested words
selectedIndex Int The current selected index when using suggestion gestures.
type Int The type of suggested words

Type can be any of:

  • 0 => Regular suggestions
  • 1 => Punctuation suggestions
  • 2 => Request to clear suggestions

CurrentWordPredictions

Inherits from PredictionEvent

The engine has received a list of suggestions for the current word.

data class CurrentWordPredictions(val predictions: List<Pair<String, Int>>)
Name Type Description
predictions List<Pair<String, Int>> A list of pairs of prediction word and type

Type of a prediction can be any of:

  • 0 => Entered Text directly from the user
  • 1 => Suggestion word
  • 2 => Word that the engine will autocorrect
  • 3 => Word entered by the user is the same as the one that the engine will correct
  • 4 => Emoji suggestion
  • 5 => Other

HighlightSuggestions

Inherits from PredictionEvent

The engine has received a list of suggestions and highlights for the next word or service.

data class Suggestions(val enumType: String?, val jsonString: String?)
Name Type Description
enumType String The type of suggestions
jsonString String A json encoded list of suggestions

enumType can be any of:

  • highlightEventPop
  • highlightEventKeywordMatch
  • highlightEventNSP
  • highlightEventNWP
  • highlightEventEmoji
  • highlightEventAll

GenericDataEvent

A GenericDataEvent is an event for the data captured during the session.

Session Emit an event when the sdk has received a session data.
SessionStarted Emit an event when the sdk has started a new session.
SessionEnded Emit an event when the sdk has ended an existing session.
SessionStored Emit an event when the sdk has stored a session data.

Session

This event is emitted when the SDK has received a session data. It includes the data received.

SessionStarted

This event is emitted when the SDK has started a new session. It includes the sessionId of the started event.

SessionEnded

This event is emitted when the SDK has ended an existing session. It includes the sessionId of the event that has ended.

SessionStored

This event is emitted when the SDK has stored a session data. It includes the path where the data is stored.

EventBasedDataCapture

An event that reports when the data capture system has data to report. In order to receive data you should do:

  1. Subscribe to any of the following events.
  2. Enable the DataCaptureMode from the KeyboardConfiguration.
  3. Make sure that your developer plan has this capability enabled. Make sure that your current plan supports it. Check it here: developers platform

All these events should be subscribed as any other event. An example on how to use these events is provided in our github repository.

SessionUpdateCaptureEvent Emit an event when the data in the session update has changed.
KeyStrokeCaptureEvent Emit an event when a key stroke has been pressed. (it reportes after the touch ends.)
WordCaptureEvent Emit an event when the last word has been added.
DeleteCaptureEvent Emit an event when a delete event has been triggered.
SwipeCaptureEvent Emit an event when swipe data has been created.
KeyPlaneCaptureEvent Emit an event when the key plane has changed.
StressUpdateCaptureEvent Emit an event when the stress data has been updated.

SessionUpdateCaptureEvent

Emit this event every time the data of the session has changed.

The data of this event is equal for Android and iOS. Check it here the data content.

KeyStrokeCaptureEvent

Emit an event when a key stroke has been pressed. The event is emitted when the touch ends and the system has processed it.

The data of this event is equal for Android and iOS. Check it here the data content.

WordCaptureEvent

Emit an event when the last word has been added. This means that a space after a word has been inserted, a predictions has been pressed or the autocorrection has changed the word for another one.

The data of this event is equal for Android and iOS. Check it here the data content.

DeleteCaptureEvent

Emit an event when a delete event has been triggered.

The data of this event is equal for Android and iOS. Check it here the data content.

SwipeCaptureEvent

Emit an event when swipe data has been created. After the end-user finishes the swipe typing and the word is added in the edittext.

The data of this event is equal for Android and iOS. Check it here the data content.

KeyPlaneCaptureEvent

Emit an event when the key plane has changed. Note that the keyplane might change automatically depending on the keys that you press.

The data of this event is equal for Android and iOS. Check it here the data content.

StressUpdateCaptureEvent

Emit an event when the stress data has been updated.

The data of this event is equal for Android and iOS. Check it here the data content.


If something needs to be added or if you find an error in our documentation, please let us know either on our GitHub or Discord.

Last updated on May 22, 2024