Fixed issues related to multi call when one of them is a conference

This commit is contained in:
Sylvain Berfini 2024-05-02 17:37:50 +02:00
parent b880578f99
commit 2b315cd0e4
6 changed files with 66 additions and 21 deletions

View file

@ -412,7 +412,9 @@ class ContactsManager @UiThread constructor() {
if (key == null) {
val fakeFriend = coreContext.core.createFriend()
fakeFriend.name = conferenceInfo.subject
return ContactAvatarModel(fakeFriend)
val model = ContactAvatarModel(fakeFriend)
model.showTrust.postValue(false)
return model
}
val foundInMap = conferenceAvatarMap[key] ?: conferenceAvatarMap[key]

View file

@ -242,6 +242,10 @@ class CallActivity : GenericActivity() {
val action =
ActiveCallFragmentDirections.actionActiveCallFragmentToCallsListFragment()
navController.navigate(action)
} else if (navController.currentDestination?.id == R.id.activeConferenceCallFragment) {
val action =
ActiveConferenceCallFragmentDirections.actionActiveConferenceCallFragmentToCallsListFragment()
navController.navigate(action)
}
}
}

View file

@ -204,6 +204,17 @@ class ActiveConferenceCallFragment : GenericCallFragment() {
}
}
callViewModel.goToCallEvent.observe(viewLifecycleOwner) {
it.consume {
if (findNavController().currentDestination?.id == R.id.activeConferenceCallFragment) {
Log.i("$TAG Going to active call fragment")
val action =
ActiveConferenceCallFragmentDirections.actionActiveConferenceCallFragmentToActiveCallFragment()
findNavController().navigate(action)
}
}
}
binding.setBackClickListener {
requireActivity().finish()
}

View file

@ -207,7 +207,8 @@ class CallsViewModel @UiThread constructor() : ViewModel() {
fun topBarClicked() {
coreContext.postOnCoreThread { core ->
if (core.callsNb == 1) {
goToActiveCallEvent.postValue(Event(core.calls.first().conference == null))
val currentCall = core.currentCall ?: core.calls.first()
goToActiveCallEvent.postValue(Event(currentCall.conference == null))
} else {
goToCallsListEvent.postValue(Event(true))
}
@ -248,12 +249,17 @@ class CallsViewModel @UiThread constructor() : ViewModel() {
}
callsTopBarIcon.postValue(R.drawable.phone_pause)
if (found != null) {
val contact = coreContext.contactsManager.findContactByAddress(
found.remoteAddress
)
callsTopBarLabel.postValue(
contact?.name ?: LinphoneUtils.getDisplayName(found.remoteAddress)
)
val conference = found.conference
if (conference != null) {
callsTopBarLabel.postValue(conference.subject)
} else {
val contact = coreContext.contactsManager.findContactByAddress(
found.remoteAddress
)
callsTopBarLabel.postValue(
contact?.name ?: LinphoneUtils.getDisplayName(found.remoteAddress)
)
}
callsTopBarStatus.postValue(LinphoneUtils.callStateToString(found.state))
} else {
Log.e("$TAG Failed to find a paused call")
@ -272,12 +278,17 @@ class CallsViewModel @UiThread constructor() : ViewModel() {
callsTopBarIcon.postValue(R.drawable.phone)
val call = core.calls.first()
val contact = coreContext.contactsManager.findContactByAddress(
call.remoteAddress
)
callsTopBarLabel.postValue(
contact?.name ?: LinphoneUtils.getDisplayName(call.remoteAddress)
)
val conference = call.conference
if (conference != null) {
callsTopBarLabel.postValue(conference.subject)
} else {
val contact = coreContext.contactsManager.findContactByAddress(
call.remoteAddress
)
callsTopBarLabel.postValue(
contact?.name ?: LinphoneUtils.getDisplayName(call.remoteAddress)
)
}
callsTopBarStatus.postValue(LinphoneUtils.callStateToString(call.state))
}

View file

@ -185,6 +185,10 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
MutableLiveData<Event<Boolean>>()
}
val goToCallEvent: MutableLiveData<Event<Boolean>> by lazy {
MutableLiveData<Event<Boolean>>()
}
// Extras actions
val toggleExtraActionsBottomSheetEvent: MutableLiveData<Event<Boolean>> by lazy {
@ -297,7 +301,9 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
if (call.state == Call.State.Connected) {
if (call.conference != null) {
Log.i("$TAG Call is in Connected state and conference isn't null")
Log.i(
"$TAG Call is in Connected state and conference isn't null, going to conference fragment"
)
conferenceModel.configureFromCall(call)
goToConferenceEvent.postValue(Event(true))
} else {
@ -357,7 +363,7 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
if (::currentCall.isInitialized) {
if (call != currentCall) {
if (call == currentCall.core.currentCall) {
if (call == core.currentCall && state != Call.State.Pausing) {
Log.w(
"$TAG Current call has changed, now is [${call.remoteAddress.asStringUriOnly()}] with state [$state]"
)
@ -451,10 +457,15 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
@UiThread
fun answer() {
coreContext.postOnCoreThread {
if (::currentCall.isInitialized) {
Log.i("$TAG Answering call [$currentCall]")
coreContext.answerCall(currentCall)
coreContext.postOnCoreThread { core ->
val call = core.calls.find {
LinphoneUtils.isCallIncoming(it.state)
}
if (call != null) {
Log.i("$TAG Answering call [${call.remoteAddress.asStringUriOnly()}]")
coreContext.answerCall(call)
} else {
Log.e("$TAG No call found in incoming state, can't answer any!")
}
}
}
@ -950,7 +961,9 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
@WorkerThread
private fun configureCall(call: Call) {
Log.i("$TAG Configuring call [$call] as current")
Log.i(
"$TAG Configuring call with remote address [${call.remoteAddress.asStringUriOnly()}] as current"
)
contact.value?.destroy()
terminatedByUsed = false
@ -966,10 +979,13 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
call.callLog.conferenceInfo
}
if (call.conference != null || conferenceInfo != null) {
val subject = call.conference?.subject ?: conferenceInfo?.subject
Log.i("$TAG Conference [$subject] found, going to conference fragment")
conferenceModel.configureFromCall(call)
goToConferenceEvent.postValue(Event(true))
} else {
conferenceModel.destroy()
goToCallEvent.postValue(Event(true))
}
if (call.dir == Call.Dir.Incoming) {

View file

@ -447,6 +447,7 @@ class LinphoneUtils {
val avatarModel = ContactAvatarModel(fakeFriend)
avatarModel.defaultToConferenceIcon.postValue(true)
avatarModel.skipInitials.postValue(true)
avatarModel.showTrust.postValue(false)
return avatarModel
}