From 1136508ba24936f1a3cd6c5ab80468ad4589ced6 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Wed, 7 May 2025 10:33:58 +0200 Subject: [PATCH] fix voice only call design by workaround. For now, instead to measure height mixed from xml and compose, assume a fixed height for the xml views (callInfosLinearLayout and callControls) to limit the grid height. They is not a nice solution and should be replaced once everything is migrated to compose. Signed-off-by: Marcel Hibbe --- .../nextcloud/talk/activities/CallActivity.kt | 3 +- .../talk/adapters/ParticipantDisplayItem.kt | 2 +- .../talk/call/components/ParticipantGrid.kt | 62 ++++++++++++------- .../talk/call/components/ParticipantTile.kt | 8 +-- .../talk/call/components/WebRTCVideoView.kt | 2 +- 5 files changed, 46 insertions(+), 31 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt index 2eaeb68cc..7d8088e7c 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt @@ -960,7 +960,8 @@ class CallActivity : CallBaseActivity() { MaterialTheme { ParticipantGrid( participants = participantUiStates.toList(), - eglBase = rootEglBase!! + eglBase = rootEglBase!!, + isVoiceOnlyCall = isVoiceOnlyCall ) { animateCallControls(true, 0) } diff --git a/app/src/main/java/com/nextcloud/talk/adapters/ParticipantDisplayItem.kt b/app/src/main/java/com/nextcloud/talk/adapters/ParticipantDisplayItem.kt index 71c0fd428..4298f7aa8 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/ParticipantDisplayItem.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/ParticipantDisplayItem.kt @@ -148,7 +148,7 @@ class ParticipantDisplayItem( isStreamEnabled = isStreamEnabled, raisedHand = raisedHand?.state == true, avatarUrl = urlForAvatar, - mediaStream = mediaStream, + mediaStream = mediaStream ) } diff --git a/app/src/main/java/com/nextcloud/talk/call/components/ParticipantGrid.kt b/app/src/main/java/com/nextcloud/talk/call/components/ParticipantGrid.kt index 664e86c3f..135f3e523 100644 --- a/app/src/main/java/com/nextcloud/talk/call/components/ParticipantGrid.kt +++ b/app/src/main/java/com/nextcloud/talk/call/components/ParticipantGrid.kt @@ -10,11 +10,7 @@ package com.nextcloud.talk.call.components import android.content.res.Configuration import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height @@ -36,6 +32,7 @@ fun ParticipantGrid( modifier: Modifier = Modifier, eglBase: EglBase?, participants: List, + isVoiceOnlyCall: Boolean, onClick: () -> Unit ) { val configuration = LocalConfiguration.current @@ -59,13 +56,21 @@ fun ParticipantGrid( val rows = ceil(participants.size / columns.toFloat()).toInt() - val screenHeight = LocalConfiguration.current.screenHeightDp.dp + val heightForNonGridComponents = if (isVoiceOnlyCall) { + // this is a workaround for now. It should ~summarize the height of callInfosLinearLayout and callControls + // Once everything is migrated to jetpack, this workaround should be obsolete or solved in a better way + 240.dp + } else { + 0.dp + } + + val gridHeight = LocalConfiguration.current.screenHeightDp.dp - heightForNonGridComponents val itemSpacing = 8.dp val edgePadding = 8.dp val totalVerticalSpacing = itemSpacing * (rows - 1) val totalVerticalPadding = edgePadding * 2 - val availableHeight = screenHeight - totalVerticalSpacing - totalVerticalPadding + val availableHeight = gridHeight - totalVerticalSpacing - totalVerticalPadding val rawItemHeight = availableHeight / rows val itemHeight = maxOf(rawItemHeight, minItemHeight) @@ -74,14 +79,14 @@ fun ParticipantGrid( columns = GridCells.Fixed(columns), modifier = Modifier .fillMaxSize() - .padding(horizontal = edgePadding) // Only horizontal outer padding here + .padding(horizontal = edgePadding) .clickable { onClick() }, verticalArrangement = Arrangement.spacedBy(itemSpacing), horizontalArrangement = Arrangement.spacedBy(itemSpacing), - contentPadding = PaddingValues(vertical = edgePadding) // vertical padding handled here + contentPadding = PaddingValues(vertical = edgePadding) ) { items( - participants.sortedBy { it.isAudioEnabled }.asReversed(), + participants, key = { it.sessionKey } ) { participant -> ParticipantTile( @@ -100,7 +105,8 @@ fun ParticipantGrid( fun ParticipantGridPreview() { ParticipantGrid( participants = getTestParticipants(1), - eglBase = null + eglBase = null, + isVoiceOnlyCall = false ) {} } @@ -109,7 +115,8 @@ fun ParticipantGridPreview() { fun TwoParticipants() { ParticipantGrid( participants = getTestParticipants(2), - eglBase = null + eglBase = null, + isVoiceOnlyCall = false ) {} } @@ -118,7 +125,8 @@ fun TwoParticipants() { fun ThreeParticipants() { ParticipantGrid( participants = getTestParticipants(3), - eglBase = null + eglBase = null, + isVoiceOnlyCall = false ) {} } @@ -127,7 +135,8 @@ fun ThreeParticipants() { fun FourParticipants() { ParticipantGrid( participants = getTestParticipants(4), - eglBase = null + eglBase = null, + isVoiceOnlyCall = false ) {} } @@ -136,7 +145,8 @@ fun FourParticipants() { fun FiveParticipants() { ParticipantGrid( participants = getTestParticipants(5), - eglBase = null + eglBase = null, + isVoiceOnlyCall = false ) {} } @@ -145,7 +155,8 @@ fun FiveParticipants() { fun SevenParticipants() { ParticipantGrid( participants = getTestParticipants(7), - eglBase = null + eglBase = null, + isVoiceOnlyCall = false ) {} } @@ -154,7 +165,8 @@ fun SevenParticipants() { fun FiftyParticipants() { ParticipantGrid( participants = getTestParticipants(50), - eglBase = null + eglBase = null, + isVoiceOnlyCall = false ) {} } @@ -167,7 +179,8 @@ fun FiftyParticipants() { fun OneParticipantLandscape() { ParticipantGrid( participants = getTestParticipants(1), - eglBase = null + eglBase = null, + isVoiceOnlyCall = false ) {} } @@ -180,7 +193,8 @@ fun OneParticipantLandscape() { fun TwoParticipantsLandscape() { ParticipantGrid( participants = getTestParticipants(2), - eglBase = null + eglBase = null, + isVoiceOnlyCall = false ) {} } @@ -193,7 +207,8 @@ fun TwoParticipantsLandscape() { fun ThreeParticipantsLandscape() { ParticipantGrid( participants = getTestParticipants(3), - eglBase = null + eglBase = null, + isVoiceOnlyCall = false ) {} } @@ -206,7 +221,8 @@ fun ThreeParticipantsLandscape() { fun FourParticipantsLandscape() { ParticipantGrid( participants = getTestParticipants(4), - eglBase = null + eglBase = null, + isVoiceOnlyCall = false ) {} } @@ -219,7 +235,8 @@ fun FourParticipantsLandscape() { fun SevenParticipantsLandscape() { ParticipantGrid( participants = getTestParticipants(7), - eglBase = null + eglBase = null, + isVoiceOnlyCall = false ) {} } @@ -232,7 +249,8 @@ fun SevenParticipantsLandscape() { fun FiftyParticipantsLandscape() { ParticipantGrid( participants = getTestParticipants(50), - eglBase = null + eglBase = null, + isVoiceOnlyCall = false ) {} } diff --git a/app/src/main/java/com/nextcloud/talk/call/components/ParticipantTile.kt b/app/src/main/java/com/nextcloud/talk/call/components/ParticipantTile.kt index 0d28af8ba..35b851ea0 100644 --- a/app/src/main/java/com/nextcloud/talk/call/components/ParticipantTile.kt +++ b/app/src/main/java/com/nextcloud/talk/call/components/ParticipantTile.kt @@ -33,11 +33,7 @@ import com.nextcloud.talk.call.ParticipantUiState import org.webrtc.EglBase @Composable -fun ParticipantTile( - participant: ParticipantUiState, - eglBase: EglBase?, - modifier: Modifier = Modifier -) { +fun ParticipantTile(participant: ParticipantUiState, eglBase: EglBase?, modifier: Modifier = Modifier) { Box( modifier = modifier .clip(RoundedCornerShape(12.dp)) @@ -110,7 +106,7 @@ fun ParticipantTilePreview() { isStreamEnabled = true, raisedHand = true, avatarUrl = "", - mediaStream = null, + mediaStream = null ) ParticipantTile( participant = participant, diff --git a/app/src/main/java/com/nextcloud/talk/call/components/WebRTCVideoView.kt b/app/src/main/java/com/nextcloud/talk/call/components/WebRTCVideoView.kt index c3947a139..814013ee1 100644 --- a/app/src/main/java/com/nextcloud/talk/call/components/WebRTCVideoView.kt +++ b/app/src/main/java/com/nextcloud/talk/call/components/WebRTCVideoView.kt @@ -18,7 +18,7 @@ import org.webrtc.SurfaceViewRenderer @Composable fun WebRTCVideoView( participant: ParticipantUiState, - eglBase: EglBase?, + eglBase: EglBase? ) { AndroidView( factory = { context ->