Shorten durating for call ended screen if terminate call action was made by user

This commit is contained in:
Sylvain Berfini 2024-01-15 10:42:25 +01:00
parent 715375831a
commit 6f623ae080
2 changed files with 17 additions and 3 deletions

View file

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

View file

@ -105,6 +105,8 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
MutableLiveData<String>()
}
var terminatedByUsed = false
val isRemoteRecordingEvent: MutableLiveData<Event<Pair<Boolean, String>>> by lazy {
MutableLiveData<Event<Pair<Boolean, String>>>()
}
@ -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)