public boolean commitText(CharSequence text, int newCursorPosition) {
if (DEBUG) Log.v(TAG, "commitText " + text);
replaceText(text, newCursorPosition, false);
- mIMM.notifyUserAction();
sendCurrentText();
return true;
}
public boolean setComposingText(CharSequence text, int newCursorPosition) {
if (DEBUG) Log.v(TAG, "setComposingText " + text);
replaceText(text, newCursorPosition, true);
- mIMM.notifyUserAction();
return true;
}
viewRootImpl.dispatchKeyFromIme(event);
}
}
- mIMM.notifyUserAction();
return false;
}
-
+
/**
* Updates InputMethodManager with the current fullscreen mode.
*/
public boolean reportFullscreenMode(boolean enabled) {
- mIMM.setFullscreenMode(enabled);
return true;
}
-
+
private void sendCurrentText() {
if (!mDummyMode) {
return;
}
}
}
-
+
private static class ControlledInputConnectionWrapper extends IInputConnectionWrapper {
private final InputMethodManager mParentInputMethodManager;
private boolean mActive;
}
@Override
+ protected void onUserAction() {
+ mParentInputMethodManager.notifyUserAction();
+ }
+
+ @Override
+ protected void onReportFullscreenMode(boolean enabled) {
+ mParentInputMethodManager.setFullscreenMode(enabled);
+ }
+
+ @Override
public String toString() {
return "ControlledInputConnectionWrapper{mActive=" + mActive
+ " mParentInputMethodManager.mActive=" + mParentInputMethodManager.mActive
+ "}";
}
}
-
+
final IInputMethodClient.Stub mClient = new IInputMethodClient.Stub() {
@Override
protected void dump(FileDescriptor fd, PrintWriter fout, String[] args) {
import java.lang.ref.WeakReference;
-public class IInputConnectionWrapper extends IInputContext.Stub {
+public abstract class IInputConnectionWrapper extends IInputContext.Stub {
static final String TAG = "IInputConnectionWrapper";
private static final int DO_GET_TEXT_AFTER_CURSOR = 10;
}
public IInputConnectionWrapper(Looper mainLooper, InputConnection conn) {
- mInputConnection = new WeakReference<InputConnection>(conn);
+ mInputConnection = new WeakReference<>(conn);
mMainLooper = mainLooper;
mH = new MyHandler(mMainLooper);
}
- public boolean isActive() {
- return true;
- }
-
+ abstract protected boolean isActive();
+
+ /**
+ * Called when the user took some actions that should be taken into consideration to update the
+ * LRU list for input method rotation.
+ */
+ abstract protected void onUserAction();
+
+ /**
+ * Called when the input method started or stopped full-screen mode.
+ *
+ */
+ abstract protected void onReportFullscreenMode(boolean enabled);
+
public void getTextAfterCursor(int length, int flags, int seq, IInputContextCallback callback) {
dispatchMessage(obtainMessageIISC(DO_GET_TEXT_AFTER_CURSOR, length, flags, seq, callback));
}
return;
}
ic.commitText((CharSequence)msg.obj, msg.arg1);
+ onUserAction();
return;
}
case DO_SET_SELECTION: {
return;
}
ic.setComposingText((CharSequence)msg.obj, msg.arg1);
+ onUserAction();
return;
}
case DO_SET_COMPOSING_REGION: {
return;
}
ic.sendKeyEvent((KeyEvent)msg.obj);
+ onUserAction();
return;
}
case DO_CLEAR_META_KEY_STATES: {
Log.w(TAG, "reportFullscreenMode on inexistent InputConnection");
return;
}
- ic.reportFullscreenMode(msg.arg1 == 1);
+ final boolean enabled = msg.arg1 == 1;
+ ic.reportFullscreenMode(enabled);
+ onReportFullscreenMode(enabled);
return;
}
case DO_PERFORM_PRIVATE_COMMAND: {