From af6cfdfc18c7ce2fd3f13026defafb75445837c3 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 24 Jun 2024 14:44:09 +0200 Subject: [PATCH] Leave start call fragment after successful call && updated name group call / conversation dialog to stay at top of screen --- .../ui/main/history/fragment/StartCallFragment.kt | 8 ++++++++ .../ui/main/history/viewmodel/StartCallViewModel.kt | 6 ++++++ .../main/res/layout/dialog_set_or_edit_group_subject.xml | 9 ++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/linphone/ui/main/history/fragment/StartCallFragment.kt b/app/src/main/java/org/linphone/ui/main/history/fragment/StartCallFragment.kt index 8f964e234..f1f3365ba 100644 --- a/app/src/main/java/org/linphone/ui/main/history/fragment/StartCallFragment.kt +++ b/app/src/main/java/org/linphone/ui/main/history/fragment/StartCallFragment.kt @@ -39,6 +39,7 @@ import org.linphone.ui.main.fragment.GenericAddressPickerFragment import org.linphone.ui.main.fragment.GroupSetOrEditSubjectDialogModel import org.linphone.ui.main.history.viewmodel.StartCallViewModel import org.linphone.utils.DialogUtils +import org.linphone.utils.Event import org.linphone.utils.addCharacterAtPosition import org.linphone.utils.hideKeyboard import org.linphone.utils.removeCharacterAtPosition @@ -104,6 +105,12 @@ class StartCallFragment : GenericAddressPickerFragment() { } } + viewModel.leaveFragmentEvent.observe(viewLifecycleOwner) { + it.consume { + goBack() + } + } + viewModel.removedCharacterAtCurrentPositionEvent.observe(viewLifecycleOwner) { it.consume { binding.searchBar.removeCharacterAtPosition() @@ -159,6 +166,7 @@ class StartCallFragment : GenericAddressPickerFragment() { @WorkerThread override fun onSingleAddressSelected(address: Address, friend: Friend) { coreContext.startAudioCall(address) + viewModel.leaveFragmentEvent.postValue(Event(true)) } override fun onPause() { diff --git a/app/src/main/java/org/linphone/ui/main/history/viewmodel/StartCallViewModel.kt b/app/src/main/java/org/linphone/ui/main/history/viewmodel/StartCallViewModel.kt index 88954c472..6bb87f30d 100644 --- a/app/src/main/java/org/linphone/ui/main/history/viewmodel/StartCallViewModel.kt +++ b/app/src/main/java/org/linphone/ui/main/history/viewmodel/StartCallViewModel.kt @@ -74,6 +74,10 @@ class StartCallViewModel @UiThread constructor() : AddressSelectionViewModel() { MutableLiveData>() } + val leaveFragmentEvent: MutableLiveData> by lazy { + MutableLiveData>() + } + private val conferenceSchedulerListener = object : ConferenceSchedulerListenerStub() { override fun onStateChanged( conferenceScheduler: ConferenceScheduler, @@ -89,6 +93,7 @@ class StartCallViewModel @UiThread constructor() : AddressSelectionViewModel() { "$TAG Conference info created, address is ${conferenceAddress.asStringUriOnly()}" ) coreContext.startVideoCall(conferenceAddress) + leaveFragmentEvent.postValue(Event(true)) } else { Log.e("$TAG Conference info URI is null!") showRedToastEvent.postValue( @@ -142,6 +147,7 @@ class StartCallViewModel @UiThread constructor() : AddressSelectionViewModel() { if (address != null) { Log.i("$TAG Calling [${address.asStringUriOnly()}]") coreContext.startAudioCall(address) + leaveFragmentEvent.postValue(Event(true)) } else { Log.e("$TAG Failed to parse [$suggestion] as SIP address") } diff --git a/app/src/main/res/layout/dialog_set_or_edit_group_subject.xml b/app/src/main/res/layout/dialog_set_or_edit_group_subject.xml index 74385ad3c..f868a71a0 100644 --- a/app/src/main/res/layout/dialog_set_or_edit_group_subject.xml +++ b/app/src/main/res/layout/dialog_set_or_edit_group_subject.xml @@ -16,6 +16,13 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + + + app:layout_constraintBottom_toBottomOf="@id/half_screen"/>