diff --git a/application/resources/src/main/res/values/arrays.xml b/application/resources/src/main/res/values/arrays.xml index c69181bd9..621dd95e5 100644 --- a/application/resources/src/main/res/values/arrays.xml +++ b/application/resources/src/main/res/values/arrays.xml @@ -442,18 +442,4 @@ 2 - - @string/timeout_infinite - @string/timeout_short - @string/timeout_normal - @string/timeout_long - - - - -1 - 1 - 2 - 3 - - \ No newline at end of file diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml index eeb2ccf2d..22f556a55 100644 --- a/application/resources/src/main/res/values/strings.xml +++ b/application/resources/src/main/res/values/strings.xml @@ -822,10 +822,8 @@ Allow OTG access Please select your OTG drive to allow access to VLC. Infinite - Short - Normal - Long Video player controls hiding delay + %ss Remove from history Prefer SMB 1 Uncheck this setting if you have some difficulties browsing your SMB server 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 bcaa8763a..c9044b1a1 100644 --- a/application/tools/src/main/java/org/videolan/tools/Settings.kt +++ b/application/tools/src/main/java/org/videolan/tools/Settings.kt @@ -39,7 +39,7 @@ object Settings : SingletonHolder({ init(it.applicat showVideoThumbs = prefs.getBoolean(SHOW_VIDEO_THUMBNAILS, true) tvUI = prefs.getBoolean(PREF_TV_UI, false) listTitleEllipsize = prefs.getString(LIST_TITLE_ELLIPSIZE, "0")?.toInt() ?: 0 - videoHudDelay = prefs.getString(VIDEO_HUD_TIMEOUT, "2")?.toInt() ?: 2 + videoHudDelay = prefs.getInt(VIDEO_HUD_TIMEOUT, 4) device = DeviceInfo(context) includeMissing = prefs.getBoolean(KEY_INCLUDE_MISSING, true) showHeaders = prefs.getBoolean(KEY_SHOW_HEADERS, true) @@ -136,7 +136,7 @@ const val KEY_PLAYBACK_SPEED_PERSIST = "playback_speed" const val KEY_PLAYBACK_SPEED_PERSIST_VIDEO = "playback_speed_video" const val KEY_VIDEO_APP_SWITCH = "video_action_switch" const val VIDEO_TRANSITION_SHOW = "video_transition_show" -const val VIDEO_HUD_TIMEOUT = "video_hud_timeout" +const val VIDEO_HUD_TIMEOUT = "video_hud_timeout_in_s" const val RESULT_RESCAN = Activity.RESULT_FIRST_USER + 1 const val RESULT_RESTART = Activity.RESULT_FIRST_USER + 2 const val RESULT_RESTART_APP = Activity.RESULT_FIRST_USER + 3 diff --git a/application/vlc-android/res/xml/preferences_video_controls.xml b/application/vlc-android/res/xml/preferences_video_controls.xml index f9d39513b..57755a8e5 100644 --- a/application/vlc-android/res/xml/preferences_video_controls.xml +++ b/application/vlc-android/res/xml/preferences_video_controls.xml @@ -67,12 +67,14 @@ app:singleLineTitle="false" /> - 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 082189a1d..07d5e0ad1 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 @@ -50,9 +50,17 @@ class PreferencesVideoControls : BasePreferenceFragment(), SharedPreferences.OnS findPreference(ENABLE_BRIGHTNESS_GESTURE)?.isVisible = AndroidDevices.hasTsp findPreference(POPUP_KEEPSCREEN)?.isVisible = !AndroidDevices.isAndroidTv && !AndroidUtil.isOOrLater findPreference(KEY_VIDEO_DOUBLE_TAP_JUMP_DELAY)?.title = getString(if (AndroidDevices.isAndroidTv) R.string.video_key_jump_delay else R.string.video_double_tap_jump_delay) + updateHudTimeoutSummary() } + private fun updateHudTimeoutSummary() { + when (Settings.videoHudDelay) { + 0 -> findPreference(VIDEO_HUD_TIMEOUT)?.summary = getString(R.string.timeout_infinite) + else -> findPreference(VIDEO_HUD_TIMEOUT)?.summary = getString(R.string.video_hud_timeout_summary, Settings.videoHudDelay.toString()) + } + } + override fun onStart() { super.onStart() preferenceScreen.sharedPreferences.registerOnSharedPreferenceChangeListener(this) @@ -68,7 +76,8 @@ class PreferencesVideoControls : BasePreferenceFragment(), SharedPreferences.OnS (activity as? VideoPlayerActivity)?.onChangedControlSetting(key) when (key) { VIDEO_HUD_TIMEOUT -> { - Settings.videoHudDelay = sharedPreferences.getString(VIDEO_HUD_TIMEOUT, "2")?.toInt() ?: 2 + Settings.videoHudDelay = sharedPreferences.getInt(VIDEO_HUD_TIMEOUT, 4) + updateHudTimeoutSummary() } KEY_VIDEO_JUMP_DELAY -> { Settings.videoJumpDelay = sharedPreferences.getInt(KEY_VIDEO_JUMP_DELAY, 10) 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 5c1e6db63..3e4dd94a6 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 @@ -935,7 +935,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback, return false } if (isShowing || fov == 0f && keyCode == KeyEvent.KEYCODE_DPAD_DOWN && !overlayDelegate.playlistContainer.isVisible()) - overlayDelegate.showOverlayTimeout(OVERLAY_TIMEOUT) + overlayDelegate.showOverlayTimeout(Settings.videoHudDelay) when (keyCode) { KeyEvent.KEYCODE_MEDIA_FAST_FORWARD -> { touchDelegate.seekDelta(Settings.videoDoubleTapJumpDelay * 1000) @@ -1005,7 +1005,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback, if (isNavMenu) return navigateDvdMenu(keyCode) else if (isLocked) { - overlayDelegate.showOverlayTimeout(OVERLAY_TIMEOUT) + overlayDelegate.showOverlayTimeout(Settings.videoHudDelay) } else if (!isShowing && !overlayDelegate.playlistContainer.isVisible()) { if (event.isAltPressed && event.isCtrlPressed) { touchDelegate.seekDelta(-300000) @@ -1026,7 +1026,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback, if (isNavMenu) return navigateDvdMenu(keyCode) else if (isLocked) { - overlayDelegate.showOverlayTimeout(OVERLAY_TIMEOUT) + overlayDelegate.showOverlayTimeout(Settings.videoHudDelay) } else if (!isShowing && !overlayDelegate.playlistContainer.isVisible()) { if (event.isAltPressed && event.isCtrlPressed) { touchDelegate.seekDelta(300000) @@ -1047,7 +1047,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback, if (isNavMenu) return navigateDvdMenu(keyCode) else if (isLocked) { - overlayDelegate.showOverlayTimeout(OVERLAY_TIMEOUT) + overlayDelegate.showOverlayTimeout(Settings.videoHudDelay) } else if (event.isCtrlPressed) { volumeUp() return true @@ -1063,7 +1063,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback, if (isNavMenu) return navigateDvdMenu(keyCode) else if (isLocked) { - overlayDelegate.showOverlayTimeout(OVERLAY_TIMEOUT) + overlayDelegate.showOverlayTimeout(Settings.videoHudDelay) } else if (event.isCtrlPressed) { volumeDown() return true @@ -1076,7 +1076,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback, if (isNavMenu) return navigateDvdMenu(keyCode) else if (isLocked) { - overlayDelegate.showOverlayTimeout(OVERLAY_TIMEOUT) + overlayDelegate.showOverlayTimeout(Settings.videoHudDelay) } else if (!isShowing) { doPlayPause() return true @@ -1384,7 +1384,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback, overlayDelegate.updateOverlayPausePlay() updateNavStatus() if (!mw.hasFlag(MediaWrapper.MEDIA_PAUSED)) - handler.sendEmptyMessageDelayed(FADE_OUT, OVERLAY_TIMEOUT.toLong()) + handler.sendEmptyMessageDelayed(FADE_OUT, Settings.videoHudDelay.toLong()) else { mw.removeFlags(MediaWrapper.MEDIA_PAUSED) wasPaused = false @@ -2181,7 +2181,6 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback, private const val KEY_TIME = "saved_time" private const val KEY_LIST = "saved_list" private const val KEY_URI = "saved_uri" - const val OVERLAY_TIMEOUT = 4000 const val OVERLAY_INFINITE = -1 const val FADE_OUT = 1 const val FADE_OUT_INFO = 2 diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt index 0843acc83..764e1baad 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt @@ -289,14 +289,12 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) { initOverlay() if (!::hudBinding.isInitialized) return overlayTimeout = when { - Settings.videoHudDelay == -2 -> VideoPlayerActivity.OVERLAY_INFINITE + Settings.videoHudDelay == 0 -> VideoPlayerActivity.OVERLAY_INFINITE isBookmarkShown() -> VideoPlayerActivity.OVERLAY_INFINITE timeout != 0 -> timeout service.isPlaying -> when (Settings.videoHudDelay) { - -1 -> VideoPlayerActivity.OVERLAY_INFINITE - 1 -> VideoPlayerActivity.OVERLAY_TIMEOUT / 2 - 3 -> VideoPlayerActivity.OVERLAY_TIMEOUT * 2 - else -> VideoPlayerActivity.OVERLAY_TIMEOUT + 0 -> VideoPlayerActivity.OVERLAY_INFINITE + else -> Settings.videoHudDelay * 1000 } else -> VideoPlayerActivity.OVERLAY_INFINITE } @@ -393,7 +391,7 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) { hudBinding.abRepeatMarkerA.visibility = if (abvalues.start == -1L) View.GONE else View.VISIBLE hudBinding.abRepeatMarkerB.visibility = if (abvalues.stop == -1L) View.GONE else View.VISIBLE service.manageAbRepeatStep(hudBinding.abRepeatReset, hudBinding.abRepeatStop, hudBinding.abRepeatContainer, abRepeatAddMarker) - if (player.settings.getBoolean(VIDEO_TRANSITION_SHOW, true)) showOverlayTimeout(if (abvalues.start == -1L || abvalues.stop == -1L) VideoPlayerActivity.OVERLAY_INFINITE else VideoPlayerActivity.OVERLAY_TIMEOUT) + if (player.settings.getBoolean(VIDEO_TRANSITION_SHOW, true)) showOverlayTimeout(if (abvalues.start == -1L || abvalues.stop == -1L) VideoPlayerActivity.OVERLAY_INFINITE else Settings.videoHudDelay) }) service.playlistManager.abRepeatOn.observe(player, { abRepeatAddMarker.visibility = if (it) View.VISIBLE else View.GONE @@ -474,7 +472,7 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) { hudBinding.orientationToggle.setOnClickListener(if (enabled) player else null) hudBinding.orientationToggle.setOnLongClickListener(if (enabled) player else null) hudBinding.swipeToUnlock.setOnStartTouchingListener { showOverlayTimeout(VideoPlayerActivity.OVERLAY_INFINITE) } - hudBinding.swipeToUnlock.setOnStopTouchingListener { showOverlayTimeout(VideoPlayerActivity.OVERLAY_TIMEOUT) } + hudBinding.swipeToUnlock.setOnStopTouchingListener { showOverlayTimeout(Settings.videoHudDelay) } hudBinding.swipeToUnlock.setOnUnlockListener { player.toggleLock() } } if (::hudRightBinding.isInitialized){ @@ -810,7 +808,7 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) { bookmarkListDelegate.markerContainer = hudBinding.bookmarkMarkerContainer bookmarkListDelegate.visibilityListener = { if (bookmarkListDelegate.visible) showOverlayTimeout(VideoPlayerActivity.OVERLAY_INFINITE) - else showOverlayTimeout(VideoPlayerActivity.OVERLAY_TIMEOUT) + else showOverlayTimeout(Settings.videoHudDelay) } } bookmarkListDelegate.show() diff --git a/application/vlc-android/src/org/videolan/vlc/util/VersionMigration.kt b/application/vlc-android/src/org/videolan/vlc/util/VersionMigration.kt index 1517ec36e..4d90294e3 100644 --- a/application/vlc-android/src/org/videolan/vlc/util/VersionMigration.kt +++ b/application/vlc-android/src/org/videolan/vlc/util/VersionMigration.kt @@ -37,7 +37,7 @@ import org.videolan.tools.* import java.io.File import java.io.IOException -private const val CURRENT_VERSION = 3 +private const val CURRENT_VERSION = 4 object VersionMigration { @@ -53,6 +53,9 @@ object VersionMigration { if (lastVersion < 3) { migrateToVersion3(context) } + if (lastVersion < 4) { + migrateToVersion4(settings) + } settings.putSingle(KEY_CURRENT_SETTINGS_VERSION, CURRENT_VERSION) } @@ -108,4 +111,21 @@ object VersionMigration { deleteAllWatchNext(context) } } + + /** + * Migrate the video hud timeout preference to a value in seconds + */ + private fun migrateToVersion4(settings: SharedPreferences) { + Log.i(this::class.java.simpleName, "Migrating to Version 4: migrate from video_hud_timeout to video_hud_timeout_in_s") + val hudTimeOut = settings.getString("video_hud_timeout", "2")?.toInt() ?: 2 + settings.edit { + when { + hudTimeOut < 0 -> putInt(VIDEO_HUD_TIMEOUT, -1) + hudTimeOut == 2 -> putInt(VIDEO_HUD_TIMEOUT, 4) + hudTimeOut == 3 -> putInt(VIDEO_HUD_TIMEOUT, 8) + else -> putInt(VIDEO_HUD_TIMEOUT, 2) + } + remove("video_hud_timeout") + } + } } \ No newline at end of file