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

Unverified Commit 942eca13 authored by cketti's avatar cketti Committed by GitHub
Browse files

Merge pull request #6524 from thundernest/swipe_gesture_outside_webview

Ignore WebView's scroll state when swipe gesture started in other view
parents dc3857a9 462d64b6
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
package com.fsck.k9.ui.messageview

import android.content.Context
import android.graphics.Rect
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.ViewConfiguration
@@ -26,6 +27,11 @@ class TouchInterceptView(context: Context, attrs: AttributeSet?) : FrameLayout(c

    private var initialX: Float = 0f
    private var initialY: Float = 0f
    private var initialRawX = 0
    private var initialRawY = 0

    private val webViewScreenLocation = IntArray(2)
    private val webViewRect = Rect()

    override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
        handleOnInterceptTouchEvent(event)
@@ -41,6 +47,8 @@ class TouchInterceptView(context: Context, attrs: AttributeSet?) : FrameLayout(c
            MotionEvent.ACTION_DOWN -> {
                initialX = event.x
                initialY = event.y
                initialRawX = event.rawX.toInt()
                initialRawY = event.rawY.toInt()
                scrollViewParent.requestDisallowInterceptTouchEvent(false)
            }
            MotionEvent.ACTION_POINTER_DOWN -> {
@@ -61,9 +69,15 @@ class TouchInterceptView(context: Context, attrs: AttributeSet?) : FrameLayout(c
                } else if (absoluteDeltaX > touchSlop && absoluteDeltaX > absoluteDeltaY &&
                    webView.canScrollHorizontally(deltaX.toInt())
                ) {
                    webView.getHitRect(webViewRect)
                    webView.getLocationOnScreen(webViewScreenLocation)
                    webViewRect.offset(webViewScreenLocation[0], webViewScreenLocation[1])

                    if (webViewRect.contains(initialRawX, initialRawY)) {
                        scrollViewParent.requestDisallowInterceptTouchEvent(true)
                    }
                }
            }
        }
    }
}