fix(session): picture in picture keeps the DroidDeck front end behind the game (#2559)

This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-11-13 07:40:20 -05:00
1 parent c57cc33125
commit d058bab64f
3 files changed
+24 -4

No files matched your search

@@ -21,6 +21,7 @@ class SessionPipController(
private set
private var suppressAuto = false
private var visit = false
private var requested = false
private var lastParams = ""
val floating get() = transitioning || activity.isInPictureInPictureMode
@@ -47,7 +48,7 @@ class SessionPipController(
return builder.build()
}
fun enter() {
fun enter(explicit: Boolean = true) {
if (!eligible()) {
Toast.makeText(activity, R.string.pip_not_ready, Toast.LENGTH_SHORT).show()
return
@@ -59,8 +60,10 @@ class SessionPipController(
return
}
prepare()
requested = explicit
val entered = runCatching { activity.enterPictureInPictureMode(params(bounds())) }.getOrDefault(false)
if (!entered) {
requested = false
restore()
Toast.makeText(activity, R.string.pip_unavailable, Toast.LENGTH_SHORT).show()
}
@@ -68,7 +71,7 @@ class SessionPipController(
fun leaving() {
if (!automatic() || !allowed()) return
if (Build.VERSION.SDK_INT < 31) enter() else prepare()
if (Build.VERSION.SDK_INT < 31) enter(explicit = false) else prepare()
}
private fun prepare() {
@@ -85,6 +88,8 @@ class SessionPipController(
showPipUi(true)
SessionService.beginPip(activity)
SessionService.setActivityVisible(activity, true)
if (requested) runCatching { com.droiddeck.launcher.HomeApp.showFrontEnd(activity) }
requested = false
} else restore()
refresh(true)
}