Fixed UI not updated when merging calls into a local conference

This commit is contained in:
Sylvain Berfini 2026-01-22 17:51:47 +01:00
parent 29343f8887
commit ae818507aa
6 changed files with 26 additions and 14 deletions

1
.idea/misc.xml generated
View file

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">

View file

@ -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()
}
}

View file

@ -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)

View file

@ -169,7 +169,7 @@ class CallsListFragment : GenericCallFragment() {
model.confirmEvent.observe(viewLifecycleOwner) {
it.consume {
viewModel.mergeCallsIntoConference()
viewModel.mergeCallsIntoConference(callViewModel.conferenceModel)
dialog.dismiss()
}
}

View file

@ -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))
}
}
}

View file

@ -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"}"
)