diff options
| author | Calvin Pan <calvinpan@google.com> | 2021-10-18 18:12:43 +0800 |
|---|---|---|
| committer | Calvin Pan <calvinpan@google.com> | 2021-11-09 21:23:54 +0800 |
| commit | c33444b736f5f4a13eb7a50857fe80e8de32551d (patch) | |
| tree | 7e6d842fa521f731de16a5c3ab32f509f120fa6d /core/java/android/inputmethodservice | |
| parent | e551c20dc8a295ebf3b7b729a321210c37e430dd (diff) | |
Support IME to take extra information to editor
Add the TextAttribute class and variant of setComposingText(),
setComposingRegion(), commitText() to support IME to take extra
information to editor.
Bug: 198732184
Test: atest CtsInputMethodTestCases:InputConnectionEndToEndTest CtsInputMethodTestCases:TextAttributeTest
Change-Id: Ic9c917b70726ca32c2097b0374951c20af9624c4
Diffstat (limited to 'core/java/android/inputmethodservice')
| -rw-r--r-- | core/java/android/inputmethodservice/RemoteInputConnection.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/core/java/android/inputmethodservice/RemoteInputConnection.java b/core/java/android/inputmethodservice/RemoteInputConnection.java index ae97fe7df729..ed617afab96e 100644 --- a/core/java/android/inputmethodservice/RemoteInputConnection.java +++ b/core/java/android/inputmethodservice/RemoteInputConnection.java @@ -31,6 +31,7 @@ import android.view.inputmethod.ExtractedTextRequest; import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputContentInfo; import android.view.inputmethod.SurroundingText; +import android.view.inputmethod.TextAttribute; import com.android.internal.inputmethod.CancellationGroup; import com.android.internal.inputmethod.CompletableFutureUtil; @@ -272,6 +273,17 @@ final class RemoteInputConnection implements InputConnection { } @AnyThread + public boolean commitText(@NonNull CharSequence text, int newCursorPosition, + @Nullable TextAttribute textAttribute) { + final boolean handled = + mInvoker.commitText(text, newCursorPosition, textAttribute); + if (handled) { + notifyUserActionIfNecessary(); + } + return handled; + } + + @AnyThread private void notifyUserActionIfNecessary() { final InputMethodServiceInternal imsInternal = mImsInternal.getAndWarnIfNull(); if (imsInternal == null) { @@ -311,6 +323,11 @@ final class RemoteInputConnection implements InputConnection { } @AnyThread + public boolean setComposingRegion(int start, int end, @Nullable TextAttribute textAttribute) { + return mInvoker.setComposingRegion(start, end, textAttribute); + } + + @AnyThread public boolean setComposingText(CharSequence text, int newCursorPosition) { final boolean handled = mInvoker.setComposingText(text, newCursorPosition); if (handled) { @@ -320,6 +337,16 @@ final class RemoteInputConnection implements InputConnection { } @AnyThread + public boolean setComposingText(CharSequence text, int newCursorPosition, + @Nullable TextAttribute textAttribute) { + final boolean handled = mInvoker.setComposingText(text, newCursorPosition, textAttribute); + if (handled) { + notifyUserActionIfNecessary(); + } + return handled; + } + + @AnyThread public boolean finishComposingText() { return mInvoker.finishComposingText(); } |
