diff --git a/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt b/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt
index 196b80038..f97ceb533 100644
--- a/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt
+++ b/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt
@@ -59,7 +59,7 @@ object PreferenceKeys {
const val PLAYBACK_SPEED = "playback_speed"
const val FULLSCREEN_ORIENTATION = "fullscreen_orientation"
const val PAUSE_ON_SCREEN_OFF = "pause_screen_off"
- const val WATCH_POSITION_TOGGLE = "watch_position_toggle"
+ const val WATCH_POSITIONS = "watch_positions"
const val WATCH_HISTORY_TOGGLE = "watch_history_toggle"
const val SEARCH_HISTORY_TOGGLE = "search_history_toggle"
const val SYSTEM_CAPTION_STYLE = "system_caption_style"
diff --git a/app/src/main/java/com/github/libretube/helpers/PlayerHelper.kt b/app/src/main/java/com/github/libretube/helpers/PlayerHelper.kt
index 431de910f..ad7d6d747 100644
--- a/app/src/main/java/com/github/libretube/helpers/PlayerHelper.kt
+++ b/app/src/main/java/com/github/libretube/helpers/PlayerHelper.kt
@@ -190,12 +190,18 @@ object PlayerHelper {
false
)
- val watchPositionsEnabled: Boolean
- get() = PreferenceHelper.getBoolean(
- PreferenceKeys.WATCH_POSITION_TOGGLE,
- true
+ private val watchPositionsPref: String
+ get() = PreferenceHelper.getString(
+ PreferenceKeys.WATCH_POSITIONS,
+ "always"
)
+ val watchPositionsVideo: Boolean
+ get() = watchPositionsPref in listOf("always", "videos")
+
+ val watchPositionsAudio: Boolean
+ get() = watchPositionsPref == "always"
+
val watchHistoryEnabled: Boolean
get() = PreferenceHelper.getBoolean(
PreferenceKeys.WATCH_HISTORY_TOGGLE,
diff --git a/app/src/main/java/com/github/libretube/services/BackgroundMode.kt b/app/src/main/java/com/github/libretube/services/BackgroundMode.kt
index 182a475eb..8b0557eb1 100644
--- a/app/src/main/java/com/github/libretube/services/BackgroundMode.kt
+++ b/app/src/main/java/com/github/libretube/services/BackgroundMode.kt
@@ -138,7 +138,7 @@ class BackgroundMode : LifecycleService() {
streamItem.url?.toID()?.let { playNextVideo(it) }
}
- if (PlayerHelper.watchPositionsEnabled) updateWatchPosition()
+ if (PlayerHelper.watchPositionsAudio) updateWatchPosition()
} catch (e: Exception) {
Log.e(TAG(), e.toString())
onDestroy()
@@ -210,7 +210,7 @@ class BackgroundMode : LifecycleService() {
// seek to the previous position if available
if (seekToPosition != 0L) {
player?.seekTo(seekToPosition)
- } else if (PlayerHelper.watchPositionsEnabled) {
+ } else if (PlayerHelper.watchPositionsAudio) {
runCatching {
val watchPosition = awaitQuery {
Database.watchPositionDao().findById(videoId)
diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt
index d9b73bfb5..0af7ca433 100644
--- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt
+++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt
@@ -628,7 +628,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
// save the watch position if video isn't finished and option enabled
private fun saveWatchPosition() {
- if (!PlayerHelper.watchPositionsEnabled) return
+ if (!PlayerHelper.watchPositionsVideo) return
val watchPosition = WatchPosition(videoId!!, exoPlayer.currentPosition)
query {
Database.watchPositionDao().insertAll(watchPosition)
diff --git a/app/src/main/java/com/github/libretube/ui/sheets/VideoOptionsBottomSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/VideoOptionsBottomSheet.kt
index dde893e74..3c0b7a0ee 100644
--- a/app/src/main/java/com/github/libretube/ui/sheets/VideoOptionsBottomSheet.kt
+++ b/app/src/main/java/com/github/libretube/ui/sheets/VideoOptionsBottomSheet.kt
@@ -51,7 +51,7 @@ class VideoOptionsBottomSheet(
}
// show the mark as watched option if watch positions are enabled
- if (PlayerHelper.watchPositionsEnabled) {
+ if (PlayerHelper.watchPositionsVideo) {
optionsList += getString(R.string.mark_as_watched)
}
diff --git a/app/src/main/res/values/array.xml b/app/src/main/res/values/array.xml
index b43536bf7..125ff938b 100644
--- a/app/src/main/res/values/array.xml
+++ b/app/src/main/res/values/array.xml
@@ -404,4 +404,16 @@
- avc
+
+ - @string/always
+ - @string/videos
+ - @string/never
+
+
+
+ - always
+ - videos
+ - never
+
+
diff --git a/app/src/main/res/xml/history_settings.xml b/app/src/main/res/xml/history_settings.xml
index 650aec620..dcdbd05b6 100644
--- a/app/src/main/res/xml/history_settings.xml
+++ b/app/src/main/res/xml/history_settings.xml
@@ -45,10 +45,12 @@
-