mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-11 16:57:39 +00:00
fix: PiP portrait aspect ratio and PiP close (X) button hangup
- Restore Rational(9, 16) portrait aspect ratio for PiP window - Add onStop handler: when PiP is dismissed via X button, hang up the call and finish the activity (mirrors PipVideoActivity pattern) - onPictureInPictureModeChanged also hangs up if activity is finishing https://claude.ai/code/session_01Ak5tTkujpjNG1r5ASuPipZ
This commit is contained in:
@@ -98,9 +98,32 @@ class CallActivity : AppCompatActivity() {
|
||||
enterPipIfActive()
|
||||
}
|
||||
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean) {
|
||||
super.onPictureInPictureModeChanged(isInPictureInPictureMode)
|
||||
isInPipMode.value = isInPictureInPictureMode
|
||||
|
||||
if (!isInPictureInPictureMode) {
|
||||
// User pressed the X button on PiP or expanded it.
|
||||
// If the activity is finishing (user dismissed PiP), hang up.
|
||||
if (isFinishing) {
|
||||
GlobalScope.launch { ActiveCallHolder.callManager?.hangup() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
// When PiP is dismissed (X button), Android stops the activity.
|
||||
// If we're not in PiP anymore and the activity is stopping, hang up and finish.
|
||||
if (!isInPictureInPictureMode) {
|
||||
val state = ActiveCallHolder.callManager?.state?.value
|
||||
if (state is CallState.Connected || state is CallState.Connecting || state is CallState.Offering) {
|
||||
GlobalScope.launch { ActiveCallHolder.callManager?.hangup() }
|
||||
}
|
||||
finishAndRemoveTask()
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
@@ -148,7 +171,7 @@ class CallActivity : AppCompatActivity() {
|
||||
val builder =
|
||||
PictureInPictureParams
|
||||
.Builder()
|
||||
.setAspectRatio(Rational(16, 9))
|
||||
.setAspectRatio(Rational(9, 16))
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
builder.setActions(buildPipActions())
|
||||
|
||||
Reference in New Issue
Block a user