[Android] Updated to make only first 5% change insensitive in vertical touch gesture (this allows fine tuning)

Vitaliy Grabchuk git at videolan.org
Wed Mar 13 11:11:31 CET 2019


vlc-android | branch: 3.1.x | Vitaliy Grabchuk <vitaliygrabchuk at gmail.com> | Thu Mar  7 11:43:21 2019 +0200| [a8f576b5fe6a0e873e6cc0cad6f52a503bf51a20] | committer: Geoffrey Métais

Updated to make only first 5% change insensitive in vertical touch gesture (this allows fine tuning)

Signed-off-by: Geoffrey Métais <geoffrey.metais at gmail.com>

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

 .../src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt    | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 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 57b9fd881..ce3216b56 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt
@@ -37,6 +37,7 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity,
     private var mInitTouchX = 0f
     private var mTouchY = -1f
     private var mTouchX = -1f
+    private var mVerticalTouchActive = false
 
     private var mLastMove: Long = 0
 
@@ -88,7 +89,7 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity,
                 }
 
                 val xChanged = if (mTouchX != -1f && mTouchY != -1f) event.rawX - mTouchX else 0f
-                val yChanged = if (xChanged != 0f) event.rawY - mTouchY else 0f
+                val yChanged = if (mTouchX != -1f && mTouchY != -1f) event.rawY - mTouchY else 0f
 
                 // coef is the gradient's move to determine a neutral zone
                 val coef = Math.abs(yChanged / xChanged)
@@ -100,6 +101,7 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity,
 
                 when (event.action) {
                     MotionEvent.ACTION_DOWN -> {
+                        mVerticalTouchActive = false
                         // Audio
                         mInitTouchY = event.rawY
                         mInitTouchX = event.rawX
@@ -120,7 +122,14 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity,
                             // No volume/brightness action if coef < 2 or a secondary display is connected
                             //TODO : Volume action when a secondary display is connected
                             if (mTouchAction != TOUCH_SEEK && coef > 2 && player.isOnPrimaryDisplay) {
-                                if (Math.abs(yChanged / screenConfig.yRange) < 0.05) return false
+                                if (!mVerticalTouchActive) {
+                                    if (Math.abs(yChanged / screenConfig.yRange) >= 0.05) {
+                                        mVerticalTouchActive = true
+                                        mTouchY = event.rawY
+                                        mTouchX = event.rawX
+                                    }
+                                    return false
+                                }
                                 mTouchY = event.rawY
                                 mTouchX = event.rawX
                                 doVerticalTouchAction(yChanged)



More information about the Android mailing list