diff --git a/app/src/main/java/org/linphone/activities/voip/data/ConferenceParticipantDeviceData.kt b/app/src/main/java/org/linphone/activities/voip/data/ConferenceParticipantDeviceData.kt index da463586c..2fb7fda14 100644 --- a/app/src/main/java/org/linphone/activities/voip/data/ConferenceParticipantDeviceData.kt +++ b/app/src/main/java/org/linphone/activities/voip/data/ConferenceParticipantDeviceData.kt @@ -47,6 +47,8 @@ class ConferenceParticipantDeviceData( val isJoining = MutableLiveData() + val isActiveSpeaker = MutableLiveData() + private var textureView: TextureView? = null private val listener = object : ParticipantDeviceListenerStub() { @@ -113,6 +115,7 @@ class ConferenceParticipantDeviceData( participantDevice.addListener(listener) isSpeaking.value = false + isActiveSpeaker.value = false isMuted.value = participantDevice.isMuted videoAvailable.value = participantDevice.getStreamAvailability(StreamType.Video) diff --git a/app/src/main/java/org/linphone/activities/voip/viewmodels/ConferenceViewModel.kt b/app/src/main/java/org/linphone/activities/voip/viewmodels/ConferenceViewModel.kt index 153f8d9c2..e69e25b8b 100644 --- a/app/src/main/java/org/linphone/activities/voip/viewmodels/ConferenceViewModel.kt +++ b/app/src/main/java/org/linphone/activities/voip/viewmodels/ConferenceViewModel.kt @@ -185,8 +185,11 @@ class ConferenceViewModel : ViewModel() { val device = conferenceParticipantDevices.value.orEmpty().find { it.participantDevice.address.weakEqual(participantDevice.address) } + if (device != null && device != speakingParticipant.value) { Log.i("[Conference] Found actively speaking participant device") + speakingParticipant.value?.isActiveSpeaker?.value = false + device.isActiveSpeaker.value = true speakingParticipant.value = device!! } else if (device == null) { Log.w("[Conference] Participant device [${participantDevice.address.asStringUriOnly()}] is the active speaker but couldn't find it in devices list") @@ -488,6 +491,7 @@ class ConferenceViewModel : ViewModel() { if (activelySpeakingParticipantDevice == device) { Log.i("[Conference] Actively speaking participant device found: ${device.name} (${device.address.asStringUriOnly()})") speakingParticipant.value = deviceData + deviceData.isActiveSpeaker.value = true foundActivelySpeakingParticipantDevice = true } } @@ -495,7 +499,9 @@ class ConferenceViewModel : ViewModel() { if (!foundActivelySpeakingParticipantDevice && devices.isNotEmpty()) { Log.w("[Conference] Actively speaking participant device not found, using first participant device available") - speakingParticipant.value = devices.first() + val deviceData = devices.first() + speakingParticipant.value = deviceData + deviceData.isActiveSpeaker.value = true } for (device in conference.me.devices) { @@ -530,6 +536,7 @@ class ConferenceViewModel : ViewModel() { if (speakingParticipant.value == null) { speakingParticipant.value = deviceData + deviceData.isActiveSpeaker.value = true } conferenceParticipantDevices.value = sortedDevices @@ -561,7 +568,9 @@ class ConferenceViewModel : ViewModel() { if (removedDeviceWasActiveSpeaker && devicesCount > 1) { Log.w("[Conference] Updating actively speaking participant device using first one available") // Using second device as first is ourselves - speakingParticipant.value = devices[1] + val deviceData = devices[1] + speakingParticipant.value = deviceData + deviceData.isActiveSpeaker.value = true } conferenceParticipantDevices.value = devices diff --git a/app/src/main/java/org/linphone/activities/voip/views/GridBoxLayout.kt b/app/src/main/java/org/linphone/activities/voip/views/GridBoxLayout.kt index 3e68f86e4..69cf9d6cc 100644 --- a/app/src/main/java/org/linphone/activities/voip/views/GridBoxLayout.kt +++ b/app/src/main/java/org/linphone/activities/voip/views/GridBoxLayout.kt @@ -29,7 +29,11 @@ import org.linphone.core.tools.Log class GridBoxLayout : GridLayout { companion object { - private val placementMatrix = arrayOf(intArrayOf(1, 2, 3, 4, 5, 6), intArrayOf(1, 1, 2, 2, 3, 3), intArrayOf(1, 1, 1, 2, 2, 2), intArrayOf(1, 1, 1, 1, 2, 2), intArrayOf(1, 1, 1, 1, 1, 2), intArrayOf(1, 1, 1, 1, 1, 1)) + private val placementMatrix = arrayOf( + intArrayOf(1, 2, 3, 4, 5, 6), intArrayOf(1, 1, 2, 2, 3, 3), + intArrayOf(1, 1, 1, 2, 2, 2), intArrayOf(1, 1, 1, 1, 2, 2), + intArrayOf(1, 1, 1, 1, 1, 2), intArrayOf(1, 1, 1, 1, 1, 1) + ) } constructor(context: Context) : this(context, null) diff --git a/app/src/main/res/layout/voip_conference_participant_remote_active_speaker_miniature.xml b/app/src/main/res/layout/voip_conference_participant_remote_active_speaker_miniature.xml index 54f2a2c7e..e2ceadd86 100644 --- a/app/src/main/res/layout/voip_conference_participant_remote_active_speaker_miniature.xml +++ b/app/src/main/res/layout/voip_conference_participant_remote_active_speaker_miniature.xml @@ -16,6 +16,7 @@ android:layout_height="@dimen/voip_active_speaker_miniature_size" android:layout_margin="5dp" android:background="@{!data.isInConference && !data.isJoining ? @drawable/shape_remote_paused_background : @drawable/shape_remote_background, default=@drawable/shape_remote_background}" + android:visibility="@{data.isActiveSpeaker ? View.GONE : View.VISIBLE}" app:layout_alignSelf="flex_end" app:layout_flexShrink="0">