mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20: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 PLAYBACK_SPEED = "playback_speed"
|
||||||
const val FULLSCREEN_ORIENTATION = "fullscreen_orientation"
|
const val FULLSCREEN_ORIENTATION = "fullscreen_orientation"
|
||||||
const val PAUSE_ON_SCREEN_OFF = "pause_screen_off"
|
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 WATCH_HISTORY_TOGGLE = "watch_history_toggle"
|
||||||
const val SEARCH_HISTORY_TOGGLE = "search_history_toggle"
|
const val SEARCH_HISTORY_TOGGLE = "search_history_toggle"
|
||||||
const val SYSTEM_CAPTION_STYLE = "system_caption_style"
|
const val SYSTEM_CAPTION_STYLE = "system_caption_style"
|
||||||
|
@ -190,12 +190,18 @@ object PlayerHelper {
|
|||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
val watchPositionsEnabled: Boolean
|
private val watchPositionsPref: String
|
||||||
get() = PreferenceHelper.getBoolean(
|
get() = PreferenceHelper.getString(
|
||||||
PreferenceKeys.WATCH_POSITION_TOGGLE,
|
PreferenceKeys.WATCH_POSITIONS,
|
||||||
true
|
"always"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val watchPositionsVideo: Boolean
|
||||||
|
get() = watchPositionsPref in listOf("always", "videos")
|
||||||
|
|
||||||
|
val watchPositionsAudio: Boolean
|
||||||
|
get() = watchPositionsPref == "always"
|
||||||
|
|
||||||
val watchHistoryEnabled: Boolean
|
val watchHistoryEnabled: Boolean
|
||||||
get() = PreferenceHelper.getBoolean(
|
get() = PreferenceHelper.getBoolean(
|
||||||
PreferenceKeys.WATCH_HISTORY_TOGGLE,
|
PreferenceKeys.WATCH_HISTORY_TOGGLE,
|
||||||
|
@ -138,7 +138,7 @@ class BackgroundMode : LifecycleService() {
|
|||||||
streamItem.url?.toID()?.let { playNextVideo(it) }
|
streamItem.url?.toID()?.let { playNextVideo(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PlayerHelper.watchPositionsEnabled) updateWatchPosition()
|
if (PlayerHelper.watchPositionsAudio) updateWatchPosition()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(TAG(), e.toString())
|
Log.e(TAG(), e.toString())
|
||||||
onDestroy()
|
onDestroy()
|
||||||
@ -210,7 +210,7 @@ class BackgroundMode : LifecycleService() {
|
|||||||
// seek to the previous position if available
|
// seek to the previous position if available
|
||||||
if (seekToPosition != 0L) {
|
if (seekToPosition != 0L) {
|
||||||
player?.seekTo(seekToPosition)
|
player?.seekTo(seekToPosition)
|
||||||
} else if (PlayerHelper.watchPositionsEnabled) {
|
} else if (PlayerHelper.watchPositionsAudio) {
|
||||||
runCatching {
|
runCatching {
|
||||||
val watchPosition = awaitQuery {
|
val watchPosition = awaitQuery {
|
||||||
Database.watchPositionDao().findById(videoId)
|
Database.watchPositionDao().findById(videoId)
|
||||||
|
@ -628,7 +628,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
|
|
||||||
// save the watch position if video isn't finished and option enabled
|
// save the watch position if video isn't finished and option enabled
|
||||||
private fun saveWatchPosition() {
|
private fun saveWatchPosition() {
|
||||||
if (!PlayerHelper.watchPositionsEnabled) return
|
if (!PlayerHelper.watchPositionsVideo) return
|
||||||
val watchPosition = WatchPosition(videoId!!, exoPlayer.currentPosition)
|
val watchPosition = WatchPosition(videoId!!, exoPlayer.currentPosition)
|
||||||
query {
|
query {
|
||||||
Database.watchPositionDao().insertAll(watchPosition)
|
Database.watchPositionDao().insertAll(watchPosition)
|
||||||
|
@ -51,7 +51,7 @@ class VideoOptionsBottomSheet(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// show the mark as watched option if watch positions are enabled
|
// show the mark as watched option if watch positions are enabled
|
||||||
if (PlayerHelper.watchPositionsEnabled) {
|
if (PlayerHelper.watchPositionsVideo) {
|
||||||
optionsList += getString(R.string.mark_as_watched)
|
optionsList += getString(R.string.mark_as_watched)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,4 +404,16 @@
|
|||||||
<item>avc</item>
|
<item>avc</item>
|
||||||
</string-array>
|
</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>
|
</resources>
|
||||||
|
@ -45,10 +45,12 @@
|
|||||||
|
|
||||||
<PreferenceCategory app:title="@string/watch_positions_title">
|
<PreferenceCategory app:title="@string/watch_positions_title">
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<ListPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="always"
|
||||||
|
android:entries="@array/watchPosition"
|
||||||
|
android:entryValues="@array/watchPositionValues"
|
||||||
android:icon="@drawable/ic_play_filled"
|
android:icon="@drawable/ic_play_filled"
|
||||||
app:key="watch_position_toggle"
|
app:key="watch_positions"
|
||||||
app:summary="@string/watch_positions_summary"
|
app:summary="@string/watch_positions_summary"
|
||||||
app:title="@string/watch_positions" />
|
app:title="@string/watch_positions" />
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user