[Android] VideoControls: add scale gesture setting

Duncan McNamara git at videolan.org
Thu Aug 11 06:08:49 UTC 2022


vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Wed Aug 10 11:45:38 2022 +0200| [db01760f9b9e65b534d241bc5cccbf24a36bc3bd] | committer: Nicolas Pomepuy

VideoControls: add scale gesture setting

All gestures have settings to disable them, except the scale to switch
from BEST_FIT to FIT_SCREEN.

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

 application/resources/src/main/res/values/strings.xml               | 2 ++
 application/tools/src/main/java/org/videolan/tools/Settings.kt      | 1 +
 application/vlc-android/res/xml/preferences_video_controls.xml      | 6 ++++++
 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt           | 5 +++--
 .../src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt            | 6 ++++--
 5 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index 17c08e24e..d700bfef5 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -345,6 +345,8 @@
     <string name="enable_double_tap_play_summary">Double tap on screen center to play or pause</string>
     <string name="enable_swipe_seek_title">Swipe to seek</string>
     <string name="enable_swipe_seek_summary">Swipe you finger across the screen to seek</string>
+    <string name="enable_scale_gesture_title">Two finger zoom</string>
+    <string name="enable_scale_gesture_summary">Zoom in and out with two fingers</string>
     <string name="popup_keepscreen_title">Keep screen ON in Pop-Up mode</string>
     <string name="popup_keepscreen_summary">Always keep screen ON while Pop-Up is displayed, even if video is paused.</string>
     <string name="browser_show_hidden_files_title">Show hidden files</string>
diff --git a/application/tools/src/main/java/org/videolan/tools/Settings.kt b/application/tools/src/main/java/org/videolan/tools/Settings.kt
index 57132a804..57f239fd2 100644
--- a/application/tools/src/main/java/org/videolan/tools/Settings.kt
+++ b/application/tools/src/main/java/org/videolan/tools/Settings.kt
@@ -124,6 +124,7 @@ const val ENABLE_DOUBLE_TAP_PLAY = "enable_double_tap_play"
 const val ENABLE_VOLUME_GESTURE = "enable_volume_gesture"
 const val ENABLE_BRIGHTNESS_GESTURE = "enable_brightness_gesture"
 const val ENABLE_SCREENSHOT_GESTURE = "enable_screenshot_gesture"
+const val ENABLE_SCALE_GESTURE = "enable_scale_gesture"
 const val SAVE_BRIGHTNESS = "save_brightness"
 const val BRIGHTNESS_VALUE = "brightness_value"
 const val POPUP_KEEPSCREEN = "popup_keepscreen"
diff --git a/application/vlc-android/res/xml/preferences_video_controls.xml b/application/vlc-android/res/xml/preferences_video_controls.xml
index a261f25ac..dedc1a052 100644
--- a/application/vlc-android/res/xml/preferences_video_controls.xml
+++ b/application/vlc-android/res/xml/preferences_video_controls.xml
@@ -25,6 +25,12 @@
                 android:summary="@string/enable_brightness_gesture_summary"
                 android:title="@string/enable_brightness_gesture_title"
                 app:singleLineTitle="false" />
+        <CheckBoxPreference
+                android:defaultValue="true"
+                android:key="enable_scale_gesture"
+                android:summary="@string/enable_scale_gesture_summary"
+                android:title="@string/enable_scale_gesture_title"
+                app:singleLineTitle="false" />
         <CheckBoxPreference
                 android:defaultValue="true"
                 android:key="enable_double_tap_seek"
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
index 4a3c71670..507ec18ba 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
@@ -538,7 +538,8 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
                 + (if (settings.getBoolean(ENABLE_DOUBLE_TAP_SEEK, true)) TOUCH_FLAG_DOUBLE_TAP_SEEK else 0)
                 + (if (settings.getBoolean(ENABLE_DOUBLE_TAP_PLAY, true)) TOUCH_FLAG_PLAY else 0)
                 + (if (settings.getBoolean(ENABLE_SWIPE_SEEK, true)) TOUCH_FLAG_SWIPE_SEEK else 0)
