From 427bdc1c86904649dc7c12cf917c05d61f2fe3fa Mon Sep 17 00:00:00 2001 From: Tiger Huang Date: Wed, 14 Oct 2020 11:40:09 +0000 Subject: DO NOT MERGE: Revert "Don't let IME window fit status bar" This reverts commit 3cd311415ba00d5d75660a8607d1ece5e68f0534. Reason for revert: The CL causes the regression b/170474494 And it also makes status bar color incorrect while FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS is cleared Fix: 170474494 Change-Id: I26bed08456197721d07f2fab563be0c54e43efd2 --- .../inputmethodservice/InputMethodService.java | 26 +++++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) (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 e0195e4eafc1..4f0c84e586a2 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -16,11 +16,11 @@ package android.inputmethodservice; -import static android.graphics.Color.TRANSPARENT; 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; @@ -69,6 +69,7 @@ import android.view.ViewGroup; 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; @@ -1202,22 +1203,25 @@ 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(navigationBars()); + mWindow.getWindow().getAttributes().setFitInsetsTypes(statusBars() | navigationBars()); mWindow.getWindow().getAttributes().setFitInsetsSides(Side.all() & ~Side.BOTTOM); mWindow.getWindow().getAttributes().setFitInsetsIgnoringVisibility(true); - // Our window will extend into the status bar area no matter the bar is visible or not. - // We don't want the ColorView to be visible when status bar is shown. - mWindow.getWindow().setStatusBarColor(TRANSPARENT); - - // 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. + // IME layout should always be inset by navigation bar, no matter its current visibility, + // unless automotive requests it. 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); } + mWindow.getWindow().getDecorView().setOnApplyWindowInsetsListener( + (v, insets) -> v.onApplyWindowInsets( + new WindowInsets.Builder(insets).setInsets( + navigationBars(), + insets.getInsetsIgnoringVisibility(navigationBars())) + .build())); // 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). -- cgit v1.2.3 From 5f0edaaaf55f26420345a1cd690b988f752d17c6 Mon Sep 17 00:00:00 2001 From: Mathew Inwood Date: Mon, 2 Nov 2020 10:29:35 +0000 Subject: Add maxTargetSdk restriction to unused APIs. These are APIs that have @UnsupportedAppUsage but for which we don't have any evidence of them currently being used, so should be safe to remove from the unsupported list. Bug: 170729553 Test: Treehugger Merged-In: I8285daa8530260251ecad6f3f38f98e263629ca7 Change-Id: I626caf7c1fe46c5ab1f39c2895b42a34319f771a --- core/java/android/inputmethodservice/InputMethodService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (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 17f413b0160f..0924e9f5eb7c 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -1097,7 +1097,7 @@ public class InputMethodService extends AbstractInputMethodService { mService.getContentResolver().unregisterContentObserver(this); } - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) private boolean shouldShowImeWithHardKeyboard() { // Lazily initialize as needed. if (mShowImeWithHardKeyboard == ShowImeWithHardKeyboardType.UNKNOWN) { @@ -1137,7 +1137,7 @@ public class InputMethodService extends AbstractInputMethodService { return "SettingsObserver{mShowImeWithHardKeyboard=" + mShowImeWithHardKeyboard + "}"; } } - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) private SettingsObserver mSettingsObserver; /** -- cgit v1.2.3 From 3f5b1ef5c1db82db29f4fc24c436417e54123ee6 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Thu, 22 Oct 2020 12:52:43 -0700 Subject: Only use system gesture insets for exclusion rects with root ime view - Instead of using the whole IME frame, we should only exclude the left and right regions for excluding the back gesture (the intention of the original change), otherwise the full IME frame will exclude the bottom gesture area which is respected by Launcher to prevent quickswitch. Bug: 171501996 Test: Dump exclusion rects received by SysUI with normal IME (only edges) floating IME (no exclusion requested) and extract mode (only edges) Change-Id: Id8e01d56190f8fafdc2da1cf95203e597acdb970 Merged-In: Id8e01d56190f8fafdc2da1cf95203e597acdb970 (cherry picked from commit 72e6319254769db69414f952c15dfaeeb14fc69a) --- .../inputmethodservice/InputMethodService.java | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (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 4f0c84e586a2..1e7815314718 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -71,6 +71,7 @@ import android.view.ViewTreeObserver; import android.view.Window; import android.view.WindowInsets; import android.view.WindowInsets.Side; +import android.view.WindowInsets.Type; import android.view.WindowManager; import android.view.animation.AnimationUtils; import android.view.inputmethod.CompletionInfo; @@ -104,7 +105,7 @@ import java.io.FileDescriptor; import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import java.util.Collections; +import java.util.ArrayList; /** * InputMethodService provides a standard implementation of an InputMethod, @@ -850,10 +851,19 @@ public class InputMethodService extends AbstractInputMethodService { /** Set region of the keyboard to be avoided from back gesture */ private void setImeExclusionRect(int visibleTopInsets) { - View inputFrameRootView = mInputFrame.getRootView(); - Rect r = new Rect(0, visibleTopInsets, inputFrameRootView.getWidth(), - inputFrameRootView.getHeight()); - inputFrameRootView.setSystemGestureExclusionRects(Collections.singletonList(r)); + View rootView = mInputFrame.getRootView(); + android.graphics.Insets systemGesture = + rootView.getRootWindowInsets().getInsetsIgnoringVisibility(Type.systemGestures()); + ArrayList exclusionRects = new ArrayList<>(); + exclusionRects.add(new Rect(0, + visibleTopInsets, + systemGesture.left, + rootView.getHeight())); + exclusionRects.add(new Rect(rootView.getWidth() - systemGesture.right, + visibleTopInsets, + rootView.getWidth(), + rootView.getHeight())); + rootView.setSystemGestureExclusionRects(exclusionRects); } /** -- cgit v1.2.3 From 604b284349860203ca41eb7e0bc8ce4e3094ac9e Mon Sep 17 00:00:00 2001 From: Tiger Huang Date: Sun, 8 Nov 2020 19:04:16 +0800 Subject: Do let IME fit invisible insets Otherwise, the fullscreen IME won't cover the entire display while there is a hidden system bar. Fix: 168657591 Test: 1. Steps in the bug. 2. Play WindowInsetsTests with combinations of system bar visibilities, navigation mode, screen orientation, and display cutout. Merged-in: I6e7d665c55839dfbb14c8d2e5365537416f5f6c6 Change-Id: I6e7d665c55839dfbb14c8d2e5365537416f5f6c6 (cherry picked from commit 145f71182ab1c1e0be4f128683c97403c97d2696) --- core/java/android/inputmethodservice/InputMethodService.java | 1 - 1 file changed, 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 1e7815314718..1926ea230bb1 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -1215,7 +1215,6 @@ public class InputMethodService extends AbstractInputMethodService { WindowManager.LayoutParams.TYPE_INPUT_METHOD, Gravity.BOTTOM, false); mWindow.getWindow().getAttributes().setFitInsetsTypes(statusBars() | navigationBars()); mWindow.getWindow().getAttributes().setFitInsetsSides(Side.all() & ~Side.BOTTOM); - mWindow.getWindow().getAttributes().setFitInsetsIgnoringVisibility(true); // IME layout should always be inset by navigation bar, no matter its current visibility, // unless automotive requests it. Automotive devices may request the navigation bar to be -- cgit v1.2.3