From ae818507aa40604cfd3440b6251b24f05c0142c3 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 22 Jan 2026 17:51:47 +0100 Subject: [PATCH] Fixed UI not updated when merging calls into a local conference --- .idea/misc.xml | 1 - .../java/org/linphone/ui/call/CallActivity.kt | 4 ++-- .../viewmodel/ConferenceViewModel.kt | 21 +++++++++++++------ .../ui/call/fragment/CallsListFragment.kt | 2 +- .../ui/call/viewmodel/CallsViewModel.kt | 6 +++++- .../history/viewmodel/HistoryViewModel.kt | 6 +++--- 6 files changed, 26 insertions(+), 14 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 74dd639e4..b2c751a35 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - diff --git a/app/src/main/java/org/linphone/ui/call/CallActivity.kt b/app/src/main/java/org/linphone/ui/call/CallActivity.kt index 3dc732406..3333b79c7 100644 --- a/app/src/main/java/org/linphone/ui/call/CallActivity.kt +++ b/app/src/main/java/org/linphone/ui/call/CallActivity.kt @@ -540,10 +540,10 @@ class CallActivity : GenericActivity() { } R.id.callsListFragment -> { if (notInConference) { - Log.i("$TAG Going calls list fragment to active call fragment") + Log.i("$TAG Going from calls list fragment to active call fragment") CallsListFragmentDirections.actionCallsListFragmentToActiveCallFragment() } else { - Log.i("$TAG Going calls list fragment to conference fragment") + Log.i("$TAG Going from calls list fragment to conference fragment") CallsListFragmentDirections.actionCallsListFragmentToActiveConferenceCallFragment() } } diff --git a/app/src/main/java/org/linphone/ui/call/conference/viewmodel/ConferenceViewModel.kt b/app/src/main/java/org/linphone/ui/call/conference/viewmodel/ConferenceViewModel.kt index 0551214a1..008faa874 100644 --- a/app/src/main/java/org/linphone/ui/call/conference/viewmodel/ConferenceViewModel.kt +++ b/app/src/main/java/org/linphone/ui/call/conference/viewmodel/ConferenceViewModel.kt @@ -298,6 +298,7 @@ class ConferenceViewModel @WorkerThread fun destroy() { isCurrentCallInConference.postValue(false) + if (::conference.isInitialized) { conference.removeListener(conferenceListener) participantDevices.value.orEmpty().forEach(ConferenceParticipantDeviceModel::destroy) @@ -307,6 +308,15 @@ class ConferenceViewModel @WorkerThread fun configureFromCall(call: Call) { val conf = call.conference ?: return + val confSubject = conf.subjectUtf8.orEmpty() + Log.i( + "$TAG Configuring conference with subject [$confSubject] from call [${call.callLog.callId}]" + ) + configure(conf) + } + + @WorkerThread + private fun configure(conf: Conference) { if (::conference.isInitialized) { conference.removeListener(conferenceListener) } @@ -314,6 +324,7 @@ class ConferenceViewModel isCurrentCallInConference.postValue(true) conference = conf conference.addListener(conferenceListener) + val core = conference.core val isIn = conference.isIn val state = conf.state @@ -331,9 +342,6 @@ class ConferenceViewModel isConversationAvailable.postValue(chatEnabled) val confSubject = conference.subjectUtf8.orEmpty() - Log.i( - "$TAG Configuring conference with subject [$confSubject] from call [${call.callLog.callId}]" - ) sipUri.postValue(conference.conferenceAddress?.asStringUriOnly()) subject.postValue(confSubject) @@ -345,15 +353,16 @@ class ConferenceViewModel } } - val currentLayout = getCurrentLayout(call) + val call = conf.call + val currentLayout = if (call == null) AUDIO_ONLY_LAYOUT else getCurrentLayout(call) conferenceLayout.postValue(currentLayout) if (currentLayout == GRID_LAYOUT && screenSharing) { Log.w( "$TAG Conference has a participant sharing its screen, changing layout from mosaic to active speaker" ) setNewLayout(ACTIVE_SPEAKER_LAYOUT) - } else if (currentLayout == AUDIO_ONLY_LAYOUT) { - val defaultLayout = call.core.defaultConferenceLayout.toInt() + } else if (call != null && currentLayout == AUDIO_ONLY_LAYOUT) { + val defaultLayout = core.defaultConferenceLayout.toInt() if (defaultLayout == Conference.Layout.ActiveSpeaker.toInt()) { Log.w("$TAG Joined conference in audio only layout, switching to active speaker layout") setNewLayout(ACTIVE_SPEAKER_LAYOUT) diff --git a/app/src/main/java/org/linphone/ui/call/fragment/CallsListFragment.kt b/app/src/main/java/org/linphone/ui/call/fragment/CallsListFragment.kt index 2fd2048ca..980e9c8ce 100644 --- a/app/src/main/java/org/linphone/ui/call/fragment/CallsListFragment.kt +++ b/app/src/main/java/org/linphone/ui/call/fragment/CallsListFragment.kt @@ -169,7 +169,7 @@ class CallsListFragment : GenericCallFragment() { model.confirmEvent.observe(viewLifecycleOwner) { it.consume { - viewModel.mergeCallsIntoConference() + viewModel.mergeCallsIntoConference(callViewModel.conferenceModel) dialog.dismiss() } } diff --git a/app/src/main/java/org/linphone/ui/call/viewmodel/CallsViewModel.kt b/app/src/main/java/org/linphone/ui/call/viewmodel/CallsViewModel.kt index f0480543c..02adea3b8 100644 --- a/app/src/main/java/org/linphone/ui/call/viewmodel/CallsViewModel.kt +++ b/app/src/main/java/org/linphone/ui/call/viewmodel/CallsViewModel.kt @@ -29,6 +29,7 @@ import org.linphone.core.Core import org.linphone.core.CoreListenerStub import org.linphone.core.tools.Log import org.linphone.ui.GenericViewModel +import org.linphone.ui.call.conference.viewmodel.ConferenceViewModel import org.linphone.ui.call.model.CallModel import org.linphone.utils.AppUtils import org.linphone.utils.Event @@ -216,7 +217,7 @@ class CallsViewModel } @UiThread - fun mergeCallsIntoConference() { + fun mergeCallsIntoConference(conferenceModel: ConferenceViewModel) { coreContext.postOnCoreThread { core -> val callsCount = core.callsNb val defaultAccount = LinphoneUtils.getDefaultAccount() @@ -234,6 +235,9 @@ class CallsViewModel showRedToast(R.string.conference_failed_to_merge_calls_into_conference_toast, R.drawable.warning_circle) } else { conference.addParticipants(core.calls) + val firstCall = core.calls.first() + conferenceModel.configureFromCall(firstCall) + goToActiveCallEvent.postValue(Event(false)) } } } diff --git a/app/src/main/java/org/linphone/ui/main/history/viewmodel/HistoryViewModel.kt b/app/src/main/java/org/linphone/ui/main/history/viewmodel/HistoryViewModel.kt index 2da405721..6a9bd2762 100644 --- a/app/src/main/java/org/linphone/ui/main/history/viewmodel/HistoryViewModel.kt +++ b/app/src/main/java/org/linphone/ui/main/history/viewmodel/HistoryViewModel.kt @@ -154,11 +154,11 @@ class HistoryViewModel val model = CallLogModel(callLog) callLogModel.postValue(model) - val conference = callLog.wasConference() - isConferenceCallLog.postValue(conference) + val isConference = callLog.wasConference() + isConferenceCallLog.postValue(isConference) meetingChatRoom = callLog.chatRoom isChatRoomAvailable.postValue(meetingChatRoom != null) - if (conference) { + if (isConference) { Log.i( "$TAG Conference call log, chat room is ${ if (meetingChatRoom != null) "available" else "not available"}" )