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

Commit 7ebf9ab1 authored by Miranda Kephart's avatar Miranda Kephart Committed by Android (Google) Code Review
Browse files

Merge "Only add gesture insets to screenshot touch region in gesture mode" into main

parents 17b1888d 3a6526ae
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,
                    )
                    ),
                )
            }
        }