am 310da35c: Merge "Follow up API signature change" into lmp-dev

* commit '310da35c77779f399e12c1e4365e6372d1477ef3':
  Follow up API signature change
main
Yohei Yukawa 2014-09-03 14:35:36 +00:00 committed by Android Git Automerger
commit f2c509a81e
3 changed files with 19 additions and 21 deletions

View File

@ -21,30 +21,29 @@ import android.view.inputmethod.InputMethodManager;
public final class InputConnectionCompatUtils { public final class InputConnectionCompatUtils {
private static final CompatUtils.ClassWrapper sInputConnectionType; private static final CompatUtils.ClassWrapper sInputConnectionType;
private static final CompatUtils.ToBooleanMethodWrapper sRequestUpdateCursorAnchorInfoMethod; private static final CompatUtils.ToBooleanMethodWrapper sRequestCursorUpdatesMethod;
static { static {
sInputConnectionType = new CompatUtils.ClassWrapper(InputConnection.class); sInputConnectionType = new CompatUtils.ClassWrapper(InputConnection.class);
sRequestUpdateCursorAnchorInfoMethod = sInputConnectionType.getPrimitiveMethod( sRequestCursorUpdatesMethod = sInputConnectionType.getPrimitiveMethod(
"requestUpdateCursorAnchorInfo", false, int.class); "requestCursorUpdates", false, int.class);
} }
public static boolean isRequestUpdateCursorAnchorInfoAvailable() { public static boolean isRequestCursorUpdatesAvailable() {
return sRequestUpdateCursorAnchorInfoMethod != null; return sRequestCursorUpdatesMethod != null;
} }
/** /**
* Local copies of some constants in CursorAnchorInfoRequest until the SDK becomes publicly * Local copies of some constants in InputConnection until the SDK becomes publicly available.
* available.
*/ */
private static int REQUEST_UPDATE_CURSOR_UPDATE_IMMEDIATE = 1 << 0; private static int CURSOR_UPDATE_IMMEDIATE = 1 << 0;
private static int REQUEST_UPDATE_CURSOR_UPDATE_MONITOR = 1 << 1; private static int CURSOR_UPDATE_MONITOR = 1 << 1;
private static boolean requestUpdateCursorAnchorInfoImpl(final InputConnection inputConnection, private static boolean requestCursorUpdatesImpl(final InputConnection inputConnection,
final int cursorUpdateMode) { final int cursorUpdateMode) {
if (!isRequestUpdateCursorAnchorInfoAvailable()) { if (!isRequestCursorUpdatesAvailable()) {
return false; return false;
} }
return sRequestUpdateCursorAnchorInfoMethod.invoke(inputConnection, cursorUpdateMode); return sRequestCursorUpdatesMethod.invoke(inputConnection, cursorUpdateMode);
} }
/** /**
@ -56,11 +55,10 @@ public final class InputConnectionCompatUtils {
* as soon as possible to notify the current cursor/anchor position to the input method. * as soon as possible to notify the current cursor/anchor position to the input method.
* @return {@code false} if the request is not handled. Otherwise returns {@code true}. * @return {@code false} if the request is not handled. Otherwise returns {@code true}.
*/ */
public static boolean requestUpdateCursorAnchorInfo(final InputConnection inputConnection, public static boolean requestCursorUpdates(final InputConnection inputConnection,
final boolean enableMonitor, final boolean requestImmediateCallback) { final boolean enableMonitor, final boolean requestImmediateCallback) {
final int cursorUpdateMode = (enableMonitor ? REQUEST_UPDATE_CURSOR_UPDATE_MONITOR : 0) final int cursorUpdateMode = (enableMonitor ? CURSOR_UPDATE_MONITOR : 0)
| (requestImmediateCallback ? REQUEST_UPDATE_CURSOR_UPDATE_IMMEDIATE : 0); | (requestImmediateCallback ? CURSOR_UPDATE_IMMEDIATE : 0);
return requestUpdateCursorAnchorInfoImpl(inputConnection, cursorUpdateMode); return requestCursorUpdatesImpl(inputConnection, cursorUpdateMode);
} }
} }

View File

@ -922,13 +922,13 @@ public final class RichInputConnection {
* prevents the application from fulfilling the request. (TODO: Improve the API when it turns * prevents the application from fulfilling the request. (TODO: Improve the API when it turns
* out that we actually need more detailed error codes) * out that we actually need more detailed error codes)
*/ */
public boolean requestUpdateCursorAnchorInfo(final boolean enableMonitor, public boolean requestCursorUpdates(final boolean enableMonitor,
final boolean requestImmediateCallback) { final boolean requestImmediateCallback) {
mIC = mParent.getCurrentInputConnection(); mIC = mParent.getCurrentInputConnection();
final boolean scheduled; final boolean scheduled;
if (null != mIC) { if (null != mIC) {
scheduled = InputConnectionCompatUtils.requestUpdateCursorAnchorInfo(mIC, scheduled = InputConnectionCompatUtils.requestCursorUpdates(mIC, enableMonitor,
enableMonitor, requestImmediateCallback); requestImmediateCallback);
} else { } else {
scheduled = false; scheduled = false;
} }

View File

@ -167,7 +167,7 @@ public final class InputLogic {
if (ProductionFlags.ENABLE_CURSOR_ANCHOR_INFO_CALLBACK) { if (ProductionFlags.ENABLE_CURSOR_ANCHOR_INFO_CALLBACK) {
// AcceptTypedWord feature relies on CursorAnchorInfo. // AcceptTypedWord feature relies on CursorAnchorInfo.
if (settingsValues.mShouldShowUiToAcceptTypedWord) { if (settingsValues.mShouldShowUiToAcceptTypedWord) {
mConnection.requestUpdateCursorAnchorInfo(true /* enableMonitor */, mConnection.requestCursorUpdates(true /* enableMonitor */,
true /* requestImmediateCallback */); true /* requestImmediateCallback */);
} }
} }