summaryrefslogtreecommitdiff
path: root/core/java/android/inputmethodservice/InputMethodService.java
diff options
context:
space:
mode:
authorYohei Yukawa <yukawa@google.com>2014-07-11 04:13:03 +0900
committerYohei Yukawa <yukawa@google.com>2014-07-11 21:13:17 +0900
commit0023d0e0c4f5339b299d1eacbd4e7181c2fd271f (patch)
treeedd47b35deab9062769e96749330c5c51bd87675 /core/java/android/inputmethodservice/InputMethodService.java
parentcaebf6ff00d9c0c0829800b9f5026c4c59d9df28 (diff)
Polish new IME API for L part 2: CursorAnchorInfo
This CL addresses feedbacks from internal customers for new input method APIs that are mainly used for physical keyboard support in L. For performance reasons, #onUpdateCursorAnchorInfo is not called back by default and each input method has to enable this event notification explicitly whenever fine-grained character locations are needed. In L-preview, InputMethodSession#setCursorAnchorMonitorMode was introduced for this purpose. However, we got several feedbacks to be addressed. - The effect of #setCursorAnchorMonitorMode is not preserved during focus change. IMEs need to call #setCursorAnchorMonitorMode every time when #onStartInput is called. This is tricky and hard to understand. - As #onUpdateCursorAnchorInfo is a new API, not all applications/text editors have supported it. Therefore IMEs can't always rely on it. However, there is no way to query if the attached target is supporting this new API or not. It would helpful for IME authors if we can provide a reliable way to query if the attached input target is supporting the new API or not. In order to address these issues, the triggering method has moved from InputMethodSession to InputConnection in this CL, as an analogy of existing InputConnection#getExtractedText API, which has provided similar functionality including optional reactive event callbacks from the application to the IME. BUG: 15812658 BUG: 16118603 Change-Id: I3c6b69bd9d79b199afe68d838f25effa6048e5cc
Diffstat (limited to 'core/java/android/inputmethodservice/InputMethodService.java')
-rw-r--r--core/java/android/inputmethodservice/InputMethodService.java25
1 files changed, 4 insertions, 21 deletions
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index 3417de12a189..8423d0952ee8 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -53,6 +53,7 @@ import android.view.WindowManager.BadTokenException;
import android.view.animation.AnimationUtils;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.CursorAnchorInfo;
+import android.view.inputmethod.CursorAnchorInfoRequest;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.ExtractedText;
import android.view.inputmethod.ExtractedTextRequest;
@@ -251,18 +252,6 @@ public class InputMethodService extends AbstractInputMethodService {
*/
public static final int IME_VISIBLE = 0x2;
- /**
- * The IME does not require cursor/anchor position.
- */
- public static final int CURSOR_ANCHOR_MONITOR_MODE_NONE = 0x0;
-
- /**
- * Passing this flag into a call to {@link #setCursorAnchorMonitorMode(int)} will result in
- * the cursor rectangle being provided in screen coordinates to subsequent
- * {@link #onUpdateCursor(Rect)} callbacks.
- */
- public static final int CURSOR_ANCHOR_MONITOR_MODE_CURSOR_RECT = 0x1;
-
InputMethodManager mImm;
int mTheme = 0;
@@ -1722,8 +1711,9 @@ public class InputMethodService extends AbstractInputMethodService {
* Called when the application has reported a new location of its text cursor. This is only
* called if explicitly requested by the input method. The default implementation does nothing.
* @param newCursor The new cursor position, in screen coordinates if the input method calls
- * {@link #setCursorAnchorMonitorMode} with {@link #CURSOR_ANCHOR_MONITOR_MODE_CURSOR_RECT}.
- * Otherwise, this is in local coordinates.
+ * {@link InputConnection#requestCursorAnchorInfo(CursorAnchorInfoRequest)} with
+ * {@link CursorAnchorInfoRequest#FLAG_CURSOR_RECT_IN_SCREEN_COORDINATES}. Otherwise,
+ * this is in local coordinates.
*/
public void onUpdateCursor(Rect newCursor) {
// Intentionally empty
@@ -1741,13 +1731,6 @@ public class InputMethodService extends AbstractInputMethodService {
}
/**
- * Update the cursor/anthor monitor mode.
- */
- public void setCursorAnchorMonitorMode(int monitorMode) {
- mImm.setCursorAnchorMonitorMode(mToken, monitorMode);
- }
-
- /**
* Close this input method's soft input area, removing it from the display.
* The input method will continue running, but the user can no longer use
* it to generate input by touching the screen.