Modify MSIME sample to use setActive()
MSIME sample can now set connection active/inactive.
Bug: 128751901
Test: Manually verified using steps in bug.
Change-Id: I77bf8c844838f32888004611975cfa316255961b
diff --git a/samples/MultiClientInputMethod/src/com/example/android/multiclientinputmethod/ClientCallbackImpl.java b/samples/MultiClientInputMethod/src/com/example/android/multiclientinputmethod/ClientCallbackImpl.java
index 45b4e56..0b7e7ac 100644
--- a/samples/MultiClientInputMethod/src/com/example/android/multiclientinputmethod/ClientCallbackImpl.java
+++ b/samples/MultiClientInputMethod/src/com/example/android/multiclientinputmethod/ClientCallbackImpl.java
@@ -152,8 +152,11 @@
mDelegate.reportImeWindowTarget(
mClientId, targetWindowHandle, window.getWindow().getAttributes().token);
}
-
if (inputConnection == null || editorInfo == null) {
+ // deactivate previous client.
+ if (MultiClientInputMethod.sLastClientId != mClientId) {
+ mDelegate.setActive(MultiClientInputMethod.sLastClientId, false /* active */);
+ }
// Dummy InputConnection case.
if (window.getClientId() == mClientId) {
// Special hack for temporary focus changes (e.g. notification shade).
@@ -163,6 +166,9 @@
window.onDummyStartInput(mClientId, targetWindowHandle);
}
} else {
+ if (MultiClientInputMethod.sLastClientId != mClientId) {
+ mDelegate.setActive(mClientId, true /* active */);
+ }
window.onStartInput(mClientId, targetWindowHandle, inputConnection);
}
@@ -184,6 +190,7 @@
window.hide();
break;
}
+ MultiClientInputMethod.sLastClientId = mClientId;
}
@Override
diff --git a/samples/MultiClientInputMethod/src/com/example/android/multiclientinputmethod/MultiClientInputMethod.java b/samples/MultiClientInputMethod/src/com/example/android/multiclientinputmethod/MultiClientInputMethod.java
index 150c21d..bf468e2 100644
--- a/samples/MultiClientInputMethod/src/com/example/android/multiclientinputmethod/MultiClientInputMethod.java
+++ b/samples/MultiClientInputMethod/src/com/example/android/multiclientinputmethod/MultiClientInputMethod.java
@@ -28,6 +28,7 @@
public final class MultiClientInputMethod extends Service {
private static final String TAG = "MultiClientInputMethod";
private static final boolean DEBUG = false;
+ static int sLastClientId = MultiClientInputMethodServiceDelegate.INVALID_CLIENT_ID;
SoftInputWindowManager mSoftInputWindowManager;
MultiClientInputMethodServiceDelegate mDelegate;