follow up gesture scroll after revert
This commit is contained in:
+3
-21
@@ -17,13 +17,12 @@ import org.mozilla.gecko.util.ThreadUtils.runOnUiThread
|
|||||||
/**
|
/**
|
||||||
* Feature that filters browser touch input and reports whether GeckoView is handling scroll input.
|
* Feature that filters browser touch input and reports whether GeckoView is handling scroll input.
|
||||||
*
|
*
|
||||||
* Checks InputResultDetail while scroll detection is enabled and only emits on state changes.
|
* Checks InputResultDetail while active and only emits on state changes.
|
||||||
*/
|
*/
|
||||||
class BrowserHandlingScrollFeature(
|
class BrowserHandlingScrollFeature(
|
||||||
private val flutterEvents: GeckoViewportEvents,
|
private val flutterEvents: GeckoViewportEvents,
|
||||||
) {
|
) {
|
||||||
private var running = false
|
private var running = false
|
||||||
private var scrollDetectionEnabled = false
|
|
||||||
private var touchSessionActive = false
|
private var touchSessionActive = false
|
||||||
private var lastValue: Boolean? = null
|
private var lastValue: Boolean? = null
|
||||||
private var touchListener: View.OnTouchListener? = null
|
private var touchListener: View.OnTouchListener? = null
|
||||||
@@ -32,34 +31,19 @@ class BrowserHandlingScrollFeature(
|
|||||||
private var suppressUntilAllPointersUp = false
|
private var suppressUntilAllPointersUp = false
|
||||||
private var syntheticCancelDispatched = false
|
private var syntheticCancelDispatched = false
|
||||||
|
|
||||||
fun start(scrollDetectionEnabled: Boolean) {
|
fun start() {
|
||||||
if (running) {
|
if (running) return
|
||||||
setScrollDetectionEnabled(scrollDetectionEnabled)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
running = true
|
running = true
|
||||||
this.scrollDetectionEnabled = scrollDetectionEnabled
|
|
||||||
touchSessionActive = false
|
touchSessionActive = false
|
||||||
lastValue = null
|
lastValue = null
|
||||||
resetPinchGuard()
|
resetPinchGuard()
|
||||||
attachTouchListenerIfPossible()
|
attachTouchListenerIfPossible()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setScrollDetectionEnabled(enabled: Boolean) {
|
|
||||||
if (scrollDetectionEnabled == enabled) return
|
|
||||||
|
|
||||||
scrollDetectionEnabled = enabled
|
|
||||||
if (!enabled) {
|
|
||||||
touchSessionActive = false
|
|
||||||
emitIfChanged(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun stop() {
|
fun stop() {
|
||||||
if (!running) return
|
if (!running) return
|
||||||
running = false
|
running = false
|
||||||
scrollDetectionEnabled = false
|
|
||||||
touchSessionActive = false
|
touchSessionActive = false
|
||||||
resetPinchGuard()
|
resetPinchGuard()
|
||||||
emitIfChanged(false)
|
emitIfChanged(false)
|
||||||
@@ -89,8 +73,6 @@ class BrowserHandlingScrollFeature(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateScrollDetection(event: MotionEvent) {
|
private fun updateScrollDetection(event: MotionEvent) {
|
||||||
if (!scrollDetectionEnabled) return
|
|
||||||
|
|
||||||
when (event.actionMasked) {
|
when (event.actionMasked) {
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN -> {
|
||||||
touchSessionActive = true
|
touchSessionActive = true
|
||||||
|
|||||||
Reference in New Issue
Block a user