summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMing-Shin Lu <lumark@google.com>2022-01-10 20:23:25 +0800
committerMing-Shin Lu <lumark@google.com>2022-01-10 23:42:17 +0800
commite0caa3b4afaf540dd6d2943dcf59528bdf7f4145 (patch)
treede8a15a062336bcccceeabdafd5f638ad1a70ba2
parent84637a4834db097f4720a91e96cf41b6a2d242db (diff)
downloaddevelopment-android12-qpr3-s6-release.tar.gz
With CL[1],[2] to migrate InputMethodService as the subclass of the new introduced class WindowProviderService in S_V2, IME context resources can be managed by associating the window container of IME window when its display/window configuration changed. So in SoftKeyboard#getDisplayContext, we can get rid of createDisplayContext logic from S_V2 with gated by SDK version and refining the method documentation to make it clear. [1]: Ie565e30ed5dd3f2cfe27355a6dded76dc3adc14b [2]: I64a1614f32d097785915f6105b1813a929e0fe32 Bug: 213118079 Bug: 133825283 Test: manual with below steps 1) adb install -r EditTextVariations.apk 2) adb install -r SoftKeyboard.apk 3) adb shell ime enable com.example.android.softkeyboard/.SoftKeyboard 4) adb shell ime set com.example.android.softkeyboard/.SoftKeyboard5 5) Enable screen auto-rotation 6) Launch EditTextVariations from launcher's shortcut 7) Tap the first EditText field to show IME 8) Rotate the device to the landscape mode 9) Expect the IME should not be shrunk Change-Id: I9a512a90ca43f07236a041d9e82dbd875206f99e
-rw-r--r--samples/SoftKeyboard/src/com/example/android/softkeyboard/SoftKeyboard.java19
1 files changed, 15 insertions, 4 deletions
diff --git a/samples/SoftKeyboard/src/com/example/android/softkeyboard/SoftKeyboard.java b/samples/SoftKeyboard/src/com/example/android/softkeyboard/SoftKeyboard.java
index b76005fbf..c9f61ae48 100644
--- a/samples/SoftKeyboard/src/com/example/android/softkeyboard/SoftKeyboard.java
+++ b/samples/SoftKeyboard/src/com/example/android/softkeyboard/SoftKeyboard.java
@@ -96,8 +96,17 @@ public class SoftKeyboard extends InputMethodService
}
/**
- * Create new context object whose resources are adjusted to match the metrics of the display
- * which is managed by WindowManager.
+ * Returns the context object whose resources are adjusted to match the metrics of the display.
+ *
+ * Note that before {@link android.os.Build.VERSION_CODES#KITKAT}, there is no way to support
+ * multi-display scenarios, so the context object will just return the IME context itself.
+ *
+ * With initiating multi-display APIs from {@link android.os.Build.VERSION_CODES#KITKAT}, the
+ * context object has to return with re-creating the display context according the metrics
+ * of the display in runtime.
+ *
+ * Starts from {@link android.os.Build.VERSION_CODES#S_V2}, the returning context object has
+ * became to IME context self since it ends up capable of updating its resources internally.
*
* @see {@link Context#createDisplayContext(Display)}
*/
@@ -106,8 +115,10 @@ public class SoftKeyboard extends InputMethodService
// createDisplayContext is not available.
return this;
}
- // TODO (b/133825283): Non-activity components Resources / DisplayMetrics update when
- // moving to external display.
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S_V2) {
+ // IME context sources is now managed by WindowProviderService from Android 12L.
+ return this;
+ }
// An issue in Q that non-activity components Resources / DisplayMetrics in
// Context doesn't well updated when the IME window moving to external display.
// Currently we do a workaround is to create new display context directly and re-init