diff --git a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt index bcee38708..200cdf81f 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -165,6 +165,7 @@ class PlayerFragment : BaseFragment() { private var sponsorBlockEnabled = true private var sponsorBlockNotifications = true private var skipButtonsEnabled = false + private var pipEnabled = true /** * for autoplay @@ -328,6 +329,11 @@ class PlayerFragment : BaseFragment() { PreferenceKeys.SKIP_BUTTONS, false ) + + pipEnabled = PreferenceHelper.getBoolean( + PreferenceKeys.PICTURE_IN_PICTURE, + true + ) } private fun initializeTransitionLayout() { @@ -1629,6 +1635,8 @@ class PlayerFragment : BaseFragment() { } private fun shouldStartPiP(): Boolean { + if (!pipEnabled) return false + val bounds = Rect() binding.playerScrollView.getHitRect(bounds) diff --git a/app/src/main/java/com/github/libretube/preferences/PreferenceKeys.kt b/app/src/main/java/com/github/libretube/preferences/PreferenceKeys.kt index 4074128fd..c8e087461 100644 --- a/app/src/main/java/com/github/libretube/preferences/PreferenceKeys.kt +++ b/app/src/main/java/com/github/libretube/preferences/PreferenceKeys.kt @@ -59,6 +59,7 @@ object PreferenceKeys { const val PLAYER_AUDIO_QUALITY = "player_audio_quality" const val DEFAULT_SUBTITLE = "default_subtitle" const val SKIP_BUTTONS = "skip_buttons" + const val PICTURE_IN_PICTURE = "picture_in_picture" /** * Background mode diff --git a/app/src/main/res/drawable/ic_window.xml b/app/src/main/res/drawable/ic_window.xml new file mode 100644 index 000000000..e58d327cd --- /dev/null +++ b/app/src/main/res/drawable/ic_window.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6f3ccd18c..5a4bee15d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -312,4 +312,5 @@ Current Backup & restore Backup + Picture in Picture diff --git a/app/src/main/res/xml/player_settings.xml b/app/src/main/res/xml/player_settings.xml index b3b646ed0..660f19e37 100644 --- a/app/src/main/res/xml/player_settings.xml +++ b/app/src/main/res/xml/player_settings.xml @@ -46,7 +46,7 @@ + +