Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
API Rename: IC#inputContent to IC#commitContent.
Browse files Browse the repository at this point in the history
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 adebb52
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 50 deletions.
6 changes: 3 additions & 3 deletions api/current.txt
Expand Up @@ -44696,6 +44696,7 @@ package android.view.inputmethod {
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);
Expand All @@ -44711,7 +44712,6 @@ package android.view.inputmethod {
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);
Expand Down Expand Up @@ -44866,6 +44866,7 @@ package android.view.inputmethod {
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);
Expand All @@ -44878,7 +44879,6 @@ package android.view.inputmethod {
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);
Expand All @@ -44900,6 +44900,7 @@ package android.view.inputmethod {
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);
Expand All @@ -44912,7 +44913,6 @@ package android.view.inputmethod {
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);
Expand Down
6 changes: 3 additions & 3 deletions api/system-current.txt
Expand Up @@ -47803,6 +47803,7 @@ package android.view.inputmethod {
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);
Expand All @@ -47818,7 +47819,6 @@ package android.view.inputmethod {
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);
Expand Down Expand Up @@ -47973,6 +47973,7 @@ package android.view.inputmethod {
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);
Expand All @@ -47985,7 +47986,6 @@ package android.view.inputmethod {
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);
Expand All @@ -48007,6 +48007,7 @@ package android.view.inputmethod {
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);
Expand All @@ -48019,7 +48020,6 @@ package android.view.inputmethod {
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);
Expand Down
6 changes: 3 additions & 3 deletions api/test-current.txt
Expand Up @@ -44776,6 +44776,7 @@ package android.view.inputmethod {
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);
Expand All @@ -44791,7 +44792,6 @@ package android.view.inputmethod {
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);
Expand Down Expand Up @@ -44946,6 +44946,7 @@ package android.view.inputmethod {
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);
Expand All @@ -44958,7 +44959,6 @@ package android.view.inputmethod {
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);
Expand All @@ -44980,6 +44980,7 @@ package android.view.inputmethod {
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);
Expand All @@ -44992,7 +44993,6 @@ package android.view.inputmethod {
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);
Expand Down
Expand Up @@ -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; }
}
4 changes: 2 additions & 2 deletions core/java/android/view/inputmethod/EditorInfo.java
Expand Up @@ -368,10 +368,10 @@ public class EditorInfo implements InputType, Parcelable {

/**
* 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
Expand Down
4 changes: 2 additions & 2 deletions core/java/android/view/inputmethod/InputConnection.java
Expand Up @@ -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>
Expand All @@ -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);
}
18 changes: 9 additions & 9 deletions core/java/android/view/inputmethod/InputConnectionInspector.java
Expand Up @@ -43,7 +43,7 @@ public final class InputConnectionInspector {
MissingMethodFlags.DELETE_SURROUNDING_TEXT_IN_CODE_POINTS,
MissingMethodFlags.GET_HANDLER,
MissingMethodFlags.CLOSE_CONNECTION,
MissingMethodFlags.INSERT_CONTENT,
MissingMethodFlags.COMMIT_CONTENT,
})
public @interface MissingMethodFlags {
/**
Expand Down Expand Up @@ -82,10 +82,10 @@ public final class InputConnectionInspector {
*/
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(
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
}
Expand Down
Expand Up @@ -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);
}
}
5 changes: 2 additions & 3 deletions core/java/android/widget/AbsListView.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down
22 changes: 11 additions & 11 deletions core/java/com/android/internal/view/IInputConnectionWrapper.java
Expand Up @@ -62,7 +62,7 @@ public abstract class IInputConnectionWrapper extends IInputContext.Stub {
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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion core/java/com/android/internal/view/IInputContext.aidl
Expand Up @@ -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);
}
Expand Up @@ -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.