Skip to content
Permalink
Browse files

API Rename: IC#inputContent to IC#commitContent.

As shown in below, we have already used commit* naming convention in
InputConnection.

 - InputConnection#commitCompletion(CompletionInfo);
 - InputConnection#commitCorrection(CorrectionInfo);
 - InputConnection#commitText(CharSequence, int);

Hence renaming IC#inputContent() to IC#commitContent() would make the
new method more consistent.

Bug: 29450024
Change-Id: Ica1ba3154795c1bf44e140dfe639b299f83cd8af
  • Loading branch information...
yukawa committed Jun 17, 2016
1 parent 4e5ee65 commit adebb52588b098a1af678d4e33a234ef1ce783b2
method public boolean clearMetaKeyStates(int);
method public void closeConnection();
method public boolean commitCompletion(android.view.inputmethod.CompletionInfo);
method public boolean commitContent(android.view.inputmethod.InputContentInfo, android.os.Bundle);
method public boolean commitCorrection(android.view.inputmethod.CorrectionInfo);
method public boolean commitText(java.lang.CharSequence, int);
method public boolean deleteSurroundingText(int, int);
method public java.lang.CharSequence getSelectedText(int);
method public java.lang.CharSequence getTextAfterCursor(int, int);
method public java.lang.CharSequence getTextBeforeCursor(int, int);
method public boolean insertContent(android.view.inputmethod.InputContentInfo, android.os.Bundle);
method public boolean performContextMenuAction(int);
method public boolean performEditorAction(int);
method public boolean performPrivateCommand(java.lang.String, android.os.Bundle);
method public abstract boolean clearMetaKeyStates(int);
method public abstract void closeConnection();
method public abstract boolean commitCompletion(android.view.inputmethod.CompletionInfo);
method public abstract boolean commitContent(android.view.inputmethod.InputContentInfo, android.os.Bundle);
method public abstract boolean commitCorrection(android.view.inputmethod.CorrectionInfo);
method public abstract boolean commitText(java.lang.CharSequence, int);
method public abstract boolean deleteSurroundingText(int, int);
method public abstract java.lang.CharSequence getSelectedText(int);
method public abstract java.lang.CharSequence getTextAfterCursor(int, int);
method public abstract java.lang.CharSequence getTextBeforeCursor(int, int);
method public abstract boolean insertContent(android.view.inputmethod.InputContentInfo, android.os.Bundle);
method public abstract boolean performContextMenuAction(int);
method public abstract boolean performEditorAction(int);
method public abstract boolean performPrivateCommand(java.lang.String, android.os.Bundle);
method public boolean clearMetaKeyStates(int);
method public void closeConnection();
method public boolean commitCompletion(android.view.inputmethod.CompletionInfo);
method public boolean commitContent(android.view.inputmethod.InputContentInfo, android.os.Bundle);
method public boolean commitCorrection(android.view.inputmethod.CorrectionInfo);
method public boolean commitText(java.lang.CharSequence, int);
method public boolean deleteSurroundingText(int, int);
method public java.lang.CharSequence getSelectedText(int);
method public java.lang.CharSequence getTextAfterCursor(int, int);
method public java.lang.CharSequence getTextBeforeCursor(int, int);
method public boolean insertContent(android.view.inputmethod.InputContentInfo, android.os.Bundle);
method public boolean performContextMenuAction(int);
method public boolean performEditorAction(int);
method public boolean performPrivateCommand(java.lang.String, android.os.Bundle);
method public boolean clearMetaKeyStates(int);
method public void closeConnection();
method public boolean commitCompletion(android.view.inputmethod.CompletionInfo);
method public boolean commitContent(android.view.inputmethod.InputContentInfo, android.os.Bundle);
method public boolean commitCorrection(android.view.inputmethod.CorrectionInfo);
method public boolean commitText(java.lang.CharSequence, int);
method public boolean deleteSurroundingText(int, int);
method public java.lang.CharSequence getSelectedText(int);
method public java.lang.CharSequence getTextAfterCursor(int, int);
method public java.lang.CharSequence getTextBeforeCursor(int, int);
method public boolean insertContent(android.view.inputmethod.InputContentInfo, android.os.Bundle);
method public boolean performContextMenuAction(int);
method public boolean performEditorAction(int);
method public boolean performPrivateCommand(java.lang.String, android.os.Bundle);
method public abstract boolean clearMetaKeyStates(int);
method public abstract void closeConnection();
method public abstract boolean commitCompletion(android.view.inputmethod.CompletionInfo);
method public abstract boolean commitContent(android.view.inputmethod.InputContentInfo, android.os.Bundle);
method public abstract boolean commitCorrection(android.view.inputmethod.CorrectionInfo);
method public abstract boolean commitText(java.lang.CharSequence, int);
method public abstract boolean deleteSurroundingText(int, int);
method public abstract java.lang.CharSequence getSelectedText(int);
method public abstract java.lang.CharSequence getTextAfterCursor(int, int);
method public abstract java.lang.CharSequence getTextBeforeCursor(int, int);
method public abstract boolean insertContent(android.view.inputmethod.InputContentInfo, android.os.Bundle);
method public abstract boolean performContextMenuAction(int);
method public abstract boolean performEditorAction(int);
method public abstract boolean performPrivateCommand(java.lang.String, android.os.Bundle);
method public boolean clearMetaKeyStates(int);
method public void closeConnection();
method public boolean commitCompletion(android.view.inputmethod.CompletionInfo);
method public boolean commitContent(android.view.inputmethod.InputContentInfo, android.os.Bundle);
method public boolean commitCorrection(android.view.inputmethod.CorrectionInfo);
method public boolean commitText(java.lang.CharSequence, int);
method public boolean deleteSurroundingText(int, int);
method public java.lang.CharSequence getSelectedText(int);
method public java.lang.CharSequence getTextAfterCursor(int, int);
method public java.lang.CharSequence getTextBeforeCursor(int, int);
method public boolean insertContent(android.view.inputmethod.InputContentInfo, android.os.Bundle);
method public boolean performContextMenuAction(int);
method public boolean performEditorAction(int);
method public boolean performPrivateCommand(java.lang.String, android.os.Bundle);
method public boolean clearMetaKeyStates(int);
method public void closeConnection();
method public boolean commitCompletion(android.view.inputmethod.CompletionInfo);
method public boolean commitContent(android.view.inputmethod.InputContentInfo, android.os.Bundle);
method public boolean commitCorrection(android.view.inputmethod.CorrectionInfo);
method public boolean commitText(java.lang.CharSequence, int);
method public boolean deleteSurroundingText(int, int);
method public java.lang.CharSequence getSelectedText(int);
method public java.lang.CharSequence getTextAfterCursor(int, int);
method public java.lang.CharSequence getTextBeforeCursor(int, int);
method public boolean insertContent(android.view.inputmethod.InputContentInfo, android.os.Bundle);
method public boolean performContextMenuAction(int);
method public boolean performEditorAction(int);
method public boolean performPrivateCommand(java.lang.String, android.os.Bundle);
method public abstract boolean clearMetaKeyStates(int);
method public abstract void closeConnection();
method public abstract boolean commitCompletion(android.view.inputmethod.CompletionInfo);
method public abstract boolean commitContent(android.view.inputmethod.InputContentInfo, android.os.Bundle);
method public abstract boolean commitCorrection(android.view.inputmethod.CorrectionInfo);
method public abstract boolean commitText(java.lang.CharSequence, int);
method public abstract boolean deleteSurroundingText(int, int);
method public abstract java.lang.CharSequence getSelectedText(int);
method public abstract java.lang.CharSequence getTextAfterCursor(int, int);
method public abstract java.lang.CharSequence getTextBeforeCursor(int, int);
method public abstract boolean insertContent(android.view.inputmethod.InputContentInfo, android.os.Bundle);
method public abstract boolean performContextMenuAction(int);
method public abstract boolean performEditorAction(int);
method public abstract boolean performPrivateCommand(java.lang.String, android.os.Bundle);
method public boolean clearMetaKeyStates(int);
method public void closeConnection();
method public boolean commitCompletion(android.view.inputmethod.CompletionInfo);
method public boolean commitContent(android.view.inputmethod.InputContentInfo, android.os.Bundle);
method public boolean commitCorrection(android.view.inputmethod.CorrectionInfo);
method public boolean commitText(java.lang.CharSequence, int);
method public boolean deleteSurroundingText(int, int);
method public java.lang.CharSequence getSelectedText(int);
method public java.lang.CharSequence getTextAfterCursor(int, int);
method public java.lang.CharSequence getTextBeforeCursor(int, int);
method public boolean insertContent(android.view.inputmethod.InputContentInfo, android.os.Bundle);
method public boolean performContextMenuAction(int);
method public boolean performEditorAction(int);
method public boolean performPrivateCommand(java.lang.String, android.os.Bundle);
@@ -855,5 +855,5 @@ private void replaceText(CharSequence text, int newCursorPosition,
/**
* The default implementation does nothing.
*/
public boolean insertContent(InputContentInfo inputContentInfo, Bundle opts) { return false; }
public boolean commitContent(InputContentInfo inputContentInfo, Bundle opts) { return false; }
}
@@ -368,10 +368,10 @@

