From 6f623ae08092c2ff989a151d9a1daa650db79632 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 15 Jan 2024 10:42:25 +0100 Subject: [PATCH] Shorten durating for call ended screen if terminate call action was made by user --- .../ui/call/fragment/EndedCallFragment.kt | 16 +++++++++++++--- .../ui/call/viewmodel/CurrentCallViewModel.kt | 4 ++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/linphone/ui/call/fragment/EndedCallFragment.kt b/app/src/main/java/org/linphone/ui/call/fragment/EndedCallFragment.kt index c78944577..43bf6df53 100644 --- a/app/src/main/java/org/linphone/ui/call/fragment/EndedCallFragment.kt +++ b/app/src/main/java/org/linphone/ui/call/fragment/EndedCallFragment.kt @@ -72,7 +72,7 @@ class EndedCallFragment : GenericCallFragment() { callViewModel.callDuration.observe(viewLifecycleOwner) { duration -> binding.chronometer.base = SystemClock.elapsedRealtime() - (1000 * duration) - // Do not start it! + binding.chronometer.stop() // Do not start it and make sure it is stopped } } @@ -81,8 +81,18 @@ class EndedCallFragment : GenericCallFragment() { lifecycleScope.launch { withContext(Dispatchers.IO) { - Log.i("$TAG Waiting 2 seconds before finishing activity") - delay(2000) + if (callViewModel.terminatedByUsed) { + Log.i( + "$TAG Call terminated by user, waiting 1 second before finishing activity" + ) + delay(1000) + } else { + Log.i( + "$TAG Call terminated by remote end, waiting 2 seconds before finishing activity" + ) + delay(2000) + } + withContext(Dispatchers.Main) { Log.i("$TAG Finishing activity") requireActivity().finish() 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 d4f29d1a1..c8d632b36 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 @@ -105,6 +105,8 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() { MutableLiveData() } + var terminatedByUsed = false + val isRemoteRecordingEvent: MutableLiveData>> by lazy { MutableLiveData>>() } @@ -469,6 +471,7 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() { coreContext.postOnCoreThread { if (::currentCall.isInitialized) { Log.i("$TAG Terminating call [${currentCall.remoteAddress.asStringUriOnly()}]") + terminatedByUsed = true currentCall.terminate() } } @@ -805,6 +808,7 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() { Log.i("$TAG Configuring call [$call] as current") contact.value?.destroy() + terminatedByUsed = false currentCall = call call.addListener(callListener)