diff --git a/app/src/main/java/org/linphone/contacts/ContactsManager.kt b/app/src/main/java/org/linphone/contacts/ContactsManager.kt index b188f5bbb..c914be7c9 100644 --- a/app/src/main/java/org/linphone/contacts/ContactsManager.kt +++ b/app/src/main/java/org/linphone/contacts/ContactsManager.kt @@ -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] 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 e6e193f75..fc0020f10 100644 --- a/app/src/main/java/org/linphone/ui/call/CallActivity.kt +++ b/app/src/main/java/org/linphone/ui/call/CallActivity.kt @@ -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) } } } diff --git a/app/src/main/java/org/linphone/ui/call/conference/fragment/ActiveConferenceCallFragment.kt b/app/src/main/java/org/linphone/ui/call/conference/fragment/ActiveConferenceCallFragment.kt index 1ea9328cd..624ad1aae 100644 --- a/app/src/main/java/org/linphone/ui/call/conference/fragment/ActiveConferenceCallFragment.kt +++ b/app/src/main/java/org/linphone/ui/call/conference/fragment/ActiveConferenceCallFragment.kt @@ -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() } 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 460959c73..58256ab67 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 @@ -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)) } diff --git a/app/src/main/java/org/linphone/ui/call/viewmodel/CurrentCallViewModel.kt b/app/src/main/java/org/linphone/ui/call/viewmodel/CurrentCallViewModel.kt index 5364f1c3a..cc7c70309 100644 --- a/app/src/main/java/org/linphone/ui/call/viewmodel/CurrentCallViewModel.kt +++ b/app/src/main/java/org/linphone/ui/call/viewmodel/CurrentCallViewModel.kt @@ -185,6 +185,10 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() { MutableLiveData>() } + val goToCallEvent: MutableLiveData> by lazy { + MutableLiveData>() + } + // Extras actions val toggleExtraActionsBottomSheetEvent: MutableLiveData> 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) { diff --git a/app/src/main/java/org/linphone/utils/LinphoneUtils.kt b/app/src/main/java/org/linphone/utils/LinphoneUtils.kt index a18393d44..a9501f129 100644 --- a/app/src/main/java/org/linphone/utils/LinphoneUtils.kt +++ b/app/src/main/java/org/linphone/utils/LinphoneUtils.kt @@ -447,6 +447,7 @@ class LinphoneUtils { val avatarModel = ContactAvatarModel(fakeFriend) avatarModel.defaultToConferenceIcon.postValue(true) avatarModel.skipInitials.postValue(true) + avatarModel.showTrust.postValue(false) return avatarModel }