-                + (if (settings.getBoolean(ENABLE_SCREENSHOT_GESTURE, false)) TOUCH_FLAG_SCREENSHOT else 0))
+                + (if (settings.getBoolean(ENABLE_SCREENSHOT_GESTURE, false)) TOUCH_FLAG_SCREENSHOT else 0)
+                + (if (settings.getBoolean(ENABLE_SCALE_GESTURE, true)) TOUCH_FLAG_SCALE else 0))
     } else 0
 
     override fun fireDialog(dialog: Dialog) {
@@ -2264,7 +2265,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
      */
     fun onChangedControlSetting(key: String) = when(key) {
         AUDIO_BOOST -> isAudioBoostEnabled = settings.getBoolean(AUDIO_BOOST, true)
-        ENABLE_VOLUME_GESTURE, ENABLE_BRIGHTNESS_GESTURE, ENABLE_DOUBLE_TAP_SEEK, ENABLE_DOUBLE_TAP_PLAY, ENABLE_SWIPE_SEEK, ENABLE_SCREENSHOT_GESTURE -> touchDelegate.touchControls = generateTouchFlags()
+        ENABLE_VOLUME_GESTURE, ENABLE_BRIGHTNESS_GESTURE, ENABLE_DOUBLE_TAP_SEEK, ENABLE_DOUBLE_TAP_PLAY, ENABLE_SWIPE_SEEK, ENABLE_SCREENSHOT_GESTURE, ENABLE_SCALE_GESTURE -> touchDelegate.touchControls = generateTouchFlags()
         ENABLE_SEEK_BUTTONS -> overlayDelegate.seekButtons = settings.getBoolean(ENABLE_SEEK_BUTTONS, false)
         else -> {}
     }
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt
index 6bfaa4591..35ac1b211 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt
@@ -39,6 +39,7 @@ const val TOUCH_FLAG_DOUBLE_TAP_SEEK = 1 shl 2
 const val TOUCH_FLAG_PLAY = 1 shl 3
 const val TOUCH_FLAG_SWIPE_SEEK = 1 shl 4
 const val TOUCH_FLAG_SCREENSHOT = 1 shl 5
+const val TOUCH_FLAG_SCALE = 1 shl 6
 //Touch Events
 private const val TOUCH_NONE = 0
 private const val TOUCH_VOLUME = 1
@@ -433,11 +434,12 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity,
 
         private var savedScale: MediaPlayer.ScaleType? = null
         override fun onScaleBegin(detector: ScaleGestureDetector): Boolean {
+            if (touchControls and TOUCH_FLAG_SCALE != TOUCH_FLAG_SCALE) return false
             return screenConfig.xRange != 0 || player.fov == 0f
         }
 
         override fun onScale(detector: ScaleGestureDetector): Boolean {
-            if (player.fov != 0f && !player.isLocked) {
+            if (player.fov != 0f && !player.isLocked && (touchControls and TOUCH_FLAG_SCALE == TOUCH_FLAG_SCALE)) {
                 val diff = VideoPlayerActivity.DEFAULT_FOV * (1 - detector.scaleFactor)
                 if (player.updateViewpoint(0f, 0f, diff)) {
                     player.fov = (player.fov + diff).coerceIn(MIN_FOV, MAX_FOV)
@@ -448,7 +450,7 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity,
         }
 
         override fun onScaleEnd(detector: ScaleGestureDetector) {
-            if (player.fov == 0f && !player.isLocked) {
+            if (player.fov == 0f && !player.isLocked && (touchControls and TOUCH_FLAG_SCALE == TOUCH_FLAG_SCALE)) {
                 val grow = detector.scaleFactor > 1.0f
                 if (grow && player.currentScaleType != MediaPlayer.ScaleType.SURFACE_FIT_SCREEN) {
                     savedScale = player.currentScaleType



More information about the Android mailing list