summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYohei Yukawa <yukawa@google.com>2014-08-21 18:38:44 -0700
committerYohei Yukawa <yukawa@google.com>2014-08-22 00:55:06 -0700
commita277db28e990d1f6f74ace0c32fe92401660a840 (patch)
tree88525827dbf2aff28871579a98e73a058a41a545
parent97a50adde5eaee4216d537b2a90a9f33533d2926 (diff)
downloadframeworks_base-a277db28e990d1f6f74ace0c32fe92401660a840.zip
frameworks_base-a277db28e990d1f6f74ace0c32fe92401660a840.tar.gz
frameworks_base-a277db28e990d1f6f74ace0c32fe92401660a840.tar.bz2
Remove CursorAnchorInfoRequest and related stuff
This CL removes CursorAnchorInfoRequest and related stuff in favor of InputConnection.requestUpdateCursorAnchorInfo, which is more easy to understand. This CL also deprecates InputMethodManager#updateCursor and related stuff. Rationale: 1. The spec of #updateCursor says that it provides the cursor position in local coordinates, while the input method requires it in the screen coordinates. 2. #updateCursor has never been enabled in AOSP, because InputMethodManager#isWatchingCursor always returned false. 3. There has been no way to let InputMethodManager#isWatchingCursor return true. 4. In L, InputMethodManager#updateCursorAnchorInfo is introduced to address all the issues above. Given that we no longer need to support #updateCursor, CursorAnchorInfoRequest is overkill when we need to convey just a couple of parameters. BUG: 17185263 BUG: 17182367 Change-Id: I4a577bfd02b37b9e56c80b8b41bb25afa95dd8ef
-rw-r--r--api/current.txt33
-rw-r--r--core/java/android/inputmethodservice/InputMethodService.java12
-rw-r--r--core/java/android/view/inputmethod/BaseInputConnection.java21
-rw-r--r--core/java/android/view/inputmethod/CursorAnchorInfoRequest.aidl19
-rw-r--r--core/java/android/view/inputmethod/CursorAnchorInfoRequest.java203
-rw-r--r--core/java/android/view/inputmethod/InputConnection.java31
-rw-r--r--core/java/android/view/inputmethod/InputConnectionWrapper.java4
-rw-r--r--core/java/android/view/inputmethod/InputMethodManager.java111
-rw-r--r--core/java/android/widget/AbsListView.java5
-rw-r--r--core/java/android/widget/Editor.java20
-rw-r--r--core/java/com/android/internal/view/IInputConnectionWrapper.java17
-rw-r--r--core/java/com/android/internal/view/IInputContext.aidl3
-rw-r--r--core/java/com/android/internal/view/IInputContextCallback.aidl2
-rw-r--r--core/java/com/android/internal/view/InputConnectionWrapper.java19
-rw-r--r--core/java/com/android/internal/widget/EditableInputConnection.java25
15 files changed, 107 insertions, 418 deletions
diff --git a/api/current.txt b/api/current.txt
index 37b8327..9c97cc9 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -13574,7 +13574,7 @@ package android.inputmethodservice {
method public void onStartInput(android.view.inputmethod.EditorInfo, boolean);
method public void onStartInputView(android.view.inputmethod.EditorInfo, boolean);
method public void onUnbindInput();
- method public void onUpdateCursor(android.graphics.Rect);
+ method public deprecated void onUpdateCursor(android.graphics.Rect);
method public void onUpdateCursorAnchorInfo(android.view.inputmethod.CursorAnchorInfo);
method public void onUpdateExtractedText(int, android.view.inputmethod.ExtractedText);
method public void onUpdateExtractingViews(android.view.inputmethod.EditorInfo);
@@ -36187,7 +36187,7 @@ package android.view.inputmethod {
method public boolean performPrivateCommand(java.lang.String, android.os.Bundle);
method public static final void removeComposingSpans(android.text.Spannable);
method public boolean reportFullscreenMode(boolean);
- method public int requestCursorAnchorInfo(android.view.inputmethod.CursorAnchorInfoRequest);
+ method public boolean requestUpdateCursorAnchorInfo(int);
method public boolean sendKeyEvent(android.view.KeyEvent);
method public boolean setComposingRegion(int, int);
method public static void setComposingSpans(android.text.Spannable);
@@ -36253,25 +36253,6 @@ package android.view.inputmethod {
method public android.view.inputmethod.CursorAnchorInfo.Builder setSelectionRange(int, int);
}
- public final class CursorAnchorInfoRequest implements android.os.Parcelable {
- ctor public CursorAnchorInfoRequest(int, int);
- ctor public CursorAnchorInfoRequest(android.os.Parcel);
- method public int describeContents();
- method public int getRequestFlags();
- method public int getRequestType();
- method public void writeToParcel(android.os.Parcel, int);
- field public static final android.os.Parcelable.Creator CREATOR;
- field public static final int FLAG_CURSOR_ANCHOR_INFO_IMMEDIATE = 2; // 0x2
- field public static final int FLAG_CURSOR_ANCHOR_INFO_MONITOR = 1; // 0x1
- field public static final int FLAG_CURSOR_RECT_IN_SCREEN_COORDINATES = 2; // 0x2
- field public static final int FLAG_CURSOR_RECT_MONITOR = 1; // 0x1
- field public static final int FLAG_CURSOR_RECT_WITH_VIEW_MATRIX = 4; // 0x4
- field public static final int RESULT_NOT_HANDLED = 0; // 0x0
- field public static final int RESULT_SCHEDULED = 1; // 0x1
- field public static final int TYPE_CURSOR_ANCHOR_INFO = 1; // 0x1
- field public static final int TYPE_CURSOR_RECT = 2; // 0x2
- }
-
public class EditorInfo implements android.text.InputType android.os.Parcelable {
ctor public EditorInfo();
method public int describeContents();
@@ -36369,13 +36350,15 @@ package android.view.inputmethod {
method public abstract boolean performEditorAction(int);
method public abstract boolean performPrivateCommand(java.lang.String, android.os.Bundle);
method public abstract boolean reportFullscreenMode(boolean);
- method public abstract int requestCursorAnchorInfo(android.view.inputmethod.CursorAnchorInfoRequest);
+ method public abstract boolean requestUpdateCursorAnchorInfo(int);
method public abstract boolean sendKeyEvent(android.view.KeyEvent);
method public abstract boolean setComposingRegion(int, int);
method public abstract boolean setComposingText(java.lang.CharSequence, int);
method public abstract boolean setSelection(int, int);
field public static final int GET_EXTRACTED_TEXT_MONITOR = 1; // 0x1
field public static final int GET_TEXT_WITH_STYLES = 1; // 0x1
+ field public static final int REQUEST_UPDATE_CURSOR_ANCHOR_INFO_IMMEDIATE = 1; // 0x1
+ field public static final int REQUEST_UPDATE_CURSOR_ANCHOR_INFO_MONITOR = 2; // 0x2
}
public class InputConnectionWrapper implements android.view.inputmethod.InputConnection {
@@ -36397,7 +36380,7 @@ package android.view.inputmethod {
method public boolean performEditorAction(int);
method public boolean performPrivateCommand(java.lang.String, android.os.Bundle);
method public boolean reportFullscreenMode(boolean);
- method public int requestCursorAnchorInfo(android.view.inputmethod.CursorAnchorInfoRequest);
+ method public boolean requestUpdateCursorAnchorInfo(int);
method public boolean sendKeyEvent(android.view.KeyEvent);
method public boolean setComposingRegion(int, int);
method public boolean setComposingText(java.lang.CharSequence, int);
@@ -36463,7 +36446,7 @@ package android.view.inputmethod {
method public boolean isActive(android.view.View);
method public boolean isActive();
method public boolean isFullscreenMode();
- method public boolean isWatchingCursor(android.view.View);
+ method public deprecated boolean isWatchingCursor(android.view.View);
method public void restartInput(android.view.View);
method public void sendAppPrivateCommand(android.view.View, java.lang.String, android.os.Bundle);
method public void setAdditionalInputMethodSubtypes(java.lang.String, android.view.inputmethod.InputMethodSubtype[]);
@@ -36481,7 +36464,7 @@ package android.view.inputmethod {
method public boolean switchToNextInputMethod(android.os.IBinder, boolean);
method public void toggleSoftInput(int, int);
method public void toggleSoftInputFromWindow(android.os.IBinder, int, int);
- method public void updateCursor(android.view.View, int, int, int, int);
+ method public deprecated void updateCursor(android.view.View, int, int, int, int);
method public void updateCursorAnchorInfo(android.view.View, android.view.inputmethod.CursorAnchorInfo);
method public void updateExtractedText(android.view.View, int, android.view.inputmethod.ExtractedText);
method public void updateSelection(android.view.View, int, int, int, int);
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index ba811b7..2eb42a7 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -53,7 +53,6 @@ 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;
@@ -1711,13 +1710,12 @@ 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 InputConnection#requestCursorAnchorInfo(CursorAnchorInfoRequest)} with
- * {@link CursorAnchorInfoRequest#FLAG_CURSOR_RECT_IN_SCREEN_COORDINATES}. Otherwise,
- * this is in local coordinates.
+ * 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.
+ * @deprecated Use {#link onUpdateCursorAnchorInfo(CursorAnchorInfo)} instead.
*/
+ @Deprecated
public void onUpdateCursor(Rect newCursor) {
// Intentionally empty
}
diff --git a/core/java/android/view/inputmethod/BaseInputConnection.java b/core/java/android/view/inputmethod/BaseInputConnection.java
index 8cae27b..4d2f57a 100644
--- a/core/java/android/view/inputmethod/BaseInputConnection.java
+++ b/core/java/android/view/inputmethod/BaseInputConnection.java
@@ -429,25 +429,10 @@ public class BaseInputConnection implements InputConnection {
}
/**
- * The default implementation is responsible for handling
- * {@link CursorAnchorInfoRequest#TYPE_CURSOR_RECT}. In fact, for derived classes, calling
- * {@code super.requestCursorAnchorInfo(request)} is the only way to handle
- * {@link CursorAnchorInfoRequest#TYPE_CURSOR_RECT}.
+ * The default implementation does nothing.
*/
- public int requestCursorAnchorInfo(CursorAnchorInfoRequest request) {
- // This implementation supports TYPE_CURSOR_RECT only.
- if (request == null ||
- request.getRequestType() != CursorAnchorInfoRequest.TYPE_CURSOR_RECT) {
- return CursorAnchorInfoRequest.RESULT_NOT_HANDLED;
- }
- if (mIMM == null) {
- // In this case, TYPE_CURSOR_RECT is not handled.
- // TODO: Return some notification code for the input method that indicates
- // Cursor rect information is temporarily unavailable.
- return CursorAnchorInfoRequest.RESULT_NOT_HANDLED;
- }
- mIMM.setCursorRectMonitorMode(request.getRequestFlags());
- return CursorAnchorInfoRequest.RESULT_SCHEDULED;
+ public boolean requestUpdateCursorAnchorInfo(int cursorUpdateMode) {
+ return false;
}
/**
diff --git a/core/java/android/view/inputmethod/CursorAnchorInfoRequest.aidl b/core/java/android/view/inputmethod/CursorAnchorInfoRequest.aidl
deleted file mode 100644
index 41ef7cc6..0000000
--- a/core/java/android/view/inputmethod/CursorAnchorInfoRequest.aidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.view.inputmethod;
-
-parcelable CursorAnchorInfoRequest;
diff --git a/core/java/android/view/inputmethod/CursorAnchorInfoRequest.java b/core/java/android/view/inputmethod/CursorAnchorInfoRequest.java
deleted file mode 100644
index e4c94f2..0000000
--- a/core/java/android/view/inputmethod/CursorAnchorInfoRequest.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package android.view.inputmethod;
-
-import android.inputmethodservice.InputMethodService;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.view.View;
-
-/**
- * Used to enable or disable event notification for
- * {@link InputMethodService#onUpdateCursorAnchorInfo(CursorAnchorInfo)}. This class is also used to
- * enable {@link InputMethodService#onUpdateCursor(android.graphics.Rect)} for existing editors
- * that have not supported {@link InputMethodService#onUpdateCursorAnchorInfo(CursorAnchorInfo)}.
- */
-public final class CursorAnchorInfoRequest implements Parcelable {
- private final int mRequestType;
- private final int mRequestFlags;
-
- /**
- * Not handled by the editor.
- */
- public static final int RESULT_NOT_HANDLED = 0x00;
- /**
- * Request is scheduled in the editor task queue.
- */
- public static final int RESULT_SCHEDULED = 0x01;
-
- /**
- * The request is for {@link InputMethodService#onUpdateCursorAnchorInfo(CursorAnchorInfo)}.
- * This mechanism is powerful enough to retrieve fine-grained positional information of
- * characters in the editor.
- */
- public static final int TYPE_CURSOR_ANCHOR_INFO = 0x01;
- /**
- * The editor is requested to call
- * {@link InputMethodManager#updateCursorAnchorInfo(android.view.View, CursorAnchorInfo)}
- * whenever cursor/anchor position is changed. To disable monitoring, call
- * {@link InputConnection#requestCursorAnchorInfo(CursorAnchorInfoRequest)} again with
- * {@link #TYPE_CURSOR_ANCHOR_INFO} and this flag off.
- * <p>
- * This flag can be used together with {@link #FLAG_CURSOR_ANCHOR_INFO_IMMEDIATE}.
- * </p>
- */
- public static final int FLAG_CURSOR_ANCHOR_INFO_MONITOR = 0x01;
- /**
- * The editor is requested to call
- * {@link InputMethodManager#updateCursorAnchorInfo(android.view.View, CursorAnchorInfo)} at
- * once, as soon as possible, regardless of cursor/anchor position changes. This flag can be
- * used together with {@link #FLAG_CURSOR_ANCHOR_INFO_MONITOR}.
- */
- public static final int FLAG_CURSOR_ANCHOR_INFO_IMMEDIATE = 0x02;
-
- /**
- * The request is for {@link InputMethodService#onUpdateCursor(android.graphics.Rect)}. This
- * mechanism has been available since API Level 3 (CUPCAKE) but only the cursor rectangle can
- * be retrieved with this mechanism.
- */
- public static final int TYPE_CURSOR_RECT = 0x02;
- /**
- * The editor is requested to call
- * {@link InputMethodManager#updateCursor(android.view.View, int, int, int, int)}
- * whenever the cursor position is changed. To disable monitoring, call
- * {@link InputConnection#requestCursorAnchorInfo(CursorAnchorInfoRequest)} again with
- * {@link #TYPE_CURSOR_RECT} and this flag off.
- * <p>
- * This flag can be used together with {@link #FLAG_CURSOR_RECT_IN_SCREEN_COORDINATES}.
- * </p>
- */
- public static final int FLAG_CURSOR_RECT_MONITOR = 0x01;
- /**
- * {@link InputMethodManager#updateCursor(android.view.View, int, int, int, int)} should be
- * called back in screen coordinates. To receive cursor position in local coordinates, call
- * {@link InputConnection#requestCursorAnchorInfo(CursorAnchorInfoRequest)} again with
- * {@link #TYPE_CURSOR_RECT} and this flag off.
- */
- public static final int FLAG_CURSOR_RECT_IN_SCREEN_COORDINATES = 0x02;
- /**
- * {@link InputMethodManager#updateCursor(android.view.View, int, int, int, int)} should be
- * called back in screen coordinates after coordinate conversion with {@link View#getMatrix()}.
- * To disable coordinate conversion with {@link View#getMatrix()} again, call
- * {@link InputConnection#requestCursorAnchorInfo(CursorAnchorInfoRequest)} with
- * {@link #TYPE_CURSOR_RECT} and this flag off.
- *
- * <p>
- * The flag is ignored if {@link #FLAG_CURSOR_RECT_IN_SCREEN_COORDINATES} is off.
- * </p>
- */
- public static final int FLAG_CURSOR_RECT_WITH_VIEW_MATRIX = 0x04;
-
- /**
- * Constructs the object with request type and type-specific flags.
- *
- * @param requestType the type of this request. Currently {@link #TYPE_CURSOR_ANCHOR_INFO} or
- * {@link #TYPE_CURSOR_RECT} is supported.
- * @param requestFlags the flags for the given request type.
- */
- public CursorAnchorInfoRequest(int requestType, int requestFlags) {
- mRequestType = requestType;
- mRequestFlags = requestFlags;
- }
-
- /**
- * Used to make this class parcelable.
- *
- * @param source the parcel from which the object is unmarshalled.
- */
- public CursorAnchorInfoRequest(Parcel source) {
- mRequestType = source.readInt();
- mRequestFlags = source.readInt();
- }
-
- /**
- * @return the type of this request.
- */
- public int getRequestType() {
- return mRequestType;
- }
-
- /**
- * @return the flags that are specific to the type of this request.
- */
- public int getRequestFlags() {
- return mRequestFlags;
- }
-
- /**
- * Used to package this object into a {@link Parcel}.
- *
- * @param dest The {@link Parcel} to be written.
- * @param flags The flags used for parceling.
- */
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(mRequestType);
- dest.writeInt(mRequestFlags);
- }
-
- @Override
- public int hashCode(){
- return mRequestType * 31 + mRequestFlags;
- }
-
- @Override
- public boolean equals(Object obj){
- if (obj == null) {
- return false;
- }
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof CursorAnchorInfoRequest)) {
- return false;
- }
- final CursorAnchorInfoRequest that = (CursorAnchorInfoRequest) obj;
- if (hashCode() != that.hashCode()) {
- return false;
- }
- return mRequestType != that.mRequestType && mRequestFlags == that.mRequestFlags;
- }
-
- @Override
- public String toString() {
- return "CursorAnchorInfoRequest{mRequestType=" + mRequestType
- + " mRequestFlags=" + mRequestFlags
- + "}";
- }
-
- /**
- * Used to make this class parcelable.
- */
- public static final Parcelable.Creator<CursorAnchorInfoRequest> CREATOR =
- new Parcelable.Creator<CursorAnchorInfoRequest>() {
- @Override
- public CursorAnchorInfoRequest createFromParcel(Parcel source) {
- return new CursorAnchorInfoRequest(source);
- }
-
- @Override
- public CursorAnchorInfoRequest[] newArray(int size) {
- return new CursorAnchorInfoRequest[size];
- }
- };
-
- @Override
- public int describeContents() {
- return 0;
- }
-}
diff --git a/core/java/android/view/inputmethod/InputConnection.java b/core/java/android/view/inputmethod/InputConnection.java
index dff91dc..ca094c1 100644
--- a/core/java/android/view/inputmethod/InputConnection.java
+++ b/core/java/android/view/inputmethod/InputConnection.java
@@ -725,13 +725,34 @@ public interface InputConnection {
public boolean performPrivateCommand(String action, Bundle data);
/**
- * Called by the IME to ask the editor for calling back
+ * The editor is requested to call
+ * {@link InputMethodManager#updateCursorAnchorInfo(android.view.View, CursorAnchorInfo)} at
+ * once, as soon as possible, regardless of cursor/anchor position changes. This flag can be
+ * used together with {@link #REQUEST_UPDATE_CURSOR_ANCHOR_INFO_MONITOR}.
+ */
+ public static final int REQUEST_UPDATE_CURSOR_ANCHOR_INFO_IMMEDIATE = 1 << 0;
+
+ /**
+ * The editor is requested to call
+ * {@link InputMethodManager#updateCursorAnchorInfo(android.view.View, CursorAnchorInfo)}
+ * whenever cursor/anchor position is changed. To disable monitoring, call
+ * {@link InputConnection#requestUpdateCursorAnchorInfo(int)} again with this flag off.
+ * <p>
+ * This flag can be used together with {@link #REQUEST_UPDATE_CURSOR_ANCHOR_INFO_IMMEDIATE}.
+ * </p>
+ */
+ public static final int REQUEST_UPDATE_CURSOR_ANCHOR_INFO_MONITOR = 1 << 1;
+
+ /**
+ * Called by the input method to ask the editor for calling back
* {@link InputMethodManager#updateCursorAnchorInfo(android.view.View, CursorAnchorInfo)} to
* notify cursor/anchor locations.
*
- * @param request the details of the request.
- * @return a result code that depends on {@link CursorAnchorInfoRequest#getRequestType()}. See
- * {@link CursorAnchorInfoRequest} for details.
+ * @param cursorUpdateMode {@link #REQUEST_UPDATE_CURSOR_ANCHOR_INFO_IMMEDIATE} and/or
+ * {@link #REQUEST_UPDATE_CURSOR_ANCHOR_INFO_MONITOR}
+ * @return {@code true} if the request is scheduled. {@code false} to indicate that when the
+ * application will not call
+ * {@link InputMethodManager#updateCursorAnchorInfo(android.view.View, CursorAnchorInfo)}.
*/
- public int requestCursorAnchorInfo(CursorAnchorInfoRequest request);
+ public boolean requestUpdateCursorAnchorInfo(int cursorUpdateMode);
}
diff --git a/core/java/android/view/inputmethod/InputConnectionWrapper.java b/core/java/android/view/inputmethod/InputConnectionWrapper.java
index c831d7c..d95df25 100644
--- a/core/java/android/view/inputmethod/InputConnectionWrapper.java
+++ b/core/java/android/view/inputmethod/InputConnectionWrapper.java
@@ -126,7 +126,7 @@ public class InputConnectionWrapper implements InputConnection {
return mTarget.performPrivateCommand(action, data);
}
- public int requestCursorAnchorInfo(CursorAnchorInfoRequest request) {
- return mTarget.requestCursorAnchorInfo(request);
+ public boolean requestUpdateCursorAnchorInfo(int cursorUpdateMode) {
+ return mTarget.requestUpdateCursorAnchorInfo(cursorUpdateMode);
}
}
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index eec3570..0a472c7 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -313,9 +313,8 @@ public final class InputMethodManager {
CompletionInfo[] mCompletions;
// Cursor position on the screen.
- Rect mNextCursorRect = new Rect();
+ Rect mTmpCursorRect = new Rect();
Rect mCursorRect = new Rect();
- RectF mTempRectF = new RectF();
int mCursorSelStart;
int mCursorSelEnd;
int mCursorCandStart;
@@ -372,28 +371,12 @@ public final class InputMethodManager {
InputChannel mCurChannel;
ImeInputEventSender mCurSender;
- private static final int CURSOR_RECT_MONITOR_MODE_NONE = 0x0;
-
- private static final int CURSOR_RECT_MONITOR_FLAG_MASK =
- CursorAnchorInfoRequest.FLAG_CURSOR_RECT_MONITOR |
- CursorAnchorInfoRequest.FLAG_CURSOR_RECT_IN_SCREEN_COORDINATES |
- CursorAnchorInfoRequest.FLAG_CURSOR_RECT_WITH_VIEW_MATRIX;
-
- private static final int CURSOR_ANCHOR_INFO_MONITOR_MODE_NONE = 0x0;
-
- private static final int CURSOR_ANCHOR_INFO_MONITOR_FLAG_MASK =
- CursorAnchorInfoRequest.FLAG_CURSOR_ANCHOR_INFO_MONITOR |
- CursorAnchorInfoRequest.FLAG_CURSOR_ANCHOR_INFO_IMMEDIATE;
-
- /**
- * The monitor mode for {@link #updateCursor(View, int, int, int, int)}.
- */
- private int mCursorRectMonitorMode = CURSOR_RECT_MONITOR_MODE_NONE;
+ private static final int REQUEST_UPDATE_CURSOR_ANCHOR_INFO_NONE = 0x0;
/**
* The monitor mode for {@link #updateCursorAnchorInfo(View, CursorAnchorInfo)}.
*/
- private int mCursorAnchorInfoMonitorMode = CURSOR_ANCHOR_INFO_MONITOR_MODE_NONE;
+ private int mRequestUpdateCursorAnchorInfoMonitorMode = REQUEST_UPDATE_CURSOR_ANCHOR_INFO_NONE;
final Pool<PendingEvent> mPendingEventPool = new SimplePool<PendingEvent>(20);
final SparseArray<PendingEvent> mPendingEvents = new SparseArray<PendingEvent>(20);
@@ -446,8 +429,8 @@ public final class InputMethodManager {
return;
}
- mCursorAnchorInfoMonitorMode = CURSOR_ANCHOR_INFO_MONITOR_MODE_NONE;
- mCursorRectMonitorMode = CURSOR_RECT_MONITOR_MODE_NONE;
+ mRequestUpdateCursorAnchorInfoMonitorMode =
+ REQUEST_UPDATE_CURSOR_ANCHOR_INFO_NONE;
setInputChannelLocked(res.channel);
mCurMethod = res.method;
@@ -1540,59 +1523,49 @@ public final class InputMethodManager {
}
/**
- * Returns true if the current input method wants to watch the location
+ * Return true if the current input method wants to watch the location
* of the input editor's cursor in its window.
- */
- public boolean isWatchingCursor(View view) {
- if (!isActive(view)) {
- return false;
- }
- synchronized (mH) {
- return (mCursorRectMonitorMode & CursorAnchorInfoRequest.FLAG_CURSOR_RECT_MONITOR) != 0;
- }
- }
-
- /**
- * Updates the result of {@link #isWatchingCursor(View)}.
*
- * @hide
+ * @deprecated Use {@link InputConnection#requestUpdateCursorAnchorInfo(int)} instead.
*/
- public void setCursorRectMonitorMode(int flags) {
- synchronized (mH) {
- mCursorRectMonitorMode = (CURSOR_RECT_MONITOR_FLAG_MASK & flags);
- }
+ @Deprecated
+ public boolean isWatchingCursor(View view) {
+ return false;
}
/**
- * Returns true if the current input method wants to be notified when cursor/anchor location
+ * Return true if the current input method wants to be notified when cursor/anchor location
* is changed.
*
* @hide
*/
public boolean isCursorAnchorInfoEnabled() {
synchronized (mH) {
- final boolean isImmediate = (mCursorAnchorInfoMonitorMode &
- CursorAnchorInfoRequest.FLAG_CURSOR_ANCHOR_INFO_IMMEDIATE) != 0;
- final boolean isMonitoring = (mCursorAnchorInfoMonitorMode &
- CursorAnchorInfoRequest.FLAG_CURSOR_ANCHOR_INFO_MONITOR) != 0;
+ final boolean isImmediate = (mRequestUpdateCursorAnchorInfoMonitorMode &
+ InputConnection.REQUEST_UPDATE_CURSOR_ANCHOR_INFO_IMMEDIATE) != 0;
+ final boolean isMonitoring = (mRequestUpdateCursorAnchorInfoMonitorMode &
+ InputConnection.REQUEST_UPDATE_CURSOR_ANCHOR_INFO_MONITOR) != 0;
return isImmediate || isMonitoring;
}
}
/**
- * Updates the result of {@link #isWatchingCursor(View)}.
+ * Set the requested mode for {@link #updateCursorAnchorInfo(View, CursorAnchorInfo)}.
*
* @hide
*/
- public void setCursorAnchorInfoMonitorMode(int flags) {
+ public void setUpdateCursorAnchorInfoMode(int flags) {
synchronized (mH) {
- mCursorAnchorInfoMonitorMode = (CURSOR_ANCHOR_INFO_MONITOR_FLAG_MASK & flags);
+ mRequestUpdateCursorAnchorInfoMonitorMode = flags;
}
}
/**
* Report the current cursor location in its window.
+ *
+ * @deprecated Use {@link #updateCursorAnchorInfo(View, CursorAnchorInfo)} instead.
*/
+ @Deprecated
public void updateCursor(View view, int left, int top, int right, int bottom) {
checkFocus();
synchronized (mH) {
@@ -1601,33 +1574,15 @@ public final class InputMethodManager {
|| mCurrentTextBoxAttribute == null || mCurMethod == null) {
return;
}
- if (DEBUG) Log.d(TAG, "updateCursor");
- final boolean usesScreenCoordinates = (mCursorRectMonitorMode &
- CursorAnchorInfoRequest.FLAG_CURSOR_RECT_IN_SCREEN_COORDINATES) != 0;
- if (usesScreenCoordinates) {
- view.getLocationOnScreen(mViewTopLeft);
- final Matrix viewMatrix = view.getMatrix();
- final boolean usesViewMatrix = (viewMatrix != null) && ((mCursorRectMonitorMode &
- CursorAnchorInfoRequest.FLAG_CURSOR_RECT_WITH_VIEW_MATRIX) != 0);
- if (usesViewMatrix) {
- mTempRectF.set(left, top, right, bottom);
- mViewToScreenMatrix.set(viewMatrix);
- mViewToScreenMatrix.postTranslate(mViewTopLeft[0], mViewTopLeft[1]);
- mViewToScreenMatrix.mapRect(mTempRectF);
- mNextCursorRect.set((int)mTempRectF.left, (int)mTempRectF.top,
- (int)mTempRectF.right, (int)mTempRectF.bottom);
- } else {
- mNextCursorRect.set(left + mViewTopLeft[0], top + mViewTopLeft[1],
- right + mViewTopLeft[0], bottom + mViewTopLeft[1]);
- }
- } else {
- mNextCursorRect.set(left, top, right, bottom);
- }
- if (!Objects.equals(mCursorRect, mNextCursorRect)) {
- if (DEBUG) Log.v(TAG, "CURSOR CHANGE: " + mNextCursorRect);
+
+ mTmpCursorRect.set(left, top, right, bottom);
+ if (!mCursorRect.equals(mTmpCursorRect)) {
+ if (DEBUG) Log.d(TAG, "updateCursor");
+
try {
- mCurMethod.updateCursor(mNextCursorRect);
- mCursorRect.set(mNextCursorRect);
+ if (DEBUG) Log.v(TAG, "CURSOR CHANGE: " + mCurMethod);
+ mCurMethod.updateCursor(mTmpCursorRect);
+ mCursorRect.set(mTmpCursorRect);
} catch (RemoteException e) {
Log.w(TAG, "IME died: " + mCurId, e);
}
@@ -1652,8 +1607,8 @@ public final class InputMethodManager {
}
// If immediate bit is set, we will call updateCursorAnchorInfo() even when the data has
// not been changed from the previous call.
- final boolean isImmediate = (mCursorAnchorInfoMonitorMode &
- CursorAnchorInfoRequest.FLAG_CURSOR_ANCHOR_INFO_IMMEDIATE) != 0;
+ final boolean isImmediate = (mRequestUpdateCursorAnchorInfoMonitorMode &
+ InputConnection.REQUEST_UPDATE_CURSOR_ANCHOR_INFO_IMMEDIATE) != 0;
if (!isImmediate && Objects.equals(mCursorAnchorInfo, cursorAnchorInfo)) {
// TODO: Consider always emitting this message once we have addressed redundant
// calls of this method from android.widget.Editor.
@@ -1668,8 +1623,8 @@ public final class InputMethodManager {
mCurMethod.updateCursorAnchorInfo(cursorAnchorInfo);
mCursorAnchorInfo = cursorAnchorInfo;
// Clear immediate bit (if any).
- mCursorAnchorInfoMonitorMode &=
- ~CursorAnchorInfoRequest.FLAG_CURSOR_ANCHOR_INFO_IMMEDIATE;
+ mRequestUpdateCursorAnchorInfoMonitorMode &=
+ ~InputConnection.REQUEST_UPDATE_CURSOR_ANCHOR_INFO_IMMEDIATE;
} catch (RemoteException e) {
Log.w(TAG, "IME died: " + mCurId, e);
}
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index 60ef693..eb93745 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -65,7 +65,6 @@ import android.view.animation.LinearInterpolator;
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.CorrectionInfo;
-import android.view.inputmethod.CursorAnchorInfoRequest;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.ExtractedText;
import android.view.inputmethod.ExtractedTextRequest;
@@ -5718,8 +5717,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
}
@Override
- public int requestCursorAnchorInfo(CursorAnchorInfoRequest request) {
- return getTarget().requestCursorAnchorInfo(request);
+ public boolean requestUpdateCursorAnchorInfo(int cursorUpdateMode) {
+ return getTarget().requestUpdateCursorAnchorInfo(cursorUpdateMode);
}
}
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index 3f5f045..29c8298 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -1298,25 +1298,6 @@ public class Editor {
reported = reportExtractedText();
}
}
-
- if (imm.isWatchingCursor(mTextView) && highlight != null) {
- highlight.computeBounds(ims.mTmpRectF, true);
- ims.mTmpOffset[0] = ims.mTmpOffset[1] = 0;
-
- canvas.getMatrix().mapPoints(ims.mTmpOffset);
- ims.mTmpRectF.offset(ims.mTmpOffset[0], ims.mTmpOffset[1]);
-
- ims.mTmpRectF.offset(0, cursorOffsetVertical);
-
- ims.mCursorRectInWindow.set((int)(ims.mTmpRectF.left + 0.5),
- (int)(ims.mTmpRectF.top + 0.5),
- (int)(ims.mTmpRectF.right + 0.5),
- (int)(ims.mTmpRectF.bottom + 0.5));
-
- imm.updateCursor(mTextView,
- ims.mCursorRectInWindow.left, ims.mCursorRectInWindow.top,
- ims.mCursorRectInWindow.right, ims.mCursorRectInWindow.bottom);
- }
}
}
@@ -4136,7 +4117,6 @@ public class Editor {
static class InputMethodState {
Rect mCursorRectInWindow = new Rect();
- RectF mTmpRectF = new RectF();
float[] mTmpOffset = new float[2];
ExtractedTextRequest mExtractedTextRequest;
final ExtractedText mExtractedText = new ExtractedText();
diff --git a/core/java/com/android/internal/view/IInputConnectionWrapper.java b/core/java/com/android/internal/view/IInputConnectionWrapper.java
index 897381d..b1f5d90 100644
--- a/core/java/com/android/internal/view/IInputConnectionWrapper.java
+++ b/core/java/com/android/internal/view/IInputConnectionWrapper.java
@@ -25,7 +25,6 @@ import android.util.Log;
import android.view.KeyEvent;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.CorrectionInfo;
-import android.view.inputmethod.CursorAnchorInfoRequest;
import android.view.inputmethod.ExtractedTextRequest;
import android.view.inputmethod.InputConnection;
@@ -55,7 +54,7 @@ public class IInputConnectionWrapper extends IInputContext.Stub {
private static final int DO_REPORT_FULLSCREEN_MODE = 100;
private static final int DO_PERFORM_PRIVATE_COMMAND = 120;
private static final int DO_CLEAR_META_KEY_STATES = 130;
- private static final int DO_REQUEST_CURSOR_ANCHOR_INFO = 140;
+ private static final int DO_REQUEST_UPDATE_CURSOR_ANCHOR_INFO = 140;
private WeakReference<InputConnection> mInputConnection;
@@ -177,9 +176,10 @@ public class IInputConnectionWrapper extends IInputContext.Stub {
dispatchMessage(obtainMessageOO(DO_PERFORM_PRIVATE_COMMAND, action, data));
}
- public void requestCursorAnchorInfo(CursorAnchorInfoRequest request, int seq,
+ public void requestUpdateCursorAnchorInfo(int cursorUpdateMode, int seq,
IInputContextCallback callback) {
- dispatchMessage(obtainMessageOSC(DO_REQUEST_CURSOR_ANCHOR_INFO, request, seq, callback));
+ dispatchMessage(obtainMessageISC(DO_REQUEST_UPDATE_CURSOR_ANCHOR_INFO, cursorUpdateMode,
+ seq, callback));
}
void dispatchMessage(Message msg) {
@@ -427,18 +427,17 @@ public class IInputConnectionWrapper extends IInputContext.Stub {
(Bundle)args.arg2);
return;
}
- case DO_REQUEST_CURSOR_ANCHOR_INFO: {
+ case DO_REQUEST_UPDATE_CURSOR_ANCHOR_INFO: {
SomeArgs args = (SomeArgs)msg.obj;
try {
InputConnection ic = mInputConnection.get();
if (ic == null || !isActive()) {
Log.w(TAG, "requestCursorAnchorInfo on inactive InputConnection");
- args.callback.setRequestCursorAnchorInfoResult(0, args.seq);
+ args.callback.setRequestUpdateCursorAnchorInfoResult(false, args.seq);
return;
}
- args.callback.setRequestCursorAnchorInfoResult(
- ic.requestCursorAnchorInfo((CursorAnchorInfoRequest)args.arg1),
- args.seq);
+ args.callback.setRequestUpdateCursorAnchorInfoResult(
+ ic.requestUpdateCursorAnchorInfo(msg.arg1), args.seq);
} catch (RemoteException e) {
Log.w(TAG, "Got RemoteException calling requestCursorAnchorInfo", e);
}
diff --git a/core/java/com/android/internal/view/IInputContext.aidl b/core/java/com/android/internal/view/IInputContext.aidl
index c06596a..fd2b513 100644
--- a/core/java/com/android/internal/view/IInputContext.aidl
+++ b/core/java/com/android/internal/view/IInputContext.aidl
@@ -20,7 +20,6 @@ import android.os.Bundle;
import android.view.KeyEvent;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.CorrectionInfo;
-import android.view.inputmethod.CursorAnchorInfoRequest;
import android.view.inputmethod.ExtractedTextRequest;
import com.android.internal.view.IInputContextCallback;
@@ -74,6 +73,6 @@ import com.android.internal.view.IInputContextCallback;
void getSelectedText(int flags, int seq, IInputContextCallback callback);
- void requestCursorAnchorInfo(in CursorAnchorInfoRequest request, int seq,
+ void requestUpdateCursorAnchorInfo(in int cursorUpdateMode, int seq,
IInputContextCallback callback);
}
diff --git a/core/java/com/android/internal/view/IInputContextCallback.aidl b/core/java/com/android/internal/view/IInputContextCallback.aidl
index ab2fbdc..54ea306 100644
--- a/core/java/com/android/internal/view/IInputContextCallback.aidl
+++ b/core/java/com/android/internal/view/IInputContextCallback.aidl
@@ -27,5 +27,5 @@ oneway interface IInputContextCallback {
void setCursorCapsMode(int capsMode, int seq);
void setExtractedText(in ExtractedText extractedText, int seq);
void setSelectedText(CharSequence selectedText, int seq);
- void setRequestCursorAnchorInfoResult(int result, int seq);
+ void setRequestUpdateCursorAnchorInfoResult(boolean result, int seq);
}
diff --git a/core/java/com/android/internal/view/InputConnectionWrapper.java b/core/java/com/android/internal/view/InputConnectionWrapper.java
index 8535a98..a8526c8 100644
--- a/core/java/com/android/internal/view/InputConnectionWrapper.java
+++ b/core/java/com/android/internal/view/InputConnectionWrapper.java
@@ -23,7 +23,6 @@ import android.util.Log;
import android.view.KeyEvent;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.CorrectionInfo;
-import android.view.inputmethod.CursorAnchorInfoRequest;
import android.view.inputmethod.ExtractedText;
import android.view.inputmethod.ExtractedTextRequest;
import android.view.inputmethod.InputConnection;
@@ -41,7 +40,7 @@ public class InputConnectionWrapper implements InputConnection {
public CharSequence mSelectedText;
public ExtractedText mExtractedText;
public int mCursorCapsMode;
- public int mCursorAnchorInfoRequestResult;
+ public boolean mRequestUpdateCursorAnchorInfoResult;
// A 'pool' of one InputContextCallback. Each ICW request will attempt to gain
// exclusive access to this object.
@@ -155,10 +154,10 @@ public class InputConnectionWrapper implements InputConnection {
}
}
- public void setRequestCursorAnchorInfoResult(int result, int seq) {
+ public void setRequestUpdateCursorAnchorInfoResult(boolean result, int seq) {
synchronized (this) {
if (seq == mSeq) {
- mCursorAnchorInfoRequestResult = result;
+ mRequestUpdateCursorAnchorInfoResult = result;
mHaveValue = true;
notifyAll();
} else {
@@ -429,21 +428,21 @@ public class InputConnectionWrapper implements InputConnection {
}
}
- public int requestCursorAnchorInfo(CursorAnchorInfoRequest request) {
- int value = CursorAnchorInfoRequest.RESULT_NOT_HANDLED;
+ public boolean requestUpdateCursorAnchorInfo(int cursorUpdateMode) {
+ boolean result = false;
try {
InputContextCallback callback = InputContextCallback.getInstance();
- mIInputContext.requestCursorAnchorInfo(request, callback.mSeq, callback);
+ mIInputContext.requestUpdateCursorAnchorInfo(cursorUpdateMode, callback.mSeq, callback);
synchronized (callback) {
callback.waitForResultLocked();
if (callback.mHaveValue) {
- value = callback.mCursorAnchorInfoRequestResult;
+ result = callback.mRequestUpdateCursorAnchorInfoResult;
}
}
callback.dispose();
} catch (RemoteException e) {
- return CursorAnchorInfoRequest.RESULT_NOT_HANDLED;
+ return false;
}
- return value;
+ return result;
}
}
diff --git a/core/java/com/android/internal/widget/EditableInputConnection.java b/core/java/com/android/internal/widget/EditableInputConnection.java
index bfe0090..2967938 100644
--- a/core/java/com/android/internal/widget/EditableInputConnection.java
+++ b/core/java/com/android/internal/widget/EditableInputConnection.java
@@ -25,9 +25,9 @@ import android.util.Log;
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.CorrectionInfo;
-import android.view.inputmethod.CursorAnchorInfoRequest;
import android.view.inputmethod.ExtractedText;
import android.view.inputmethod.ExtractedTextRequest;
+import android.view.inputmethod.InputConnection;
import android.widget.TextView;
public class EditableInputConnection extends BaseInputConnection {
@@ -188,24 +188,17 @@ public class EditableInputConnection extends BaseInputConnection {
}
@Override
- public int requestCursorAnchorInfo(CursorAnchorInfoRequest request) {
- if (DEBUG) Log.v(TAG, "requestCursorAnchorInfo " + request);
-
- // This implementation supports TYPE_CURSOR_ANCHOR_INFO only. Other events will be
- // delegated to the super class.
- if (request == null ||
- request.getRequestType() != CursorAnchorInfoRequest.TYPE_CURSOR_ANCHOR_INFO) {
- return super.requestCursorAnchorInfo(request);
- }
+ public boolean requestUpdateCursorAnchorInfo(int cursorUpdateMode) {
+ if (DEBUG) Log.v(TAG, "requestUpdateCursorAnchorInfo " + cursorUpdateMode);
+
if (mIMM == null) {
// In this case, TYPE_CURSOR_ANCHOR_INFO is not handled.
- // TODO: Return some notification code for the input method that indicates
+ // TODO: Return some notification code rather than false to indicate method that
// CursorAnchorInfo is temporarily unavailable.
- return CursorAnchorInfoRequest.RESULT_NOT_HANDLED;
+ return false;
}
- final int flags = request.getRequestFlags();
- mIMM.setCursorAnchorInfoMonitorMode(flags);
- if ((flags & CursorAnchorInfoRequest.FLAG_CURSOR_ANCHOR_INFO_IMMEDIATE) != 0) {
+ mIMM.setUpdateCursorAnchorInfoMode(cursorUpdateMode);
+ if ((cursorUpdateMode & InputConnection.REQUEST_UPDATE_CURSOR_ANCHOR_INFO_IMMEDIATE) != 0) {
if (mTextView == null) {
// In this case, FLAG_CURSOR_ANCHOR_INFO_IMMEDIATE is silently ignored.
// TODO: Return some notification code for the input method that indicates
@@ -220,6 +213,6 @@ public class EditableInputConnection extends BaseInputConnection {
mTextView.requestLayout();
}
}
- return CursorAnchorInfoRequest.RESULT_SCHEDULED;
+ return true;
}
}