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

Commit f47269c5 authored by Miranda Kephart's avatar Miranda Kephart
Browse files

Fix screenshot back behavior in 3-button mode

We weren't dismissing when the back button was pressed, because the
screenshot UI loses focus on touch_outside and so we never get the key
press. This change checks if the touch is in the navigation bar system
region, and doesn't reset the focus if so.

Bug: 441745433
Test: manual (using 3-button mode)
Flag: EXEMPT bugfix
Change-Id: I5ca573c43a1004e36632b5d868b57f686d4ab09c
parent 940d70b4
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -357,7 +357,11 @@ constructor(
                        if (
                            ev is MotionEvent &&
                                ev.actionMasked == MotionEvent.ACTION_DOWN &&
                                !getTouchRegion().contains(ev.rawX.toInt(), ev.rawY.toInt())
                                !view
                                    .getObservedRegion(
                                        windowManager.currentWindowMetrics.windowInsets
                                    )
                                    .contains(ev.rawX.toInt(), ev.rawY.toInt())
                        ) {
                            callbacks?.onTouchOutside()
                        }
@@ -366,11 +370,7 @@ constructor(
    }

    private fun getTouchRegion(): Region {
        return view.getTouchRegion(
            windowManager.currentWindowMetrics.windowInsets.getInsets(
                WindowInsets.Type.systemGestures()
            )
        )
        return view.getTouchRegion(windowManager.currentWindowMetrics.windowInsets)
    }

    companion object {
+16 −2
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.systemui.screenshot.ui

import android.content.Context
import android.content.res.Configuration
import android.graphics.Insets
import android.graphics.Rect
import android.graphics.Region
import android.util.AttributeSet
@@ -119,7 +118,21 @@ class ScreenshotShelfView(context: Context, attrs: AttributeSet? = null) :
        })
    }

    fun getTouchRegion(gestureInsets: Insets): Region {
    fun getObservedRegion(insets: WindowInsets): Region {
        val region = getTouchRegion(insets)
        if (
            resources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode) !=
                NAV_BAR_MODE_GESTURAL
        ) {
            region.op(
                insets.getBoundingRects(WindowInsets.Type.navigationBars())[0],
                Region.Op.UNION,
            )
        }
        return region
    }

    fun getTouchRegion(insets: WindowInsets): Region {
        val region = getSwipeRegion()

        // only add gesture insets to touch region in gestural mode
@@ -127,6 +140,7 @@ class ScreenshotShelfView(context: Context, attrs: AttributeSet? = null) :
            resources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode) ==
                NAV_BAR_MODE_GESTURAL
        ) {
            val gestureInsets = insets.getInsets(WindowInsets.Type.systemGestures())
            // 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)