Option to disable watch positions in audio mode

This commit is contained in:
Bnyro 2023-02-12 12:55:31 +01:00
parent 80be666b48
commit 7648f1822f
7 changed files with 32 additions and 12 deletions

View File

@ -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"

View File

@ -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,

View File

@ -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)

View File

@ -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)

View File

@ -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)
}

View File

@ -404,4 +404,16 @@
<item>avc</item>
</string-array>
<string-array name="watchPosition">
<item>@string/always</item>
<item>@string/videos</item>
<item>@string/never</item>
</string-array>
<string-array name="watchPositionValues">
<item>always</item>
<item>videos</item>
<item>never</item>
</string-array>
</resources>

View File

@ -45,10 +45,12 @@
<PreferenceCategory app:title="@string/watch_positions_title">
<SwitchPreferenceCompat
android:defaultValue="true"
<ListPreference
android:defaultValue="always"
android:entries="@array/watchPosition"
android:entryValues="@array/watchPositionValues"
android:icon="@drawable/ic_play_filled"
app:key="watch_position_toggle"
app:key="watch_positions"
app:summary="@string/watch_positions_summary"
app:title="@string/watch_positions" />