AppListener

interface AppListener

A listener that is given to the app on initialization, in order for the app to perform operations on the keyboard.

Summary

Functions
Boolean sendContent(text: String)
Send text content to the active input connection.
Void sendMedia(
  media: AppMedia,
  fallbackToUrl: Boolean,
  ignoreContentType: Boolean,
  onResult: ((success: Boolean) -> Unit)?
)
Send media to the active input connection.
Void sendEvent(event: AppEvent)
Send app event to the host application.
Void attachInputConnection(inputConnection: InputConnection, editorInfo: EditorInfo? = null)
Set a temporary input connection.
Void releaseInputConnection()
Release temporary input connection.
Void show(otherApp: KeyboardApp? = null)(otherApp: KeyboardApp? = null)
Show frame view for app.
Boolean hide(otherApp: KeyboardApp? = null)
Hide frame view for app.
Void showFullView(view: View)
Show the given [view] as the full view covering the frame and the keyboard.
Void hideFullView()
Hide the current full view (if any).
Void onSelectionChanged(start: Int, end: Int)
Inform of a selection change inside the temporary connection.
Void onTextExtracted(text: ExtractedText?)
Inform of a text change inside an editor.

Functions

sendContent

fun sendContent(text: String): Boolean

Send text content to the active input connection.

Parameters
text: String The text content to deliver to the active input connection.
Returns
Boolean Whether the text was accepted by the underlying editor.

sendMedia

fun sendMedia(
    media: AppMedia,
    fallbackToUrl: Boolean = true,
    ignoreContentType: Boolean = false,
    onResult: ((success: Boolean) -> Unit)? = null
)

Send media to the active input connection.

Parameters
media: AppMedia The AppMedia object to deliver to the active input connection.
fallbackToUrl: Boolean Whether it should fallback to send content as url.
ignoreContentType: Boolean Whether it should try to deliver the media even when editor does not accept the given content type.
onResult: ((success: Boolean) -> Unit)? Whether the media was accepted by the underlying editor.

sendEvent

fun sendEvent(event: AppEvent)

Send app event to the host application.

Parameters
event: AppEvent The AppEvent to deliver to the host application.

attachInputConnection

fun attachInputConnection(inputConnection: InputConnection, editorInfo: EditorInfo? = null)

Set a temporary input connection.

Keyboard typing will be delivered to this input connection rather than the active input connection.

Parameters
inputConnection: InputConnection An input connection obtained from an editor.
editorInfo: EditorInfo? EditorInfo used in the input connection.

releaseInputConnection

fun releaseInputConnection()

Release temporary input connection.

show

fun show(otherApp: KeyboardApp? = null)

Show frame view for app.

Any attached frame or full view will be detached. Any previously set input connection will be cleared up.

Parameters
otherApp: KeyboardApp? The app to show. When [otherApp] is null, app becomes the keyboard app that received this listener.

hide

fun hide(otherApp: KeyboardApp? = null): Boolean

Hide frame view for app.

Hides views and clears input connection when active app matches [otherApp].

Parameters
otherApp: KeyboardApp? The app to hide. When [otherApp] is null, app becomes the current active app, which might be different from the app that received this listener.

showFullView

fun showFullView(view: View)

Show the given [view] as the full view covering the frame and the keyboard.

Parameters
view: View Show the given view as the full view covering the frame and the keyboard

hideFullView

fun hideFullView()

Hide the current full view (if any).

onSelectionChanged

fun onSelectionChanged(start: Int, end: Int)

Inform of a selection change inside the temporary connection.

Parameters
start: Int The selection start position.
end: Int The selection end position.

onTextExtracted

fun onTextExtracted(text: ExtractedText?)

Inform of a text change inside an editor.

Parameters
text: ExtractedText? The extracted text from the editor

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 June 16, 2023