diff --git a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/pip/PictureInPicturePresenter.kt b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/pip/PictureInPicturePresenter.kt index aeb507f6ec..274a80cc26 100644 --- a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/pip/PictureInPicturePresenter.kt +++ b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/pip/PictureInPicturePresenter.kt @@ -60,7 +60,9 @@ class PictureInPicturePresenter( } is PictureInPictureEvent.SetPipOrientation -> { Timber.tag(loggerTag.value).d("onOrientationChange: ${event.orientation}") - pipView?.setPipOrientation(event.orientation) + if (isPipSupported) { + pipView?.setPipOrientation(event.orientation) + } } } } diff --git a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/pip/PipView.kt b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/pip/PipView.kt index aa1ab79dd0..54b8d77601 100644 --- a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/pip/PipView.kt +++ b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/pip/PipView.kt @@ -8,9 +8,15 @@ package io.element.android.features.call.impl.pip +import android.os.Build +import androidx.annotation.RequiresApi + interface PipView { + @RequiresApi(Build.VERSION_CODES.O) fun setPipOrientation(orientation: Int?) + @RequiresApi(Build.VERSION_CODES.O) fun setPipParams() + @RequiresApi(Build.VERSION_CODES.O) fun enterPipMode(): Boolean fun hangUp() } diff --git a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/ElementCallActivity.kt b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/ElementCallActivity.kt index 5ed9e29fe2..4a6b8f1c05 100644 --- a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/ElementCallActivity.kt +++ b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/ElementCallActivity.kt @@ -202,7 +202,9 @@ class ElementCallActivity : } DisposableEffect(Unit) { val onPictureInPictureModeChangedListener = Consumer { _: PictureInPictureModeChangedInfo -> - setPipParams() + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + setPipParams() + } pipEventSink(PictureInPictureEvent.OnPictureInPictureModeChanged(isInPictureInPictureMode)) if (!isInPictureInPictureMode && !lifecycle.currentState.isAtLeast(Lifecycle.State.STARTED)) { Timber.tag(loggerTag.value).d("Exiting PiP mode: Hangup the call") @@ -300,6 +302,7 @@ class ElementCallActivity : } } + @RequiresApi(Build.VERSION_CODES.O) override fun setPipOrientation(orientation: Int?) { currentPipOrientation = orientation setPictureInPictureParams(getPictureInPictureParams())