@@ -14,7 +14,7 @@ class MyAppWidgetHostView(context: Context) : AppWidgetHostView(context) {
1414 private var actionDownCoords = PointF ()
1515 private var currentCoords = PointF ()
1616 private var actionDownMS = 0L
17- private val moveGestureThreshold = resources.getDimension(R .dimen.move_gesture_threshold).toInt()
17+ private val moveGestureThreshold = resources.getDimension(R .dimen.move_gesture_threshold).toInt() / 4
1818 var hasLongPressed = false
1919 var ignoreTouches = false
2020 var longPressListener: ((x: Float , y: Float ) -> Unit )? = null
@@ -52,7 +52,7 @@ class MyAppWidgetHostView(context: Context) : AppWidgetHostView(context) {
5252 MotionEvent .ACTION_MOVE -> {
5353 currentCoords.x = event.rawX
5454 currentCoords.y = event.rawY
55- if (hasFingerMoved(event.rawX, event.rawY) ) {
55+ if (abs(actionDownCoords.x - currentCoords.x) > moveGestureThreshold ) {
5656 resetTouches()
5757 return true
5858 }
@@ -67,7 +67,7 @@ class MyAppWidgetHostView(context: Context) : AppWidgetHostView(context) {
6767 }
6868
6969 private val longPressRunnable = Runnable {
70- if (! hasFingerMoved( currentCoords.x, currentCoords.y)) {
70+ if (abs(actionDownCoords.x - currentCoords.x) < moveGestureThreshold && abs(actionDownCoords.y - currentCoords.y) < moveGestureThreshold ) {
7171 longPressHandler.removeCallbacksAndMessages(null )
7272 hasLongPressed = true
7373 longPressListener?.invoke(actionDownCoords.x, actionDownCoords.y)
0 commit comments