From 7bbe9684cf9ae79ee378a53f907afad144c82900 Mon Sep 17 00:00:00 2001 From: Miranda Kephart Date: Tue, 15 Feb 2022 12:36:01 -0500 Subject: [PATCH] Don't allow screenshot swipe-dismiss on gesture-back regions Currently we listen to touches in the gesture regions (the sides of the screen) when determining whether a swipe has occurred. This has the side effect of making it impossible to touch through the screenshot overlay in those areas. This change makes it so we ignore swipe-dismiss in those regions (but still listen for the back gesture) and allow tapping through the overlay on the edges of the screen. Bug: 217571135 Fix: 217571135 Test: manual Change-Id: I53869885c443320bd03cca80346741733f616629 --- .../systemui/screenshot/ScreenshotView.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java index f9827905b69aa..4a9a1f1f055d5 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java @@ -263,22 +263,29 @@ public class ScreenshotView extends FrameLayout implements inoutInfo.touchableRegion.set(getTouchRegion(true)); } - private Region getTouchRegion(boolean includeScrim) { - Region touchRegion = new Region(); + private Region getSwipeRegion() { + Region swipeRegion = new Region(); final Rect tmpRect = new Rect(); mScreenshotPreview.getBoundsOnScreen(tmpRect); tmpRect.inset((int) FloatingWindowUtil.dpToPx(mDisplayMetrics, -SWIPE_PADDING_DP), (int) FloatingWindowUtil.dpToPx(mDisplayMetrics, -SWIPE_PADDING_DP)); - touchRegion.op(tmpRect, Region.Op.UNION); + swipeRegion.op(tmpRect, Region.Op.UNION); mActionsContainerBackground.getBoundsOnScreen(tmpRect); tmpRect.inset((int) FloatingWindowUtil.dpToPx(mDisplayMetrics, -SWIPE_PADDING_DP), (int) FloatingWindowUtil.dpToPx(mDisplayMetrics, -SWIPE_PADDING_DP)); - touchRegion.op(tmpRect, Region.Op.UNION); + swipeRegion.op(tmpRect, Region.Op.UNION); mDismissButton.getBoundsOnScreen(tmpRect); - touchRegion.op(tmpRect, Region.Op.UNION); + swipeRegion.op(tmpRect, Region.Op.UNION); + + return swipeRegion; + } + + private Region getTouchRegion(boolean includeScrim) { + Region touchRegion = getSwipeRegion(); if (includeScrim && mScrollingScrim.getVisibility() == View.VISIBLE) { + final Rect tmpRect = new Rect(); mScrollingScrim.getBoundsOnScreen(tmpRect); touchRegion.op(tmpRect, Region.Op.UNION); } @@ -328,7 +335,7 @@ public class ScreenshotView extends FrameLayout implements @Override // ViewGroup public boolean onInterceptTouchEvent(MotionEvent ev) { // scrolling scrim should not be swipeable; return early if we're on the scrim - if (!getTouchRegion(false).contains((int) ev.getRawX(), (int) ev.getRawY())) { + if (!getSwipeRegion().contains((int) ev.getRawX(), (int) ev.getRawY())) { return false; } // always pass through the down event so the swipe handler knows the initial state