am d88a1f97: am ebb6b422: Merge "API Review: InputConnection" into lmp-dev
* commit 'd88a1f9790bfaaa6540f65d76827274d716a2539': API Review: InputConnection
This commit is contained in:
@@ -431,7 +431,15 @@ public class BaseInputConnection implements InputConnection {
|
||||
/**
|
||||
* The default implementation does nothing.
|
||||
*/
|
||||
public boolean requestUpdateCursorAnchorInfo(int cursorUpdateMode) {
|
||||
public boolean requestCursorUpdates(int cursorUpdateMode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default implementation does nothing.
|
||||
* @removed
|
||||
*/
|
||||
public final boolean requestUpdateCursorAnchorInfo(int cursorUpdateMode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -728,31 +728,47 @@ public interface InputConnection {
|
||||
* 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}.
|
||||
* used together with {@link #CURSOR_UPDATE_MONITOR}.
|
||||
*/
|
||||
public static final int REQUEST_UPDATE_CURSOR_ANCHOR_INFO_IMMEDIATE = 1 << 0;
|
||||
public static final int CURSOR_UPDATE_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.
|
||||
* {@link InputConnection#requestCursorUpdates(int)} again with this flag off.
|
||||
* <p>
|
||||
* This flag can be used together with {@link #REQUEST_UPDATE_CURSOR_ANCHOR_INFO_IMMEDIATE}.
|
||||
* This flag can be used together with {@link #CURSOR_UPDATE_IMMEDIATE}.
|
||||
* </p>
|
||||
*/
|
||||
public static final int REQUEST_UPDATE_CURSOR_ANCHOR_INFO_MONITOR = 1 << 1;
|
||||
public static final int CURSOR_UPDATE_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 cursorUpdateMode {@link #REQUEST_UPDATE_CURSOR_ANCHOR_INFO_IMMEDIATE} and/or
|
||||
* {@link #REQUEST_UPDATE_CURSOR_ANCHOR_INFO_MONITOR}
|
||||
* @param cursorUpdateMode {@link #CURSOR_UPDATE_IMMEDIATE} and/or
|
||||
* {@link #CURSOR_UPDATE_MONITOR}. Pass {@code 0} to disable the effect of
|
||||
* {@link #CURSOR_UPDATE_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 boolean requestCursorUpdates(int cursorUpdateMode);
|
||||
|
||||
/**
|
||||
* @removed
|
||||
*/
|
||||
public static final int REQUEST_UPDATE_CURSOR_UPDATE_IMMEDIATE = 1 << 0;
|
||||
|
||||
/**
|
||||
* @removed
|
||||
*/
|
||||
public static final int REQUEST_UPDATE_CURSOR_ANCHOR_INFO_MONITOR = 1 << 1;
|
||||
|
||||
/**
|
||||
* @removed
|
||||
*/
|
||||
public boolean requestUpdateCursorAnchorInfo(int cursorUpdateMode);
|
||||
}
|
||||
|
||||
@@ -126,7 +126,14 @@ public class InputConnectionWrapper implements InputConnection {
|
||||
return mTarget.performPrivateCommand(action, data);
|
||||
}
|
||||
|
||||
public boolean requestUpdateCursorAnchorInfo(int cursorUpdateMode) {
|
||||
return mTarget.requestUpdateCursorAnchorInfo(cursorUpdateMode);
|
||||
public boolean requestCursorUpdates(int cursorUpdateMode) {
|
||||
return mTarget.requestCursorUpdates(cursorUpdateMode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @removed
|
||||
*/
|
||||
public final boolean requestUpdateCursorAnchorInfo(int cursorUpdateMode) {
|
||||
return mTarget.requestCursorUpdates(cursorUpdateMode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1526,7 +1526,7 @@ public final class InputMethodManager {
|
||||
* Return true if the current input method wants to watch the location
|
||||
* of the input editor's cursor in its window.
|
||||
*
|
||||
* @deprecated Use {@link InputConnection#requestUpdateCursorAnchorInfo(int)} instead.
|
||||
* @deprecated Use {@link InputConnection#requestCursorUpdates(int)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isWatchingCursor(View view) {
|
||||
@@ -1542,9 +1542,9 @@ public final class InputMethodManager {
|
||||
public boolean isCursorAnchorInfoEnabled() {
|
||||
synchronized (mH) {
|
||||
final boolean isImmediate = (mRequestUpdateCursorAnchorInfoMonitorMode &
|
||||
InputConnection.REQUEST_UPDATE_CURSOR_ANCHOR_INFO_IMMEDIATE) != 0;
|
||||
InputConnection.CURSOR_UPDATE_IMMEDIATE) != 0;
|
||||
final boolean isMonitoring = (mRequestUpdateCursorAnchorInfoMonitorMode &
|
||||
InputConnection.REQUEST_UPDATE_CURSOR_ANCHOR_INFO_MONITOR) != 0;
|
||||
InputConnection.CURSOR_UPDATE_MONITOR) != 0;
|
||||
return isImmediate || isMonitoring;
|
||||
}
|
||||
}
|
||||
@@ -1608,7 +1608,7 @@ 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 = (mRequestUpdateCursorAnchorInfoMonitorMode &
|
||||
InputConnection.REQUEST_UPDATE_CURSOR_ANCHOR_INFO_IMMEDIATE) != 0;
|
||||
InputConnection.CURSOR_UPDATE_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.
|
||||
@@ -1624,7 +1624,7 @@ public final class InputMethodManager {
|
||||
mCursorAnchorInfo = cursorAnchorInfo;
|
||||
// Clear immediate bit (if any).
|
||||
mRequestUpdateCursorAnchorInfoMonitorMode &=
|
||||
~InputConnection.REQUEST_UPDATE_CURSOR_ANCHOR_INFO_IMMEDIATE;
|
||||
~InputConnection.CURSOR_UPDATE_IMMEDIATE;
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "IME died: " + mCurId, e);
|
||||
}
|
||||
|
||||
@@ -5718,9 +5718,17 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
||||
return getTarget().performPrivateCommand(action, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requestCursorUpdates(int cursorUpdateMode) {
|
||||
return getTarget().requestCursorUpdates(cursorUpdateMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @removed
|
||||
*/
|
||||
@Override
|
||||
public boolean requestUpdateCursorAnchorInfo(int cursorUpdateMode) {
|
||||
return getTarget().requestUpdateCursorAnchorInfo(cursorUpdateMode);
|
||||
return getTarget().requestCursorUpdates(cursorUpdateMode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -437,7 +437,7 @@ public class IInputConnectionWrapper extends IInputContext.Stub {
|
||||
return;
|
||||
}
|
||||
args.callback.setRequestUpdateCursorAnchorInfoResult(
|
||||
ic.requestUpdateCursorAnchorInfo(msg.arg1), args.seq);
|
||||
ic.requestCursorUpdates(msg.arg1), args.seq);
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Got RemoteException calling requestCursorAnchorInfo", e);
|
||||
}
|
||||
|
||||
@@ -428,7 +428,7 @@ public class InputConnectionWrapper implements InputConnection {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean requestUpdateCursorAnchorInfo(int cursorUpdateMode) {
|
||||
public boolean requestCursorUpdates(int cursorUpdateMode) {
|
||||
boolean result = false;
|
||||
try {
|
||||
InputContextCallback callback = InputContextCallback.getInstance();
|
||||
@@ -445,4 +445,11 @@ public class InputConnectionWrapper implements InputConnection {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @removed
|
||||
*/
|
||||
public boolean requestUpdateCursorAnchorInfo(int cursorUpdateMode) {
|
||||
return requestCursorUpdates(cursorUpdateMode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,13 +188,13 @@ public class EditableInputConnection extends BaseInputConnection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requestUpdateCursorAnchorInfo(int cursorUpdateMode) {
|
||||
public boolean requestCursorUpdates(int cursorUpdateMode) {
|
||||
if (DEBUG) Log.v(TAG, "requestUpdateCursorAnchorInfo " + cursorUpdateMode);
|
||||
|
||||
// It is possible that any other bit is used as a valid flag in a future release.
|
||||
// We should reject the entire request in such a case.
|
||||
final int KNOWN_FLAGS_MASK = InputConnection.REQUEST_UPDATE_CURSOR_ANCHOR_INFO_IMMEDIATE |
|
||||
InputConnection.REQUEST_UPDATE_CURSOR_ANCHOR_INFO_MONITOR;
|
||||
final int KNOWN_FLAGS_MASK = InputConnection.CURSOR_UPDATE_IMMEDIATE |
|
||||
InputConnection.CURSOR_UPDATE_MONITOR;
|
||||
final int unknownFlags = cursorUpdateMode & ~KNOWN_FLAGS_MASK;
|
||||
if (unknownFlags != 0) {
|
||||
if (DEBUG) {
|
||||
@@ -212,7 +212,7 @@ public class EditableInputConnection extends BaseInputConnection {
|
||||
return false;
|
||||
}
|
||||
mIMM.setUpdateCursorAnchorInfoMode(cursorUpdateMode);
|
||||
if ((cursorUpdateMode & InputConnection.REQUEST_UPDATE_CURSOR_ANCHOR_INFO_IMMEDIATE) != 0) {
|
||||
if ((cursorUpdateMode & InputConnection.CURSOR_UPDATE_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
|
||||
|
||||
Reference in New Issue
Block a user