/**
* List of acceptable MIME types for
* {@link InputConnection#insertContent(InputContentInfo, Bundle)}.
* {@link InputConnection#commitContent(InputContentInfo, Bundle)}.
*
* <p>{@code null} or an empty array means that
* {@link InputConnection#insertContent(InputContentInfo, Bundle)} is not supported in this
* {@link InputConnection#commitContent(InputContentInfo, Bundle)} is not supported in this
* editor.</p>
*/
@Nullable
@@ -840,7 +840,7 @@ public ExtractedText getExtractedText(ExtractedTextRequest request,
public void closeConnection();

/**
* Called by the input method to insert a content such as PNG image to the editor.
* Called by the input method to commit a content such as PNG image to the editor.
*
* <p>In order to avoid variety of compatibility issues, this focuses on a simple use case,
* where we expect editors and IMEs work cooperatively as follows:</p>
@@ -866,5 +866,5 @@ public ExtractedText getExtractedText(ExtractedTextRequest request,
* @return {@code true} if this request is accepted by the application, no matter if the request
* is already handled or still being handled in background.
*/
public boolean insertContent(@NonNull InputContentInfo inputContentInfo, @Nullable Bundle opts);
public boolean commitContent(@NonNull InputContentInfo inputContentInfo, @Nullable Bundle opts);
}
@@ -43,7 +43,7 @@
MissingMethodFlags.DELETE_SURROUNDING_TEXT_IN_CODE_POINTS,
MissingMethodFlags.GET_HANDLER,
MissingMethodFlags.CLOSE_CONNECTION,
MissingMethodFlags.INSERT_CONTENT,
MissingMethodFlags.COMMIT_CONTENT,
})
public @interface MissingMethodFlags {
/**
@@ -82,10 +82,10 @@
*/
int CLOSE_CONNECTION = 1 << 6;
/**
* {@link InputConnection#insertContent(InputContentInfo, Bundle)} is available in
* {@link InputConnection#commitContent(InputContentInfo, Bundle)} is available in
* {@link android.os.Build.VERSION_CODES#N} MR-1 and later.
*/
int INSERT_CONTENT = 1 << 7;
int COMMIT_CONTENT = 1 << 7;
}

