fix: pip-to-audio action does not close pip window (#6476)

This commit is contained in:
Jānis 2024-09-10 18:47:36 +03:00 committed by GitHub
parent d8f826ec6b
commit bf99635b48
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,7 @@
package com.github.libretube.ui.fragments
import android.annotation.SuppressLint
import android.app.Activity
import android.app.Dialog
import android.content.BroadcastReceiver
import android.content.Context
@ -175,6 +176,9 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
*/
private var playerLayoutOrientation = Int.MIN_VALUE
// Activity that's active during PiP, can be used for controlling its lifecycle.
private var pipActivity: Activity? = null
private val mainActivity get() = activity as MainActivity
private val windowInsetsControllerCompat
get() = WindowCompat
@ -219,7 +223,8 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
playOnBackground()
// wait some time in order for the service to get started properly
handler.postDelayed(500) {
activity?.finish()
pipActivity?.moveTaskToBack(false)
pipActivity = null
}
}
@ -1511,6 +1516,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
updateCurrentSubtitle(null)
openOrCloseFullscreenDialog(true)
pipActivity = activity
} else {
binding.player.useController = true