From 149ea23fa568a68e26afed7ccadf1fb99ae5d9e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Fri, 22 Sep 2023 09:39:48 +0200 Subject: [PATCH] Fix scrolling on widgets on home screen This closes #139 --- .../simplemobiletools/launcher/views/MyAppWidgetHostView.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/launcher/views/MyAppWidgetHostView.kt b/app/src/main/kotlin/com/simplemobiletools/launcher/views/MyAppWidgetHostView.kt index 7ce1bba..8e36926 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/views/MyAppWidgetHostView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/views/MyAppWidgetHostView.kt @@ -14,7 +14,7 @@ class MyAppWidgetHostView(context: Context) : AppWidgetHostView(context) { private var actionDownCoords = PointF() private var currentCoords = PointF() private var actionDownMS = 0L - private val moveGestureThreshold = resources.getDimension(R.dimen.move_gesture_threshold).toInt() + private val moveGestureThreshold = resources.getDimension(R.dimen.move_gesture_threshold).toInt() / 4 var hasLongPressed = false var ignoreTouches = false var longPressListener: ((x: Float, y: Float) -> Unit)? = null @@ -52,7 +52,7 @@ class MyAppWidgetHostView(context: Context) : AppWidgetHostView(context) { MotionEvent.ACTION_MOVE -> { currentCoords.x = event.rawX currentCoords.y = event.rawY - if (hasFingerMoved(event.rawX, event.rawY)) { + if (abs(actionDownCoords.x - currentCoords.x) > moveGestureThreshold ) { resetTouches() return true } @@ -67,7 +67,7 @@ class MyAppWidgetHostView(context: Context) : AppWidgetHostView(context) { } private val longPressRunnable = Runnable { - if (!hasFingerMoved(currentCoords.x, currentCoords.y)) { + if (abs(actionDownCoords.x - currentCoords.x) < moveGestureThreshold && abs(actionDownCoords.y - currentCoords.y) < moveGestureThreshold) { longPressHandler.removeCallbacksAndMessages(null) hasLongPressed = true longPressListener?.invoke(actionDownCoords.x, actionDownCoords.y)