public class

BaseInputConnection

extends Object
implements InputConnection
java.lang.Object
   ↳ android.view.inputmethod.BaseInputConnection

Class Overview

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.

Summary

[Expand]
Inherited Constants
From interface android.view.inputmethod.InputConnection
Public Constructors
BaseInputConnection(View targetView, boolean fullEditor)
Public Methods
boolean beginBatchEdit()
Default implementation does nothing.
boolean clearMetaKeyStates(int states)
Default implementation uses MetaKeyKeyListener.clearMetaKeyState(long, int) to clear the state.
boolean commitCompletion(CompletionInfo text)
Default implementation does nothing.
boolean commitText(CharSequence text, int newCursorPosition)
Default implementation replaces any existing composing text with the given text.
boolean deleteSurroundingText(int leftLength, int rightLength)
The default implementation performs the deletion around the current selection position of the editable text.
boolean endBatchEdit()
Default implementation does nothing.
boolean finishComposingText()
The default implementation removes the composing state from the current editable text.
static int getComposingSpanEnd(Spannable text)
static int getComposingSpanStart(Spannable text)
int getCursorCapsMode(int reqModes)
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.
Editable getEditable()
Return the target of edit operations.
ExtractedText getExtractedText(ExtractedTextRequest request, int flags)
The default implementation always returns null.
CharSequence getTextAfterCursor(int length, int flags)
The default implementation returns the given amount of text from the current cursor position in the buffer.
CharSequence getTextBeforeCursor(int length, int flags)
The default implementation returns the given amount of text from the current cursor position in the buffer.
boolean performContextMenuAction(int id)
The default implementation does nothing.
boolean performEditorAction(int actionCode)
The default implementation does nothing.
boolean performPrivateCommand(String action, Bundle data)
The default implementation does nothing.
final static void removeComposingSpans(Spannable text)
boolean reportFullscreenMode(boolean enabled)
Updates InputMethodManager with the current fullscreen mode.
boolean sendKeyEvent(KeyEvent event)
Provides standard implementation for sending a key event to the window attached to the input connection's view.
static void setComposingSpans(Spannable text)
boolean setComposingText(CharSequence text, int newCursorPosition)
The default implementation places the given text into the editable, replacing any existing composing text.
boolean setSelection(int start, int end)
The default implementation changes the selection position in the current editable text.
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.view.inputmethod.InputConnection

Public Constructors

public BaseInputConnection (View targetView, boolean fullEditor)

Public Methods

public boolean beginBatchEdit ()

Default implementation does nothing.

public boolean clearMetaKeyStates (int states)

Default implementation uses MetaKeyKeyListener.clearMetaKeyState(long, int) to clear the state.

Parameters
states The states to be cleared, may be one or more bits as per KeyEvent.getMetaState().
Returns
  • Returns true on success, false if the input connection is no longer valid.

public boolean commitCompletion (CompletionInfo text)

Default implementation does nothing.

Parameters
text The committed completion.
Returns
  • Returns true on success, false if the input connection is no longer valid.

public boolean commitText (CharSequence text, int newCursorPosition)

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 The committed text.
newCursorPosition 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.
Returns
  • Returns true on success, false if the input connection is no longer valid.

public boolean deleteSurroundingText (int leftLength, int rightLength)

The default implementation performs the deletion around the current selection position of the editable text.

Parameters
leftLength The number of characters to be deleted before the current cursor position.
rightLength The number of characters to be deleted after the current cursor position.
Returns
  • Returns true on success, false if the input connection is no longer valid.

public boolean endBatchEdit ()

Default implementation does nothing.

public boolean finishComposingText ()

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.

public static int getComposingSpanEnd (Spannable text)

public static int getComposingSpanStart (Spannable text)

public int getCursorCapsMode (int reqModes)

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 The desired modes to retrieve, as defined by TextUtils.getCapsMode. These constants are defined so that you can simply pass the current TextBoxAttribute.contentType value directly in to here.
Returns
  • Returns the caps mode flags that are in effect.

public Editable getEditable ()

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.

public ExtractedText getExtractedText (ExtractedTextRequest request, int flags)

The default implementation always returns null.

Parameters
request Description of how the text should be returned.
flags Additional options to control the client, either 0 or GET_EXTRACTED_TEXT_MONITOR.
Returns
  • Returns an ExtractedText object describing the state of the text view and containing the extracted text itself.

public CharSequence getTextAfterCursor (int length, int flags)

The default implementation returns the given amount of text from the current cursor position in the buffer.

Parameters
length The expected length of the text.
flags Supplies additional options controlling how the text is returned. May be either 0 or GET_TEXT_WITH_STYLES.
Returns
  • Returns the text after the cursor position; the length of the returned text might be less than n.

public CharSequence getTextBeforeCursor (int length, int flags)

The default implementation returns the given amount of text from the current cursor position in the buffer.

Parameters
length The expected length of the text.
flags Supplies additional options controlling how the text is returned. May be either 0 or GET_TEXT_WITH_STYLES.
Returns
  • Returns the text before the cursor position; the length of the returned text might be less than n.

public boolean performContextMenuAction (int id)

The default implementation does nothing.

public boolean performEditorAction (int actionCode)

The default implementation does nothing.

Parameters
actionCode This must be one of the action constants for EditorInfo.editorType, such as EditorInfo.EDITOR_ACTION_GO.
Returns
  • Returns true on success, false if the input connection is no longer valid.

public boolean performPrivateCommand (String action, Bundle data)

The default implementation does nothing.

Parameters
action 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 Any data to include with the command.
Returns
  • Returns true if the command was sent (whether or not the associated editor understood it), false if the input connection is no longer valid.

public static final void removeComposingSpans (Spannable text)

public boolean reportFullscreenMode (boolean enabled)

Updates InputMethodManager with the current fullscreen mode.

public boolean sendKeyEvent (KeyEvent event)

Provides standard implementation for sending a key event to the window attached to the input connection's view.

Parameters
event The key event.
Returns
  • Returns true on success, false if the input connection is no longer valid.

public static void setComposingSpans (Spannable text)

public boolean setComposingText (CharSequence text, int newCursorPosition)

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 The composing text with styles if necessary. If no style object attached to the text, the default style for composing text is used. See {#link android.text.Spanned} for how to attach style object to the text. {#link android.text.SpannableString} and {#link android.text.SpannableStringBuilder} are two implementations of the interface {#link android.text.Spanned}.
newCursorPosition 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.
Returns
  • Returns true on success, false if the input connection is no longer valid.

public boolean setSelection (int start, int end)

The default implementation changes the selection position in the current editable text.

Returns
  • Returns true on success, false if the input connection is no longer valid.