private static final Map<Class, Integer> sMissingMethodsMap = Collections.synchronizedMap(
@@ -135,8 +135,8 @@ public static int getMissingMethodFlagsInternal(@NonNull final Class clazz) {
if (!hasCloseConnection(clazz)) {
flags |= MissingMethodFlags.CLOSE_CONNECTION;
}
if (!hasInsertContent(clazz)) {
flags |= MissingMethodFlags.INSERT_CONTENT;
if (!hasCommitContent(clazz)) {
flags |= MissingMethodFlags.COMMIT_CONTENT;
}
sMissingMethodsMap.put(clazz, flags);
return flags;
@@ -206,9 +206,9 @@ private static boolean hasCloseConnection(@NonNull final Class clazz) {
}
}

private static boolean hasInsertContent(@NonNull final Class clazz) {
private static boolean hasCommitContent(@NonNull final Class clazz) {
try {
final Method method = clazz.getMethod("insertContent", InputContentInfo.class,
final Method method = clazz.getMethod("commitContent", InputContentInfo.class,
Bundle.class);
return !Modifier.isAbstract(method.getModifiers());
} catch (NoSuchMethodException e) {
@@ -263,11 +263,11 @@ public static String getMissingMethodFlagsAsString(@MissingMethodFlags final int
}
sb.append("closeConnection()");
}
if ((flags & MissingMethodFlags.INSERT_CONTENT) != 0) {
if ((flags & MissingMethodFlags.COMMIT_CONTENT) != 0) {
if (!isEmpty) {
sb.append(",");
}
sb.append("InsertContent(InputContentInfo, Bundle)");
sb.append("commitContent(InputContentInfo, Bundle)");
}
return sb.toString();
}
@@ -274,7 +274,7 @@ public void closeConnection() {
* {@inheritDoc}
* @throws NullPointerException if the target is {@code null}.
*/
public boolean insertContent(InputContentInfo inputContentInfo, Bundle opts) {
return mTarget.insertContent(inputContentInfo, opts);
public boolean commitContent(InputContentInfo inputContentInfo, Bundle opts) {
return mTarget.commitContent(inputContentInfo, opts);
}
}
@@ -19,7 +19,6 @@
import android.annotation.ColorInt;
import android.annotation.DrawableRes;
import android.annotation.NonNull;
import android.content.ClipData;
import android.content.Context;
import android.content.Intent;
import android.content.res.TypedArray;
@@ -5986,8 +5985,8 @@ public void closeConnection() {
}

@Override
public boolean insertContent(InputContentInfo inputContentInfo, Bundle opts) {
return getTarget().insertContent(inputContentInfo, opts);
public boolean commitContent(InputContentInfo inputContentInfo, Bundle opts) {
return getTarget().commitContent(inputContentInfo, opts);
}
}

@@ -62,7 +62,7 @@
private static final int DO_CLEAR_META_KEY_STATES = 130;
private static final int DO_REQUEST_UPDATE_CURSOR_ANCHOR_INFO = 140;
private static final int DO_CLOSE_CONNECTION = 150;
private static final int DO_INSERT_CONTENT = 160;
private static final int DO_COMMIT_CONTENT = 160;

@GuardedBy("mLock")
@Nullable
@@ -243,9 +243,9 @@ public void closeConnection() {
dispatchMessage(obtainMessage(DO_CLOSE_CONNECTION));
}

public void insertContent(InputContentInfo inputContentInfo, Bundle opts,
public void commitContent(InputContentInfo inputContentInfo, Bundle opts,
int seq, IInputContextCallback callback) {
dispatchMessage(obtainMessageOOSC(DO_INSERT_CONTENT, inputContentInfo, opts, seq, callback));
dispatchMessage(obtainMessageOOSC(DO_COMMIT_CONTENT, inputContentInfo, opts, seq, callback));
}

void dispatchMessage(Message msg) {
@@ -559,26 +559,26 @@ void executeMessage(Message msg) {
}
return;
}
case DO_INSERT_CONTENT: {
case DO_COMMIT_CONTENT: {
SomeArgs args = (SomeArgs) msg.obj;
try {
InputConnection ic = getInputConnection();
if (ic == null || !isActive()) {
Log.w(TAG, "insertContent on inactive InputConnection");
args.callback.setInsertContentResult(false, args.seq);
Log.w(TAG, "commitContent on inactive InputConnection");
args.callback.setCommitContentResult(false, args.seq);
return;
}
final InputContentInfo inputContentInfo = (InputContentInfo) args.arg1;
if (inputContentInfo == null || !inputContentInfo.validate()) {
Log.w(TAG, "insertContent with invalid inputContentInfo="
Log.w(TAG, "commitContent with invalid inputContentInfo="
+ inputContentInfo);
args.callback.setInsertContentResult(false, args.seq);
args.callback.setCommitContentResult(false, args.seq);
return;
}
args.callback.setInsertContentResult(
ic.insertContent(inputContentInfo, (Bundle) args.arg2), args.seq);
args.callback.setCommitContentResult(
ic.commitContent(inputContentInfo, (Bundle) args.arg2), args.seq);
} catch (RemoteException e) {
Log.w(TAG, "Got RemoteException calling insertContent", e);
Log.w(TAG, "Got RemoteException calling commitContent", e);
}
return;
}
@@ -78,6 +78,6 @@ import com.android.internal.view.IInputContextCallback;
void requestUpdateCursorAnchorInfo(int cursorUpdateMode, int seq,
IInputContextCallback callback);

void insertContent(in InputContentInfo inputContentInfo, in Bundle opts, int sec,
void commitContent(in InputContentInfo inputContentInfo, in Bundle opts, int sec,
IInputContextCallback callback);
}
@@ -28,5 +28,5 @@ oneway interface IInputContextCallback {
void setExtractedText(in ExtractedText extractedText, int seq);
void setSelectedText(CharSequence selectedText, int seq);
void setRequestUpdateCursorAnchorInfoResult(boolean result, int seq);
void setInsertContentResult(boolean result, int seq);
void setCommitContentResult(boolean result, int seq);
}

0 comments on commit adebb52

Please sign in to comment.
You can’t perform that action at this time.