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

Commit 2731731d authored by Joshua Trask's avatar Joshua Trask Committed by Android (Google) Code Review
Browse files

Merge "[Screenshot] Extend timeout on user interaction" into 24D1-dev

parents e6f86ad1 da0eb1fa
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -86,7 +86,8 @@ constructor(
            viewModel,
            LayoutInflater.from(context),
            onDismissalRequested = { event, velocity -> requestDismissal(event, velocity) },
            onDismissalCancelled = { animationController.getSwipeReturnAnimation().start() }
            onDismissalCancelled = { animationController.getSwipeReturnAnimation().start() },
            onUserInteraction = { callbacks?.onUserInteraction() }
        )
        view.updateInsets(windowManager.currentWindowMetrics.windowInsets)
        addPredictiveBackListener { requestDismissal(SCREENSHOT_DISMISSED_OTHER) }
+16 −0
Original line number Diff line number Diff line
@@ -39,11 +39,20 @@ class ScreenshotShelfView(context: Context, attrs: AttributeSet? = null) :
    private lateinit var screenshotStatic: ViewGroup
    var onTouchInterceptListener: ((MotionEvent) -> Boolean)? = null

    var userInteractionCallback: (() -> Unit)? = null

    private val displayMetrics = context.resources.displayMetrics
    private val tmpRect = Rect()
    private lateinit var actionsContainerBackground: View
    private lateinit var dismissButton: View

    init {
        setOnTouchListener({ _: View, _: MotionEvent ->
            userInteractionCallback?.invoke()
            true
        })
    }

    override fun onFinishInflate() {
        super.onFinishInflate()
        // Get focus so that the key events go to the layout.
@@ -127,7 +136,14 @@ class ScreenshotShelfView(context: Context, attrs: AttributeSet? = null) :
        private const val TOUCH_PADDING_DP = 12f
    }

    override fun onInterceptHoverEvent(event: MotionEvent): Boolean {
        userInteractionCallback?.invoke()
        return super.onInterceptHoverEvent(event)
    }

    override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
        userInteractionCallback?.invoke()

        if (onTouchInterceptListener?.invoke(ev) == true) {
            return true
        }
+2 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ object ScreenshotShelfViewBinder {
        layoutInflater: LayoutInflater,
        onDismissalRequested: (event: ScreenshotEvent, velocity: Float?) -> Unit,
        onDismissalCancelled: () -> Unit,
        onUserInteraction: () -> Unit
    ) {
        val swipeGestureListener =
            SwipeGestureListener(
@@ -55,6 +56,7 @@ object ScreenshotShelfViewBinder {
                onCancel = onDismissalCancelled
            )
        view.onTouchInterceptListener = { swipeGestureListener.onMotionEvent(it) }
        view.userInteractionCallback = onUserInteraction

        val previewView: ImageView = view.requireViewById(R.id.screenshot_preview)
        val previewViewBlur: ImageView = view.requireViewById(R.id.screenshot_preview_blur)