Commit fe3f6ee1 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy Committed by Geoffrey Métais

Fix brightness / volume gesture triggering the hud opening

parent 6f47ec7c
...@@ -12,7 +12,8 @@ import kotlinx.coroutines.ObsoleteCoroutinesApi ...@@ -12,7 +12,8 @@ import kotlinx.coroutines.ObsoleteCoroutinesApi
import org.videolan.libvlc.MediaPlayer import org.videolan.libvlc.MediaPlayer
import org.videolan.medialibrary.Tools import org.videolan.medialibrary.Tools
import org.videolan.vlc.util.AndroidDevices 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_AUDIO_VOLUME = 1
const val TOUCH_FLAG_BRIGHTNESS = 1 shl 1 const val TOUCH_FLAG_BRIGHTNESS = 1 shl 1
...@@ -157,11 +158,12 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity, ...@@ -157,11 +158,12 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity,
} }
} }
MotionEvent.ACTION_UP -> { MotionEvent.ACTION_UP -> {
val touchSlop = ViewConfiguration.get(player).scaledTouchSlop
if (touchAction == TOUCH_IGNORE) touchAction = TOUCH_NONE if (touchAction == TOUCH_IGNORE) touchAction = TOUCH_NONE
// Mouse events for the core // Mouse events for the core
player.sendMouseEvent(MotionEvent.ACTION_UP, xTouch, yTouch) player.sendMouseEvent(MotionEvent.ACTION_UP, xTouch, yTouch)
// Seek // Seek
if (touchAction == TOUCH_SEEK) doSeekTouch(Math.round(deltaY), xgesturesize, true) if (touchAction == TOUCH_SEEK) doSeekTouch(deltaY.roundToInt(), xgesturesize, true)
touchX = -1f touchX = -1f
touchY = -1f touchY = -1f
...@@ -173,10 +175,13 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity, ...@@ -173,10 +175,13 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity,
lastTapTimeMs = 0 lastTapTimeMs = 0
} }
if (numberOfTaps > 0 && now - lastTapTimeMs < 500) { //verify that the touch coordinate distance did not exceed the touchslop to increment the count tap
numberOfTaps += 1 if (abs(event.rawX - initTouchX) < touchSlop && abs(event.rawY - initTouchY) < touchSlop) {
} else { if (numberOfTaps > 0 && now - lastTapTimeMs < ViewConfiguration.getDoubleTapTimeout()) {
numberOfTaps = 1 numberOfTaps += 1
} else {
numberOfTaps = 1
}
} }
lastTapTimeMs = now lastTapTimeMs = now
...@@ -393,7 +398,6 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity, ...@@ -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) data class ScreenConfig(val metrics: DisplayMetrics, val xRange: Int, val yRange: Int, val orientation: Int)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment