From d38c264e7de716f8038dcdc6a6407046fda62fc4 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 3 Apr 2023 13:38:22 +0200 Subject: [PATCH] lock call activity in portrait mode during audio call --- .../siacs/conversations/ui/RtpSessionActivity.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java index 592a28d59..b7352aa27 100644 --- a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java @@ -10,6 +10,7 @@ import android.app.PictureInPictureParams; import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; +import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.os.Build; import android.os.Bundle; @@ -406,7 +407,7 @@ public class RtpSessionActivity extends XmppActivity private void putScreenInCallMode(final Set media) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - if (!media.contains(Media.VIDEO)) { + if (Media.audioOnly(media)) { final JingleRtpConnection rtpConnection = rtpConnectionReference != null ? rtpConnectionReference.get() : null; final AppRTCAudioManager audioManager = @@ -417,6 +418,15 @@ public class RtpSessionActivity extends XmppActivity acquireProximityWakeLock(); } } + lockOrientation(media); + } + + private void lockOrientation(final Set media) { + if (Media.audioOnly(media)) { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + } else { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); + } } @SuppressLint("WakelockTimeout") @@ -1379,6 +1389,7 @@ public class RtpSessionActivity extends XmppActivity final AbstractJingleConnection.Id id = requireRtpConnection().getId(); final boolean verified = requireRtpConnection().isVerified(); final Set media = getMedia(); + lockOrientation(media); final ContentAddition contentAddition = getPendingContentAddition(); final Contact contact = getWith(); if (account == id.account && id.with.equals(with) && id.sessionId.equals(sessionId)) {