Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3a6526ae authored by Miranda Kephart's avatar Miranda Kephart
Browse files

Only add gesture insets to screenshot touch region in gesture mode

We prevent touches in the swipe gesture region from going through to
what's behind the screenshot UI so that we can recognize (and dismiss
on) the back gesture. However, in three-button mode in landscape the
'gesture region' includes the nav bar, so we were preventing taps from
going through to the nav bar. This change conditions on the device being
in gesture mode so that we ignore touches on the nav bar in 3-button
mode in landscape.

Bug: 372542780
Fix: 372542780
Flag: EXEMPT minor change restoring previous behavior
Test: manual (ensure taps on the nav bar in 3-button mode in landscape
are recognized)

Change-Id: I764e75dac7fc214a0136bea917ad865b5f2d40f8
parent b5219782
Loading
Loading
Loading
Loading
+25 −18
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.view.WindowInsets
import android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL
import android.widget.FrameLayout
import android.widget.ImageView
import com.android.systemui.res.R
@@ -59,17 +60,17 @@ class ScreenshotShelfView(context: Context, attrs: AttributeSet? = null) :
                    ev1: MotionEvent?,
                    ev2: MotionEvent,
                    distanceX: Float,
                    distanceY: Float
                    distanceY: Float,
                ): Boolean {
                    actionsContainer.getBoundsOnScreen(tmpRect)
                    val touchedInActionsContainer =
                        tmpRect.contains(ev2.rawX.toInt(), ev2.rawY.toInt())
                    val canHandleInternallyByScrolling =
                        touchedInActionsContainer
                        && actionsContainer.canScrollHorizontally(distanceX.toInt())
                        touchedInActionsContainer &&
                            actionsContainer.canScrollHorizontally(distanceX.toInt())
                    return !canHandleInternallyByScrolling
                }
            }
            },
        )

    init {
@@ -106,6 +107,11 @@ class ScreenshotShelfView(context: Context, attrs: AttributeSet? = null) :
    fun getTouchRegion(gestureInsets: Insets): Region {
        val region = getSwipeRegion()

        // only add gesture insets to touch region in gestural mode
        if (
            resources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode) ==
                NAV_BAR_MODE_GESTURAL
        ) {
            // Receive touches in gesture insets so they don't cause TOUCH_OUTSIDE
            // left edge gesture region
            val insetRect = Rect(0, 0, gestureInsets.left, displayMetrics.heightPixels)
@@ -115,9 +121,10 @@ class ScreenshotShelfView(context: Context, attrs: AttributeSet? = null) :
                displayMetrics.widthPixels - gestureInsets.right,
                0,
                displayMetrics.widthPixels,
            displayMetrics.heightPixels
                displayMetrics.heightPixels,
            )
            region.op(insetRect, Region.Op.UNION)
        }

        return region
    }
@@ -153,7 +160,7 @@ class ScreenshotShelfView(context: Context, attrs: AttributeSet? = null) :
                        cutout.safeInsetBottom + verticalPadding,
                        waterfall.bottom + verticalPadding,
                        minimumBottomPadding,
                    )
                    ),
                )
            } else {
                screenshotStatic.setPadding(
@@ -164,7 +171,7 @@ class ScreenshotShelfView(context: Context, attrs: AttributeSet? = null) :
                        navBarInsets.bottom + verticalPadding,
                        waterfall.bottom + verticalPadding,
                        minimumBottomPadding,
                    )
                    ),
                )
            }
        }