[Android] Fix brightness / volume gesture triggering the hud opening

Nicolas Pomepuy git at videolan.org
Wed Jul 17 11:19:34 CEST 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Wed Jul 17 07:53:54 2019 +0200| [fe3f6ee1b7a33010e5ec839bb3e2048b71bd9f0c] | committer: Geoffrey Métais

Fix brightness / volume gesture triggering the hud opening

> https://code.videolan.org/videolan/vlc-android/commit/fe3f6ee1b7a33010e5ec839bb3e2048b71bd9f0c
---

 .../org/videolan/vlc/gui/video/VideoTouchDelegate.kt   | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt b/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt
index 0f339ed2d..9ba1ce1db 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt
@@ -12,7 +12,8 @@ import kotlinx.coroutines.ObsoleteCoroutinesApi
 import org.videolan.libvlc.MediaPlayer
 import org.videolan.medialibrary.Tools
 import org.videolan.vlc.util.AndroidDevices
-
+import kotlin.math.abs
+import kotlin.math.roundToInt
 
 const val TOUCH_FLAG_AUDIO_VOLUME = 1
 const val TOUCH_FLAG_BRIGHTNESS = 1 shl 1
@@ -157,11 +158,12 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity,
                         }
                     }
                     MotionEvent.ACTION_UP -> {
+                        val touchSlop = ViewConfiguration.get(player).scaledTouchSlop
                         if (touchAction == TOUCH_IGNORE) touchAction = TOUCH_NONE
                         // Mouse events for the core
                         player.sendMouseEvent(MotionEvent.ACTION_UP, xTouch, yTouch)
                         // Seek
-                        if (touchAction == TOUCH_SEEK) doSeekTouch(Math.round(deltaY), xgesturesize, true)
+                        if (touchAction == TOUCH_SEEK) doSeekTouch(deltaY.roundToInt(), xgesturesize, true)
                         touchX = -1f
                         touchY = -1f
 
@@ -173,10 +175,13 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity,
                             lastTapTimeMs = 0
                         }
 
-                        if (numberOfTaps > 0 && now - lastTapTimeMs < 500) {
-                            numberOfTaps += 1
-                        } else {
-                            numberOfTaps = 1
+                        //verify that the touch coordinate distance did not exceed the touchslop to increment the count tap
+                        if (abs(event.rawX - initTouchX) < touchSlop && abs(event.rawY - initTouchY) < touchSlop) {
+                            if (numberOfTaps > 0 && now - lastTapTimeMs < ViewConfiguration.getDoubleTapTimeout()) {
+                                numberOfTaps += 1
+                            } else {
+                                numberOfTaps = 1
+                            }
                         }
 
                         lastTapTimeMs = now
@@ -393,7 +398,6 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity,
             }
         }
     }
-
 }
 
 data class ScreenConfig(val metrics: DisplayMetrics, val xRange: Int, val yRange: Int, val orientation: Int)
\ No newline at end of file



More information about the Android mailing list