mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 11:39:42 +01:00
Merge pull request #5008 from nextcloud/simplifyCallGridLayoutForVoiceOnly
simplify call grid design logic for voice only calls
This commit is contained in:
commit
eb75f488c5
@ -947,8 +947,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
ParticipantGrid(
|
ParticipantGrid(
|
||||||
participantUiStates = participantUiStates,
|
participantUiStates = participantUiStates,
|
||||||
eglBase = rootEglBase!!,
|
eglBase = rootEglBase!!,
|
||||||
isVoiceOnlyCall = isVoiceOnlyCall,
|
isVoiceOnlyCall = isVoiceOnlyCall
|
||||||
isInPipMode = isInPipMode
|
|
||||||
) {
|
) {
|
||||||
animateCallControls(true, 0)
|
animateCallControls(true, 0)
|
||||||
}
|
}
|
||||||
|
@ -12,11 +12,11 @@ package com.nextcloud.talk.call.components
|
|||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.BoxWithConstraints
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
|
||||||
import androidx.compose.foundation.lazy.grid.GridCells
|
import androidx.compose.foundation.lazy.grid.GridCells
|
||||||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
||||||
import androidx.compose.foundation.lazy.grid.items
|
import androidx.compose.foundation.lazy.grid.items
|
||||||
@ -36,7 +36,6 @@ fun ParticipantGrid(
|
|||||||
eglBase: EglBase?,
|
eglBase: EglBase?,
|
||||||
participantUiStates: List<ParticipantUiState>,
|
participantUiStates: List<ParticipantUiState>,
|
||||||
isVoiceOnlyCall: Boolean,
|
isVoiceOnlyCall: Boolean,
|
||||||
isInPipMode: Boolean,
|
|
||||||
onClick: () -> Unit
|
onClick: () -> Unit
|
||||||
) {
|
) {
|
||||||
val configuration = LocalConfiguration.current
|
val configuration = LocalConfiguration.current
|
||||||
@ -44,8 +43,9 @@ fun ParticipantGrid(
|
|||||||
|
|
||||||
val minItemHeight = 100.dp
|
val minItemHeight = 100.dp
|
||||||
|
|
||||||
val columns =
|
if (participantUiStates.isEmpty()) return
|
||||||
if (isPortrait) {
|
|
||||||
|
val columns = if (isPortrait) {
|
||||||
when (participantUiStates.size) {
|
when (participantUiStates.size) {
|
||||||
1, 2, 3 -> 1
|
1, 2, 3 -> 1
|
||||||
else -> 2
|
else -> 2
|
||||||
@ -56,38 +56,32 @@ fun ParticipantGrid(
|
|||||||
2, 4 -> 2
|
2, 4 -> 2
|
||||||
else -> 3
|
else -> 3
|
||||||
}
|
}
|
||||||
}
|
}.coerceAtLeast(1) // Prevent 0
|
||||||
|
|
||||||
val rows = ceil(participantUiStates.size / columns.toFloat()).toInt()
|
val rows = ceil(participantUiStates.size / columns.toFloat()).toInt().coerceAtLeast(1)
|
||||||
|
|
||||||
val heightForNonGridComponents = if (isVoiceOnlyCall && !isInPipMode) {
|
|
||||||
// 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 itemSpacing = 8.dp
|
||||||
val edgePadding = 8.dp
|
val edgePadding = 8.dp
|
||||||
|
|
||||||
val totalVerticalSpacing = itemSpacing * (rows - 1)
|
val totalVerticalSpacing = itemSpacing * (rows - 1)
|
||||||
val totalVerticalPadding = edgePadding * 2
|
val totalVerticalPadding = edgePadding * 2
|
||||||
val availableHeight = gridHeight - totalVerticalSpacing - totalVerticalPadding
|
|
||||||
|
|
||||||
val rawItemHeight = availableHeight / rows
|
BoxWithConstraints(
|
||||||
|
modifier = modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.clickable { onClick() }
|
||||||
|
) {
|
||||||
|
val availableHeight = maxHeight
|
||||||
|
|
||||||
|
val gridAvailableHeight = availableHeight - totalVerticalSpacing - totalVerticalPadding
|
||||||
|
val rawItemHeight = gridAvailableHeight / rows
|
||||||
val itemHeight = maxOf(rawItemHeight, minItemHeight)
|
val itemHeight = maxOf(rawItemHeight, minItemHeight)
|
||||||
|
|
||||||
LazyVerticalGrid(
|
LazyVerticalGrid(
|
||||||
columns = GridCells.Fixed(columns),
|
columns = GridCells.Fixed(columns),
|
||||||
modifier = Modifier
|
modifier = Modifier.fillMaxSize(),
|
||||||
.fillMaxSize()
|
|
||||||
.padding(horizontal = edgePadding)
|
|
||||||
.clickable { onClick() },
|
|
||||||
verticalArrangement = Arrangement.spacedBy(itemSpacing),
|
verticalArrangement = Arrangement.spacedBy(itemSpacing),
|
||||||
horizontalArrangement = Arrangement.spacedBy(itemSpacing),
|
horizontalArrangement = Arrangement.spacedBy(itemSpacing),
|
||||||
contentPadding = PaddingValues(vertical = edgePadding)
|
contentPadding = PaddingValues(vertical = edgePadding, horizontal = edgePadding)
|
||||||
) {
|
) {
|
||||||
items(
|
items(
|
||||||
participantUiStates,
|
participantUiStates,
|
||||||
@ -104,6 +98,7 @@ fun ParticipantGrid(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Preview
|
@Preview
|
||||||
@Composable
|
@Composable
|
||||||
@ -111,8 +106,7 @@ fun ParticipantGridPreview() {
|
|||||||
ParticipantGrid(
|
ParticipantGrid(
|
||||||
participantUiStates = getTestParticipants(1),
|
participantUiStates = getTestParticipants(1),
|
||||||
eglBase = null,
|
eglBase = null,
|
||||||
isVoiceOnlyCall = false,
|
isVoiceOnlyCall = false
|
||||||
isInPipMode = false
|
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,8 +116,7 @@ fun TwoParticipants() {
|
|||||||
ParticipantGrid(
|
ParticipantGrid(
|
||||||
participantUiStates = getTestParticipants(2),
|
participantUiStates = getTestParticipants(2),
|
||||||
eglBase = null,
|
eglBase = null,
|
||||||
isVoiceOnlyCall = false,
|
isVoiceOnlyCall = false
|
||||||
isInPipMode = false
|
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,8 +126,7 @@ fun ThreeParticipants() {
|
|||||||
ParticipantGrid(
|
ParticipantGrid(
|
||||||
participantUiStates = getTestParticipants(3),
|
participantUiStates = getTestParticipants(3),
|
||||||
eglBase = null,
|
eglBase = null,
|
||||||
isVoiceOnlyCall = false,
|
isVoiceOnlyCall = false
|
||||||
isInPipMode = false
|
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,8 +136,7 @@ fun FourParticipants() {
|
|||||||
ParticipantGrid(
|
ParticipantGrid(
|
||||||
participantUiStates = getTestParticipants(4),
|
participantUiStates = getTestParticipants(4),
|
||||||
eglBase = null,
|
eglBase = null,
|
||||||
isVoiceOnlyCall = false,
|
isVoiceOnlyCall = false
|
||||||
isInPipMode = false
|
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,8 +146,7 @@ fun FiveParticipants() {
|
|||||||
ParticipantGrid(
|
ParticipantGrid(
|
||||||
participantUiStates = getTestParticipants(5),
|
participantUiStates = getTestParticipants(5),
|
||||||
eglBase = null,
|
eglBase = null,
|
||||||
isVoiceOnlyCall = false,
|
isVoiceOnlyCall = false
|
||||||
isInPipMode = false
|
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,8 +156,7 @@ fun SevenParticipants() {
|
|||||||
ParticipantGrid(
|
ParticipantGrid(
|
||||||
participantUiStates = getTestParticipants(7),
|
participantUiStates = getTestParticipants(7),
|
||||||
eglBase = null,
|
eglBase = null,
|
||||||
isVoiceOnlyCall = false,
|
isVoiceOnlyCall = false
|
||||||
isInPipMode = false
|
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,8 +166,7 @@ fun FiftyParticipants() {
|
|||||||
ParticipantGrid(
|
ParticipantGrid(
|
||||||
participantUiStates = getTestParticipants(50),
|
participantUiStates = getTestParticipants(50),
|
||||||
eglBase = null,
|
eglBase = null,
|
||||||
isVoiceOnlyCall = false,
|
isVoiceOnlyCall = false
|
||||||
isInPipMode = false
|
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,8 +180,7 @@ fun OneParticipantLandscape() {
|
|||||||
ParticipantGrid(
|
ParticipantGrid(
|
||||||
participantUiStates = getTestParticipants(1),
|
participantUiStates = getTestParticipants(1),
|
||||||
eglBase = null,
|
eglBase = null,
|
||||||
isVoiceOnlyCall = false,
|
isVoiceOnlyCall = false
|
||||||
isInPipMode = false
|
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,8 +194,7 @@ fun TwoParticipantsLandscape() {
|
|||||||
ParticipantGrid(
|
ParticipantGrid(
|
||||||
participantUiStates = getTestParticipants(2),
|
participantUiStates = getTestParticipants(2),
|
||||||
eglBase = null,
|
eglBase = null,
|
||||||
isVoiceOnlyCall = false,
|
isVoiceOnlyCall = false
|
||||||
isInPipMode = false
|
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,8 +208,7 @@ fun ThreeParticipantsLandscape() {
|
|||||||
ParticipantGrid(
|
ParticipantGrid(
|
||||||
participantUiStates = getTestParticipants(3),
|
participantUiStates = getTestParticipants(3),
|
||||||
eglBase = null,
|
eglBase = null,
|
||||||
isVoiceOnlyCall = false,
|
isVoiceOnlyCall = false
|
||||||
isInPipMode = false
|
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,8 +222,7 @@ fun FourParticipantsLandscape() {
|
|||||||
ParticipantGrid(
|
ParticipantGrid(
|
||||||
participantUiStates = getTestParticipants(4),
|
participantUiStates = getTestParticipants(4),
|
||||||
eglBase = null,
|
eglBase = null,
|
||||||
isVoiceOnlyCall = false,
|
isVoiceOnlyCall = false
|
||||||
isInPipMode = false
|
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,8 +236,7 @@ fun SevenParticipantsLandscape() {
|
|||||||
ParticipantGrid(
|
ParticipantGrid(
|
||||||
participantUiStates = getTestParticipants(7),
|
participantUiStates = getTestParticipants(7),
|
||||||
eglBase = null,
|
eglBase = null,
|
||||||
isVoiceOnlyCall = false,
|
isVoiceOnlyCall = false
|
||||||
isInPipMode = false
|
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,8 +250,7 @@ fun FiftyParticipantsLandscape() {
|
|||||||
ParticipantGrid(
|
ParticipantGrid(
|
||||||
participantUiStates = getTestParticipants(50),
|
participantUiStates = getTestParticipants(50),
|
||||||
eglBase = null,
|
eglBase = null,
|
||||||
isVoiceOnlyCall = false,
|
isVoiceOnlyCall = false
|
||||||
isInPipMode = false
|
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user