BaseInputConnection
open class BaseInputConnection : InputConnection
| kotlin.Any | |
| ↳ | android.view.inputmethod.BaseInputConnection |
Base class for implementors of the InputConnection interface, taking care of most of the common behavior for providing a connection to an Editable. Implementors of this class will want to be sure to implement getEditable to provide access to their own editable object, and to refer to the documentation in InputConnection.
Summary
Inherited constants |
|
|---|---|
Public constructors |
|
|---|---|
Public methods |
|
|---|---|
| open Boolean |
Default implementation does nothing. |
| open Boolean |
clearMetaKeyStates(states: Int)Default implementation uses |
| open Unit |
Default implementation calls |
| open Boolean |
commitCompletion(text: CompletionInfo!)Default implementation does nothing and returns false. |
| open Boolean |
commitContent(inputContentInfo: InputContentInfo, flags: Int, opts: Bundle?)The default implementation does nothing. |
| open Boolean |
commitCorrection(correctionInfo: CorrectionInfo!)Default implementation does nothing and returns false. |
| open Boolean |
commitText(text: CharSequence!, newCursorPosition: Int)Default implementation replaces any existing composing text with the given text. |
| open Boolean |
deleteSurroundingText(beforeLength: Int, afterLength: Int)The default implementation performs the deletion around the current selection position of the editable text. |
| open Boolean |
deleteSurroundingTextInCodePoints(beforeLength: Int, afterLength: Int)The default implementation performs the deletion around the current selection position of the editable text. |
| open Boolean |
Default implementation does nothing. |
| open Boolean |
The default implementation removes the composing state from the current editable text. |
| open static Int |
getComposingSpanEnd(text: Spannable!) |
| open static Int |
getComposingSpanStart(text: Spannable!) |
| open Int |
getCursorCapsMode(reqModes: Int)The default implementation uses TextUtils. |
| open Editable! |
Return the target of edit operations. |
| open ExtractedText! |
getExtractedText(request: ExtractedTextRequest!, flags: Int)The default implementation always returns null. |
| open Handler! | |
| open CharSequence! |
getSelectedText(flags: Int)The default implementation returns the text currently selected, or null if none is selected. |
| open CharSequence! |
getTextAfterCursor(length: Int, flags: Int)The default implementation returns the given amount of text from the current cursor position in the buffer. |
| open CharSequence! |
getTextBeforeCursor(length: Int, flags: Int)The default implementation returns the given amount of text from the current cursor position in the buffer. |
| open Boolean |
The default implementation does nothing. |
| open Boolean |
performEditorAction(actionCode: Int)The default implementation turns this into the enter key. |
| open Boolean |
performPrivateCommand(action: String!, data: Bundle!)The default implementation does nothing. |
| static Unit |
removeComposingSpans(text: Spannable!) |
| open Boolean |
reportFullscreenMode(enabled: Boolean)Updates InputMethodManager with the current fullscreen mode. |
| open Boolean |
requestCursorUpdates(cursorUpdateMode: Int)The default implementation does nothing. |
| open Boolean |
sendKeyEvent(event: KeyEvent!)Provides standard implementation for sending a key event to the window attached to the input connection's view. |
| open Boolean |
setComposingRegion(start: Int, end: Int) |
| open static Unit |
setComposingSpans(text: Spannable!) |
| open Boolean |
setComposingText(text: CharSequence!, newCursorPosition: Int)The default implementation places the given text into the editable, replacing any existing composing text. |
| open Boolean |
setSelection(start: Int, end: Int)The default implementation changes the selection position in the current editable text. |
Public constructors
Public methods
beginBatchEdit
open fun beginBatchEdit(): Boolean
Default implementation does nothing.
| Return | |
|---|---|
Boolean |
true if a batch edit is now in progress, false otherwise. Since this method starts a batch edit, that means it will always return true unless the input connection is no longer valid. |
clearMetaKeyStates
open fun clearMetaKeyStates(states: Int): Boolean
Default implementation uses MetaKeyKeyListener#clearMetaKeyState(long, int) to clear the state.
| Parameters | |
|---|---|
states |
Int: The states to be cleared, may be one or more bits as per KeyEvent#getMetaState(). |
| Return | |
|---|---|
Boolean |
true on success, false if the input connection is no longer valid. |
closeConnection
open fun closeConnection(): Unit
Default implementation calls finishComposingText().
If you override this method you must call through to the superclass implementation.
commitCompletion
open fun commitCompletion(text: CompletionInfo!): Boolean
Default implementation does nothing and returns false.
| Parameters | |
|---|---|
text |
CompletionInfo!: The committed completion. |
| Return | |
|---|---|
Boolean |
true on success, false if the input connection is no longer valid. |
commitContent
open fun commitContent(
inputContentInfo: InputContentInfo,
flags: Int,
opts: Bundle?
): Boolean
The default implementation does nothing.
| Parameters | |
|---|---|
inputContentInfo |
InputContentInfo: Content to be inserted. This value cannot be null. |
flags |
Int: INPUT_CONTENT_GRANT_READ_URI_PERMISSION if the content provider allows grantUriPermissions or 0 if the application does not need to call InputContentInfo#requestPermission(). |
opts |
Bundle?: optional bundle data. This can be null. This value may be null. |
| Return | |
|---|---|
Boolean |
true if this request is accepted by the application, whether the request is already handled or still being handled in background, false otherwise. |
commitCorrection
open fun commitCorrection(correctionInfo: CorrectionInfo!): Boolean
Default implementation does nothing and returns false.
| Parameters | |
|---|---|
correctionInfo |
CorrectionInfo!: Detailed information about the correction. |
| Return | |
|---|---|
Boolean |
true on success, false if the input connection is no longer valid. In android.os.Build.VERSION_CODES#N and later, returns false when the target application does not implement this method. |
commitText
open fun commitText(
text: CharSequence!,
newCursorPosition: Int
): Boolean
Default implementation replaces any existing composing text with the given text. In addition, only if dummy mode, a key event is sent for the new text and the current editable buffer cleared.
| Parameters | |
|---|---|
text |
CharSequence!: The text to commit. This may include styles. |
newCursorPosition |
Int: The new cursor position around the text, in Java characters. If > 0, this is relative to the end of the text - 1; if <= 0, this is relative to the start of the text. So a value of 1 will always advance the cursor to the position after the full text being inserted. Note that this means you can't position the cursor within the text, because the editor can make modifications to the text you are providing so it is not possible to correctly specify locations there. |
| Return | |
|---|---|
Boolean |
true on success, false if the input connection is no longer valid. |
deleteSurroundingText
open fun deleteSurroundingText(
beforeLength: Int,
afterLength: Int
): Boolean
The default implementation performs the deletion around the current selection position of the editable text.
| Parameters | |
|---|---|
beforeLength |
Int: The number of characters before the cursor to be deleted, in code unit. If this is greater than the number of existing characters between the beginning of the text and the cursor, then this method does not fail but deletes all the characters in that range. |
afterLength |
Int: The number of characters after the cursor to be deleted, in code unit. If this is greater than the number of existing characters between the cursor and the end of the text, then this method does not fail but deletes all the characters in that range. |
| Return | |
|---|---|
Boolean |
true when selected text is deleted, false when either the selection is invalid or not yet attached (i.e. selection start or end is -1), or the editable text is null. |
deleteSurroundingTextInCodePoints
open fun deleteSurroundingTextInCodePoints(
beforeLength: Int,
afterLength: Int
): Boolean
The default implementation performs the deletion around the current selection position of the editable text.
| Parameters | |
|---|---|
beforeLength |
Int: The number of characters before the cursor to be deleted, in code points. If this is greater than the number of existing characters between the beginning of the text and the cursor, then this method does not fail but deletes all the characters in that range. |
afterLength |
Int: The number of characters after the cursor to be deleted, in code points. If this is greater than the number of existing characters between the cursor and the end of the text, then this method does not fail but deletes all the characters in that range. |
| Return | |
|---|---|
Boolean |
true on success, false if the input connection is no longer valid. Returns false when the target application does not implement this method. |
endBatchEdit
open fun endBatchEdit(): Boolean
Default implementation does nothing.
| Return | |
|---|---|
Boolean |
true if there is still a batch edit in progress after closing the latest one (in other words, if the nesting count is > 0), false otherwise or if the input connection is no longer valid. |
finishComposingText
open fun finishComposingText(): Boolean
The default implementation removes the composing state from the current editable text. In addition, only if dummy mode, a key event is sent for the new text and the current editable buffer cleared.
| Return | |
|---|---|
Boolean |
true on success, false if the input connection is no longer valid. |
getComposingSpanStart
open static fun getComposingSpanStart(text: Spannable!): Int
getCursorCapsMode
open fun getCursorCapsMode(reqModes: Int): Int
The default implementation uses TextUtils.getCapsMode to get the cursor caps mode for the current selection position in the editable text, unless in dummy mode in which case 0 is always returned.
| Parameters | |
|---|---|
reqModes |
Int: The desired modes to retrieve, as defined by TextUtils.getCapsMode. These constants are defined so that you can simply pass the current EditorInfo#inputType value directly in to here. |
| Return | |
|---|---|
Int |
the caps mode flags that are in effect at the current cursor position. See TYPE_TEXT_FLAG_CAPS_* in android.text.InputType. |
getEditable
open fun getEditable(): Editable!
Return the target of edit operations. The default implementation returns its own fake editable that is just used for composing text; subclasses that are real text editors should override this and supply their own.
getExtractedText
open fun getExtractedText(
request: ExtractedTextRequest!,
flags: Int
): ExtractedText!
The default implementation always returns null.
| Parameters | |
|---|---|
request |
ExtractedTextRequest!: Description of how the text should be returned. android.view.inputmethod.ExtractedTextRequest |
flags |
Int: Additional options to control the client, either 0 or GET_EXTRACTED_TEXT_MONITOR. |
| Return | |
|---|---|
ExtractedText! |
an android.view.inputmethod.ExtractedText object describing the state of the text view and containing the extracted text itself, or null if the input connection is no longer valid of the editor can't comply with the request for some reason. |
getHandler
open fun getHandler(): Handler!
| Return | |
|---|---|
Handler! |
null to use the default Handler. |
getSelectedText
open fun getSelectedText(flags: Int): CharSequence!
The default implementation returns the text currently selected, or null if none is selected.
| Parameters | |
|---|---|
flags |
Int: Supplies additional options controlling how the text is returned. May be either 0 or GET_TEXT_WITH_STYLES. |
| Return | |
|---|---|
CharSequence! |
the text that is currently selected, if any, or null if no text is selected. In android.os.Build.VERSION_CODES#N and later, returns false when the target application does not implement this method. |
getTextAfterCursor
open fun getTextAfterCursor(
length: Int,
flags: Int
): CharSequence!
The default implementation returns the given amount of text from the current cursor position in the buffer.
| Parameters | |
|---|---|
n |
The expected length of the text. |
flags |
Int: Supplies additional options controlling how the text is returned. May be either 0 or GET_TEXT_WITH_STYLES. |
| Return | |
|---|---|
CharSequence! |
the text after the cursor position; the length of the returned text might be less than n. |
getTextBeforeCursor
open fun getTextBeforeCursor(
length: Int,
flags: Int
): CharSequence!
The default implementation returns the given amount of text from the current cursor position in the buffer.
| Parameters | |
|---|---|
n |
The expected length of the text. |
flags |
Int: Supplies additional options controlling how the text is returned. May be either 0 or GET_TEXT_WITH_STYLES. |
| Return | |
|---|---|
CharSequence! |
the text before the cursor position; the length of the returned text might be less than n. |
performContextMenuAction
open fun performContextMenuAction(id: Int): Boolean
The default implementation does nothing.
performEditorAction
open fun performEditorAction(actionCode: Int): Boolean
The default implementation turns this into the enter key.
| Parameters | |
|---|---|
editorAction |
This must be one of the action constants for EditorInfo#imeOptions, such as EditorInfo#IME_ACTION_GO. |
| Return | |
|---|---|
Boolean |
true on success, false if the input connection is no longer valid. |
performPrivateCommand
open fun performPrivateCommand(
action: String!,
data: Bundle!
): Boolean
The default implementation does nothing.
| Parameters | |
|---|---|
action |
String!: Name of the command to be performed. This must be a scoped name, i.e. prefixed with a package name you own, so that different developers will not create conflicting commands. |
data |
Bundle!: Any data to include with the command. |
| Return | |
|---|---|
Boolean |
true if the command was sent (whether or not the associated editor understood it), false if the input connection is no longer valid. |
reportFullscreenMode
open fun reportFullscreenMode(enabled: Boolean): Boolean
Updates InputMethodManager with the current fullscreen mode.
| Return | |
|---|---|
Boolean |
For editor authors, the return value will always be ignored. For IME authors, this always returns true on android.os.Build.VERSION_CODES#N_MR1 and prior devices and false on android.os.Build.VERSION_CODES#O and later devices. |
requestCursorUpdates
open fun requestCursorUpdates(cursorUpdateMode: Int): Boolean
The default implementation does nothing.
| Parameters | |
|---|---|
cursorUpdateMode |
Int: CURSOR_UPDATE_IMMEDIATE and/or CURSOR_UPDATE_MONITOR. Pass 0 to disable the effect of CURSOR_UPDATE_MONITOR. |
| Return | |
|---|---|
Boolean |
true if the request is scheduled. false to indicate that when the application will not call InputMethodManager#updateCursorAnchorInfo(android.view.View, CursorAnchorInfo). In android.os.Build.VERSION_CODES#N and later, returns false also when the target application does not implement this method. |
sendKeyEvent
open fun sendKeyEvent(event: KeyEvent!): Boolean
Provides standard implementation for sending a key event to the window attached to the input connection's view.
| Parameters | |
|---|---|
event |
KeyEvent!: The key event. |
| Return | |
|---|---|
Boolean |
true on success, false if the input connection is no longer valid. |
setComposingRegion
open fun setComposingRegion(
start: Int,
end: Int
): Boolean
| Parameters | |
|---|---|
start |
Int: the position in the text at which the composing region begins |
end |
Int: the position in the text at which the composing region ends |
| Return | |
|---|---|
Boolean |
true on success, false if the input connection is no longer valid. In android.os.Build.VERSION_CODES#N and later, false is returned when the target application does not implement this method. |
setComposingText
open fun setComposingText(
text: CharSequence!,
newCursorPosition: Int
): Boolean
The default implementation places the given text into the editable, replacing any existing composing text. The new text is marked as in a composing state with the composing style.
| Parameters | |
|---|---|
text |
CharSequence!: The composing text with styles if necessary. If no style object attached to the text, the default style for composing text is used. See android.text.Spanned for how to attach style object to the text. android.text.SpannableString and android.text.SpannableStringBuilder are two implementations of the interface android.text.Spanned. |
newCursorPosition |
Int: The new cursor position around the text. If > 0, this is relative to the end of the text - 1; if <= 0, this is relative to the start of the text. So a value of 1 will always advance you to the position after the full text being inserted. Note that this means you can't position the cursor within the text, because the editor can make modifications to the text you are providing so it is not possible to correctly specify locations there. |
| Return | |
|---|---|
Boolean |
true on success, false if the input connection is no longer valid. |
setSelection
open fun setSelection(
start: Int,
end: Int
): Boolean
The default implementation changes the selection position in the current editable text.
| Parameters | |
|---|---|
start |
Int: the character index where the selection should start. |
end |
Int: the character index where the selection should end. |
| Return | |
|---|---|
Boolean |
true on success, false if the input connection is no longer valid. |