summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Winson Chung <winsonc@google.com> 2020-10-29 18:57:26 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-10-29 18:57:26 +0000
commit5f17ad28c8df97b2fc9f2ec17dc23f050a17aa22 (patch)
treeb874c691a096ff84f187d909e49ca5ad526d55d6
parenta15b4bb4fdb0968e27efa45fab07eb52b63dd696 (diff)
parent72e6319254769db69414f952c15dfaeeb14fc69a (diff)
Merge "Only use system gesture insets for exclusion rects with root ime view"
-rw-r--r--core/java/android/inputmethodservice/InputMethodService.java20
1 files changed, 15 insertions, 5 deletions
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index 070bec11b93a..d290465816b6 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -102,6 +102,7 @@ import android.view.ViewRootImpl;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowInsets.Side;
+import android.view.WindowInsets.Type;
import android.view.WindowManager;
import android.view.animation.AnimationUtils;
import android.view.inputmethod.CompletionInfo;
@@ -135,7 +136,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;
import java.util.Objects;
/**
@@ -883,10 +884,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().getInsets(Type.systemGestures());
+ ArrayList<Rect> 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);
}
/**