From c8364e3878aa8e0f9e8dda1bd5305c5ef7eeada0 Mon Sep 17 00:00:00 2001 From: Tiger Huang Date: Tue, 10 Mar 2020 21:20:58 +0800 Subject: Make IME fit navgation bars at left and right sides IME is not big enough to be the background of navigation bar when navigation bar is on the left or right edge of the screen. Also, IME can be on top of navigation bar in landscape split-screen mode, we don't want IME to block touches on navigation bar. Fix: 151083985 Test: 1. Open Messages. 2. Rotate device to landscape. 3. Click on "Search message" and see if IME extends into the navigation bar area at the left or right edge. Change-Id: I0ef3d6379a9ae52b3749154d2fdc54e9aa94a9e0 --- core/java/android/inputmethodservice/InputMethodService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'core/java/android/inputmethodservice/InputMethodService.java') diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index 1b6c1ee4f7e2..7e4d68d9925e 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -20,6 +20,7 @@ import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; import static android.view.ViewRootImpl.NEW_INSETS_MODE_NONE; 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; @@ -71,6 +72,7 @@ import android.view.ViewRootImpl; import android.view.ViewTreeObserver; import android.view.Window; import android.view.WindowInsets; +import android.view.WindowInsets.Side; import android.view.WindowManager; import android.view.animation.AnimationUtils; import android.view.autofill.AutofillId; @@ -1246,7 +1248,8 @@ public class InputMethodService extends AbstractInputMethodService { Context.LAYOUT_INFLATER_SERVICE); mWindow = new SoftInputWindow(this, "InputMethod", mTheme, null, null, mDispatcherState, WindowManager.LayoutParams.TYPE_INPUT_METHOD, Gravity.BOTTOM, false); - mWindow.getWindow().getAttributes().setFitInsetsTypes(WindowInsets.Type.statusBars()); + mWindow.getWindow().getAttributes().setFitInsetsTypes(statusBars() | navigationBars()); + mWindow.getWindow().getAttributes().setFitInsetsSides(Side.all() & ~Side.BOTTOM); // IME layout should always be inset by navigation bar, no matter its current visibility, // unless automotive requests it, since automotive may hide the navigation bar. -- cgit v1.2.3