Turn #1560 into an option

This commit is contained in:
Bnyro 2022-12-27 18:48:09 +01:00
parent 0dfb47143b
commit 0f72df6e70
6 changed files with 29 additions and 1 deletions

View File

@ -86,6 +86,7 @@ object PreferenceKeys {
const val PLAYER_PINCH_CONTROL = "player_pinch_control"
const val CAPTIONS_SIZE = "captions_size"
const val DOUBLE_TAP_TO_SEEK = "double_tap_seek"
const val PAUSE_ON_QUIT = "pause_on_quit"
/**
* Background mode

View File

@ -1442,7 +1442,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
activity?.enterPictureInPictureMode(getPipParams())
return
}
if (!PlayerHelper.pipEnabled) exoPlayer.pause()
if (PlayerHelper.pauseOnQuit) exoPlayer.pause()
}
@RequiresApi(Build.VERSION_CODES.O)

View File

@ -2,6 +2,8 @@ package com.github.libretube.ui.preferences
import android.content.ActivityNotFoundException
import android.content.Intent
import android.os.Build
import android.os.Build.VERSION.SDK_INT
import android.os.Bundle
import android.provider.Settings
import android.widget.Toast
@ -59,6 +61,18 @@ class PlayerSettings : BasePreferenceFragment() {
}
true
}
val pictureInPicture = findPreference<SwitchPreferenceCompat>(
PreferenceKeys.PICTURE_IN_PICTURE
)!!
val pauseOnQuit = findPreference<SwitchPreferenceCompat>(PreferenceKeys.PAUSE_ON_QUIT)
pictureInPicture.isVisible = SDK_INT >= Build.VERSION_CODES.O
pauseOnQuit?.isVisible = !pictureInPicture.isVisible || !pictureInPicture.isChecked
pictureInPicture.setOnPreferenceChangeListener { _, newValue ->
pauseOnQuit?.isVisible = !(newValue as Boolean)
true
}
}
private fun setupSubtitlePref(preference: ListPreference) {

View File

@ -320,6 +320,12 @@ object PlayerHelper {
true
)
val pauseOnQuit: Boolean
get() = PreferenceHelper.getBoolean(
PreferenceKeys.PAUSE_ON_QUIT,
false
)
fun getDefaultResolution(context: Context): String {
return if (NetworkHelper.isNetworkMobile(context)) {
PreferenceHelper.getString(

View File

@ -421,6 +421,7 @@
<string name="hide_watched_from_feed">Hide watched videos from feed</string>
<string name="hide_watched_from_feed_summary">Don\'t show videos being watched more than 90% in the subscriptions tab.</string>
<string name="playlistUrl">Playlist URL</string>
<string name="pause_on_quit">Pause on quit</string>
<!-- Notification channel strings -->
<string name="download_channel_name">Download Service</string>

View File

@ -38,6 +38,12 @@
app:key="picture_in_picture"
app:title="@string/picture_in_picture" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:icon="@drawable/ic_pause_filled"
app:key="pause_on_quit"
app:title="@string/pause_on_quit" />
<SwitchPreferenceCompat
android:icon="@drawable/ic_rotating_circle"
android:summary="@string/autoRotatePlayer_summary"