[Android] Add a settings for the video screenshot feature
Nicolas Pomepuy
git at videolan.org
Wed Jul 27 13:34:21 UTC 2022
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Jul 18 12:56:52 2022 +0200| [2d7323aa8360ffeef05548d03ad2464e5a221f3c] | committer: Duncan McNamara
Add a settings for the video screenshot feature
> https://code.videolan.org/videolan/vlc-android/commit/2d7323aa8360ffeef05548d03ad2464e5a221f3c
---
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 ++++++
.../org/videolan/vlc/gui/preferences/PreferencesVideoControls.kt | 1 +
.../src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt | 5 +++--
.../src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt | 5 +++--
6 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 fbdd6a9ec..2a31e9064 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -348,6 +348,8 @@
<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>
+ <string name="enable_video_screenshot">Take a screenshot</string>
+ <string name="enable_video_screenshot_summary">Tap with 3 fingers to take a screenshot</string>
<string name="subtitles_prefs_category">Subtitles</string>
<string name="subtitles_size_title">Subtitles Size</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 77148501d..95f156095 100644
--- a/application/tools/src/main/java/org/videolan/tools/Settings.kt
+++ b/application/tools/src/main/java/org/videolan/tools/Settings.kt
@@ -120,6 +120,7 @@ const val ENABLE_SWIPE_SEEK = "enable_swipe_seek"
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 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 44c4511fd..a261f25ac 100644
--- a/application/vlc-android/res/xml/preferences_video_controls.xml
+++ b/application/vlc-android/res/xml/preferences_video_controls.xml
@@ -49,6 +49,12 @@
android:dependency="enable_double_tap_seek"
app:key="video_double_tap_jump_delay"
app:title="@string/video_double_tap_jump_delay" />
+ <CheckBoxPreference
+ android:defaultValue="false"
+ android:key="enable_screenshot_gesture"
+ android:summary="@string/enable_video_screenshot_summary"
+ android:title="@string/enable_video_screenshot"
+ app:singleLineTitle="false" />
</PreferenceCategory>
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideoControls.kt b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideoControls.kt
index e7eeeacf7..6d56f1aa6 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideoControls.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideoControls.kt
@@ -43,6 +43,7 @@ class PreferencesVideoControls : BasePreferenceFragment(), SharedPreferences.OnS
findPreference<Preference>(AUDIO_BOOST)?.isVisible = !AndroidDevices.isAndroidTv
findPreference<Preference>(ENABLE_DOUBLE_TAP_SEEK)?.isVisible = !AndroidDevices.isAndroidTv
findPreference<Preference>(ENABLE_DOUBLE_TAP_PLAY)?.isVisible = !AndroidDevices.isAndroidTv
+ findPreference<Preference>(ENABLE_SCREENSHOT_GESTURE)?.isVisible = !AndroidDevices.isAndroidTv
findPreference<Preference>(ENABLE_VOLUME_GESTURE)?.isVisible = AndroidDevices.hasTsp
findPreference<Preference>(ENABLE_BRIGHTNESS_GESTURE)?.isVisible = AndroidDevices.hasTsp
findPreference<Preference>(POPUP_KEEPSCREEN)?.isVisible = !AndroidDevices.isAndroidTv && !AndroidUtil.isOOrLater
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 f024b1723..f0c551654 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
@@ -537,7 +537,8 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
+ (if (brightnessTouch) TOUCH_FLAG_BRIGHTNESS else 0)
+ (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_SWIPE_SEEK, true)) TOUCH_FLAG_SWIPE_SEEK else 0)
+ + (if (settings.getBoolean(ENABLE_SCREENSHOT_GESTURE, false)) TOUCH_FLAG_SCREENSHOT else 0))
} else 0
override fun fireDialog(dialog: Dialog) {
@@ -2245,7 +2246,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 -> touchDelegate.touchControls = generateTouchFlags()
+ ENABLE_VOLUME_GESTURE, ENABLE_BRIGHTNESS_GESTURE, ENABLE_DOUBLE_TAP_SEEK, ENABLE_DOUBLE_TAP_PLAY, ENABLE_SWIPE_SEEK, ENABLE_SCREENSHOT_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 ec448dbac..6bfaa4591 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
@@ -38,6 +38,7 @@ const val TOUCH_FLAG_BRIGHTNESS = 1 shl 1
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
//Touch Events
private const val TOUCH_NONE = 0
private const val TOUCH_VOLUME = 1
@@ -167,7 +168,7 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity,
player.sendMouseEvent(MotionEvent.ACTION_DOWN, xTouch, yTouch)
}
MotionEvent.ACTION_MOVE -> {
- if (event.pointerCount == 3) touchAction = TOUCH_SCREENSHOT
+ if ((touchControls and TOUCH_FLAG_SCREENSHOT == TOUCH_FLAG_SCREENSHOT) && event.pointerCount == 3) touchAction = TOUCH_SCREENSHOT
if (touchAction == TOUCH_IGNORE) return false
// Mouse events for the core
player.sendMouseEvent(MotionEvent.ACTION_MOVE, xTouch, yTouch)
@@ -201,7 +202,7 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity,
}
}
MotionEvent.ACTION_UP -> {
- if (touchAction == TOUCH_SCREENSHOT) {
+ if ((touchControls and TOUCH_FLAG_SCREENSHOT == TOUCH_FLAG_SCREENSHOT) && touchAction == TOUCH_SCREENSHOT) {
player.takeScreenshot()
return true
}
More information about the Android
mailing list