From f0c633bc4849cfa1376254586b1459572d56b8b0 Mon Sep 17 00:00:00 2001 From: Thales Lima Date: Wed, 6 Jul 2022 11:21:12 +0100 Subject: [PATCH] Take account of IME insets Fix: 233159032 Test: manual Change-Id: I2a23c13f7b2bcd8b0c758140dd1fdd5bb800f3f1 --- src/com/android/launcher3/views/BaseDragLayer.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/com/android/launcher3/views/BaseDragLayer.java b/src/com/android/launcher3/views/BaseDragLayer.java index f553fb4e8e..800b1f6ad7 100644 --- a/src/com/android/launcher3/views/BaseDragLayer.java +++ b/src/com/android/launcher3/views/BaseDragLayer.java @@ -22,13 +22,11 @@ import static android.view.MotionEvent.ACTION_UP; import static com.android.launcher3.util.window.RefreshRateTracker.getSingleFrameMs; -import android.annotation.TargetApi; import android.app.WallpaperManager; import android.content.Context; import android.graphics.Insets; import android.graphics.Rect; import android.graphics.RectF; -import android.os.Build; import android.util.AttributeSet; import android.util.Property; import android.view.MotionEvent; @@ -550,18 +548,24 @@ public abstract class BaseDragLayer } @Override - @TargetApi(Build.VERSION_CODES.Q) public WindowInsets dispatchApplyWindowInsets(WindowInsets insets) { if (Utilities.ATLEAST_Q) { Insets gestureInsets = insets.getMandatorySystemGestureInsets(); int gestureInsetBottom = gestureInsets.bottom; + Insets imeInset = Utilities.ATLEAST_R + ? insets.getInsets(WindowInsets.Type.ime()) + : Insets.NONE; DeviceProfile dp = mActivity.getDeviceProfile(); if (dp.isTaskbarPresent) { // Ignore taskbar gesture insets to avoid interfering with TouchControllers. gestureInsetBottom = Math.max(0, gestureInsetBottom - dp.taskbarSize); } - mSystemGestureRegion.set(gestureInsets.left, gestureInsets.top, - gestureInsets.right, gestureInsetBottom); + mSystemGestureRegion.set( + Math.max(gestureInsets.left, imeInset.left), + Math.max(gestureInsets.top, imeInset.top), + Math.max(gestureInsets.right, imeInset.right), + Math.max(gestureInsetBottom, imeInset.bottom) + ); } return super.dispatchApplyWindowInsets(insets); }