diff options
| author | Yohei Yukawa <yukawa@google.com> | 2021-12-27 19:29:13 -0800 |
|---|---|---|
| committer | Yohei Yukawa <yukawa@google.com> | 2021-12-27 19:29:13 -0800 |
| commit | 880a1b80b4b23266bc2916102a022f26cfbbb35b (patch) | |
| tree | ffc7b078c57535c4c9dcb1bdec0f3f72d4fac87f /core/java/android/inputmethodservice/InputMethodService.java | |
| parent | ea7801bd267f98fba10741b88bc900aef9f84121 (diff) | |
Merge SoftInputWindow#initDockWindow() into IMS#onCreate()
This CL merges
SoftInputWindow#initDockWindow()
into
InputMethodService#onCreate()
so that we can see what parameters are set to the IME window at a
glance, rather than having to check 2 different files.
The end result is expected to be the same, and in theory there should
be no observable behavior change.
If you are reading this commit message to look for why those
parameters have been set, here are some quick links to relevant CLs.
* `FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS`
- DecorView#mNavigationGuard is gone [1]
* `window.setDecorFitsSystemWindows(false)`
- Updated InputMethodService to not inset by navigation bar if
requested by automotive. [2]
- Smooth out IME animation for automotive devices [3]
* `setFitInsetsTypes(statusBars() | navigationBars())`
- Do let IME fit invisible insets [4]
* `setFitInsetsSides(Side.all() & ~Side.BOTTOM)`
- Make IME fit navgation bars at left and right sides [5]
* `receiveInsetsIgnoringZOrder = true`
- Let IME receive insets ignoring z-order [6]
[1]: I664630099b6eb3fe31675444ba94944cb0eb98b0
8f162c6e846ac99d6aac4473d7903722e9d6e54b
[2]: I4faf82bdd7536bd2d049ded04034a9635d8ca0d3
7eec316f54e22237f92a2808a3a2f9356229335d
[3]: I5d7b03d5c829a2679efdd06fa961d1158494e08f
b0d0d7c46ab0425431912d2e03cc620be657a969
[4]: I6e7d665c55839dfbb14c8d2e5365537416f5f6c6
145f71182ab1c1e0be4f128683c97403c97d2696
[5]: I0ef3d6379a9ae52b3749154d2fdc54e9aa94a9e0
c8364e3878aa8e0f9e8dda1bd5305c5ef7eeada0
[6]: I53c64a5598f246ad577f652156903e4666a30cd9
ea491da863774457299ffd5f2534dc2ba4d3ba52
Bug: 192412909
Test: presubmit
Change-Id: If0f2bac45e6752612cc11e57d2fac55626221bd1
Diffstat (limited to 'core/java/android/inputmethodservice/InputMethodService.java')
| -rw-r--r-- | core/java/android/inputmethodservice/InputMethodService.java | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index be841c01f51f..afaa085c7cbd 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -51,7 +51,6 @@ import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; import static android.view.WindowInsets.Type.navigationBars; import static android.view.WindowInsets.Type.statusBars; -import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; import static java.lang.annotation.RetentionPolicy.SOURCE; @@ -94,6 +93,7 @@ import android.util.Log; import android.util.PrintWriterPrinter; import android.util.Printer; import android.util.proto.ProtoOutputStream; +import android.view.Gravity; import android.view.KeyCharacterMap; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -1340,26 +1340,42 @@ public class InputMethodService extends AbstractInputMethodService { Context.LAYOUT_INFLATER_SERVICE); Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMS.initSoftInputWindow"); mWindow = new SoftInputWindow(this, mTheme, mDispatcherState); - mWindow.getWindow().getAttributes().setFitInsetsTypes(statusBars() | navigationBars()); - mWindow.getWindow().getAttributes().setFitInsetsSides(Side.all() & ~Side.BOTTOM); - mWindow.getWindow().getAttributes().receiveInsetsIgnoringZOrder = true; - // Automotive devices may request the navigation bar to be hidden when the IME shows up - // (controlled via config_automotiveHideNavBarForKeyboard) in order to maximize the visible - // screen real estate. When this happens, the IME window should animate from the bottom of - // the screen to reduce the jank that happens from the lack of synchronization between the - // bottom system window and the IME window. - if (mIsAutomotive && mAutomotiveHideNavBarForKeyboard) { - mWindow.getWindow().setDecorFitsSystemWindows(false); - } + { + final Window window = mWindow.getWindow(); + { + final WindowManager.LayoutParams lp = window.getAttributes(); + lp.setTitle("InputMethod"); + lp.type = WindowManager.LayoutParams.TYPE_INPUT_METHOD; + lp.width = WindowManager.LayoutParams.MATCH_PARENT; + lp.height = WindowManager.LayoutParams.WRAP_CONTENT; + lp.gravity = Gravity.BOTTOM; + lp.setFitInsetsTypes(statusBars() | navigationBars()); + lp.setFitInsetsSides(Side.all() & ~Side.BOTTOM); + lp.receiveInsetsIgnoringZOrder = true; + window.setAttributes(lp); + } - // For ColorView in DecorView to work, FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS needs to be set - // by default (but IME developers can opt this out later if they want a new behavior). - mWindow.getWindow().setFlags( - FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); + // For ColorView in DecorView to work, FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS needs to be set + // by default (but IME developers can opt this out later if they want a new behavior). + final int windowFlags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN + | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE + | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; + final int windowFlagsMask = windowFlags + | WindowManager.LayoutParams.FLAG_DIM_BEHIND; // to be unset + window.setFlags(windowFlags, windowFlagsMask); + + // Automotive devices may request the navigation bar to be hidden when the IME shows up + // (controlled via config_automotiveHideNavBarForKeyboard) in order to maximize the + // visible screen real estate. When this happens, the IME window should animate from the + // bottom of the screen to reduce the jank that happens from the lack of synchronization + // between the bottom system window and the IME window. + if (mIsAutomotive && mAutomotiveHideNavBarForKeyboard) { + window.setDecorFitsSystemWindows(false); + } + } initViews(); - mWindow.getWindow().setLayout(MATCH_PARENT, WRAP_CONTENT); Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); mInlineSuggestionSessionController = new InlineSuggestionSessionController( |
