mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
Option to disable watch positions in audio mode
This commit is contained in:
parent
80be666b48
commit
7648f1822f
@ -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"
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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>
|
||||
|
@ -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" />
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user