From d32c6f70a1b7343373ed71dc80e7ec676680342f Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 30 Jan 2024 15:46:33 +0100 Subject: [PATCH] Hide active speaker miniature + fix display name missing + added missing mute indicator + added avatar if not sending video --- .../linphone/ui/call/model/ConferenceModel.kt | 22 ++++++----- .../model/ConferenceParticipantDeviceModel.kt | 8 ++++ .../call_conference_active_speaker_cell.xml | 4 +- ...all_conference_active_speaker_fragment.xml | 37 ++++++++++++++++++- .../res/layout/call_conference_grid_cell.xml | 2 +- 5 files changed, 60 insertions(+), 13 deletions(-) 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 e810fb220..248b1fbc3 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 @@ -53,7 +53,7 @@ class ConferenceModel { val participantsLabel = MutableLiveData() - val activeSpeakerName = MutableLiveData() + val activeSpeaker = MutableLiveData() val isCurrentCallInConference = MutableLiveData() @@ -87,16 +87,20 @@ class ConferenceModel { conference: Conference, participantDevice: ParticipantDevice ) { + activeSpeaker.value?.isActiveSpeaker?.postValue(false) + val found = participantDevices.value.orEmpty().find { it.device == participantDevice } if (found != null) { - val name = found.avatarModel.contactName ?: participantDevice.name ?: participantDevice.address.username - Log.i("$TAG Newly active speaker participant is [$name]") - activeSpeakerName.postValue(name.orEmpty()) + Log.i("$TAG Newly active speaker participant is [${found.name}]") + found.isActiveSpeaker.postValue(true) + activeSpeaker.postValue(found) } else { Log.i("$TAG Failed to find actively speaking participant...") - activeSpeakerName.postValue(participantDevice.name) + val model = ConferenceParticipantDeviceModel(participantDevice) + model.isActiveSpeaker.postValue(true) + activeSpeaker.postValue(model) } } @@ -299,10 +303,10 @@ class ConferenceModel { val model = ConferenceParticipantDeviceModel(device) devicesList.add(model) - if (device.isSpeaking) { - val name = model.avatarModel.contactName ?: device.name ?: device.address.username - Log.i("$TAG Using participant is [$name] as current active speaker") - activeSpeakerName.postValue(name.orEmpty()) + if (device == conference.activeSpeakerParticipantDevice) { + Log.i("$TAG Using participant is [${model.name}] as current active speaker") + model.isActiveSpeaker.postValue(true) + activeSpeaker.postValue(model) } } } diff --git a/app/src/main/java/org/linphone/ui/call/model/ConferenceParticipantDeviceModel.kt b/app/src/main/java/org/linphone/ui/call/model/ConferenceParticipantDeviceModel.kt index 118cde62a..2df8e0ed9 100644 --- a/app/src/main/java/org/linphone/ui/call/model/ConferenceParticipantDeviceModel.kt +++ b/app/src/main/java/org/linphone/ui/call/model/ConferenceParticipantDeviceModel.kt @@ -29,6 +29,7 @@ import org.linphone.core.ParticipantDevice import org.linphone.core.ParticipantDeviceListenerStub import org.linphone.core.StreamType import org.linphone.core.tools.Log +import org.linphone.utils.LinphoneUtils class ConferenceParticipantDeviceModel @WorkerThread constructor( val device: ParticipantDevice, @@ -40,10 +41,16 @@ class ConferenceParticipantDeviceModel @WorkerThread constructor( val avatarModel = coreContext.contactsManager.getContactAvatarModelForAddress(device.address) + val name = avatarModel.contactName ?: device.name ?: LinphoneUtils.getDisplayName( + device.address + ) + val isMuted = MutableLiveData() val isSpeaking = MutableLiveData() + val isActiveSpeaker = MutableLiveData() + val isVideoAvailable = MutableLiveData() val isSendingVideo = MutableLiveData() @@ -119,6 +126,7 @@ class ConferenceParticipantDeviceModel @WorkerThread constructor( isMuted.postValue(device.isMuted) isSpeaking.postValue(device.isSpeaking) + isActiveSpeaker.postValue(false) Log.i( "$TAG Participant [${device.address.asStringUriOnly()}] is in state [${device.state}]" ) diff --git a/app/src/main/res/layout/call_conference_active_speaker_cell.xml b/app/src/main/res/layout/call_conference_active_speaker_cell.xml index b143f6ced..d9bd35f5f 100644 --- a/app/src/main/res/layout/call_conference_active_speaker_cell.xml +++ b/app/src/main/res/layout/call_conference_active_speaker_cell.xml @@ -13,12 +13,14 @@ + + android:layout_height="match_parent" + android:background="@color/gray_900"> + + + +