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