From 913d1262037a48639b66c6cf92d28d2760ba4e01 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 21 Feb 2024 16:54:01 +0100 Subject: [PATCH] Automatically switch to active speaker layout when more participant devices than authorized by grid layout are present --- .../linphone/ui/call/model/ConferenceModel.kt | 17 +++++++++++++++++ .../org/linphone/ui/call/view/GridBoxLayout.kt | 2 ++ 2 files changed, 19 insertions(+) diff --git a/app/src/main/java/org/linphone/ui/call/model/ConferenceModel.kt b/app/src/main/java/org/linphone/ui/call/model/ConferenceModel.kt index 37c3952be..816c9b0b4 100644 --- a/app/src/main/java/org/linphone/ui/call/model/ConferenceModel.kt +++ b/app/src/main/java/org/linphone/ui/call/model/ConferenceModel.kt @@ -32,6 +32,7 @@ import org.linphone.core.Participant import org.linphone.core.ParticipantDevice import org.linphone.core.StreamType import org.linphone.core.tools.Log +import org.linphone.ui.call.view.GridBoxLayout import org.linphone.utils.AppUtils import org.linphone.utils.Event @@ -371,6 +372,8 @@ class ConferenceModel { activeSpeaker.postValue(first) } + checkIfTooManyParticipantDevicesForGridLayout(devicesList) + participantDevices.postValue(sortParticipantDevicesList(devicesList)) participants.postValue(participantsList) participantsLabel.postValue( @@ -441,6 +444,7 @@ class ConferenceModel { val newModel = ConferenceParticipantDeviceModel(participantDevice) list.add(newModel) + checkIfTooManyParticipantDevicesForGridLayout(list) participantDevices.postValue(sortParticipantDevicesList(list)) } @@ -497,4 +501,17 @@ class ConferenceModel { } } } + + @WorkerThread + private fun checkIfTooManyParticipantDevicesForGridLayout( + list: ArrayList + ) { + if (list.size > GridBoxLayout.MAX_CHILD && conferenceLayout.value == GRID_LAYOUT) { + Log.w( + "$TAG Too many participant devices for grid layout, switching to active speaker layout" + ) + setNewLayout(ACTIVE_SPEAKER_LAYOUT) + // TODO FIXME: notify user + } + } } diff --git a/app/src/main/java/org/linphone/ui/call/view/GridBoxLayout.kt b/app/src/main/java/org/linphone/ui/call/view/GridBoxLayout.kt index e45230c08..a36e482cf 100644 --- a/app/src/main/java/org/linphone/ui/call/view/GridBoxLayout.kt +++ b/app/src/main/java/org/linphone/ui/call/view/GridBoxLayout.kt @@ -32,6 +32,8 @@ class GridBoxLayout : GridLayout { companion object { private const val TAG = "[Grid Box Layout]" + const val MAX_CHILD = 6 + private val placementMatrix = arrayOf( intArrayOf(1, 2, 3, 4, 5, 6), intArrayOf(1, 1, 2, 2, 3, 3),