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 606d5a9a6..6c7cd38c8 100644
--- a/app/src/main/java/org/linphone/ui/call/CallActivity.kt
+++ b/app/src/main/java/org/linphone/ui/call/CallActivity.kt
@@ -162,6 +162,13 @@ class CallActivity : AppCompatActivity() {
}
}
+ callViewModel.goTEndedCallEvent.observe(this) {
+ it.consume {
+ val action = ActiveCallFragmentDirections.actionGlobalEndedCallFragment()
+ findNavController(R.id.call_nav_container).navigate(action)
+ }
+ }
+
callsViewModel.showIncomingCallEvent.observe(this) {
it.consume {
val action = IncomingCallFragmentDirections.actionGlobalIncomingCallFragment()
@@ -194,7 +201,7 @@ class CallActivity : AppCompatActivity() {
}
}
- callsViewModel.noMoreCallEvent.observe(this) {
+ callsViewModel.noCallFoundEvent.observe(this) {
it.consume {
finish()
}
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
new file mode 100644
index 000000000..85d55bc9f
--- /dev/null
+++ b/app/src/main/java/org/linphone/ui/call/fragment/EndedCallFragment.kt
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2010-2023 Belledonne Communications SARL.
+ *
+ * This file is part of linphone-android
+ * (see https://www.linphone.org).
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package org.linphone.ui.call.fragment
+
+import android.os.Bundle
+import android.os.SystemClock
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.annotation.UiThread
+import androidx.lifecycle.ViewModelProvider
+import androidx.lifecycle.lifecycleScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.delay
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
+import org.linphone.core.tools.Log
+import org.linphone.databinding.CallEndedFragmentBinding
+import org.linphone.ui.call.viewmodel.CurrentCallViewModel
+
+@UiThread
+class EndedCallFragment : GenericCallFragment() {
+ companion object {
+ private const val TAG = "[Ended Call Fragment]"
+ }
+
+ private lateinit var binding: CallEndedFragmentBinding
+
+ private lateinit var callViewModel: CurrentCallViewModel
+
+ override fun onCreateView(
+ inflater: LayoutInflater,
+ container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View {
+ binding = CallEndedFragmentBinding.inflate(layoutInflater)
+ return binding.root
+ }
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+
+ callViewModel = requireActivity().run {
+ ViewModelProvider(this)[CurrentCallViewModel::class.java]
+ }
+
+ binding.lifecycleOwner = viewLifecycleOwner
+ binding.viewModel = callViewModel
+
+ Log.i("$TAG Showing ended call fragment")
+
+ callViewModel.callDuration.observe(viewLifecycleOwner) { duration ->
+ binding.chronometer.base = SystemClock.elapsedRealtime() - (1000 * duration)
+ // Do not start it!
+ }
+ }
+
+ override fun onResume() {
+ super.onResume()
+
+ lifecycleScope.launch {
+ withContext(Dispatchers.IO) {
+ Log.i("$TAG 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/CallsViewModel.kt b/app/src/main/java/org/linphone/ui/call/viewmodel/CallsViewModel.kt
index f54390d8b..d5c41ee92 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
@@ -47,15 +47,9 @@ class CallsViewModel @UiThread constructor() : ViewModel() {
val showOutgoingCallEvent = MutableLiveData>()
- val noMoreCallEvent = MutableLiveData>()
+ val noCallFoundEvent = MutableLiveData>()
private val coreListener = object : CoreListenerStub() {
- @WorkerThread
- override fun onLastCallEnded(core: Core) {
- Log.i("$TAG No more call, leaving Call activity")
- noMoreCallEvent.postValue(Event(true))
- }
-
@WorkerThread
override fun onCallStateChanged(
core: Core,
@@ -158,7 +152,7 @@ class CallsViewModel @UiThread constructor() : ViewModel() {
}
} else {
Log.w("$TAG No call found, leaving Call activity")
- noMoreCallEvent.postValue(Event(true))
+ noCallFoundEvent.postValue(Event(true))
}
}
}
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 1dfcaa678..d14b4a14f 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
@@ -102,6 +102,10 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
MutableLiveData()
}
+ val goTEndedCallEvent: MutableLiveData> by lazy {
+ MutableLiveData>()
+ }
+
// To synchronize chronometers in UI
val callDuration = MutableLiveData()
@@ -194,8 +198,16 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
)
configureCall(newCurrentCall)
} else {
- Log.e("$TAG Failed to get a valid call to display!")
+ Log.e(
+ "$TAG Failed to get a valid call to display, go to ended call fragment"
+ )
+ goTEndedCallEvent.postValue(Event(true))
}
+ } else {
+ Log.i("$TAG Call is ending, go to ended call fragment")
+ // Show that call was ended for a few seconds, then leave
+ // TODO FIXME: do not show it when call is being ended due to user terminating the call
+ goTEndedCallEvent.postValue(Event(true))
}
} else {
val videoEnabled = call.currentParams.isVideoEnabled
diff --git a/app/src/main/res/layout/call_ended_actions.xml b/app/src/main/res/layout/call_ended_actions.xml
new file mode 100644
index 000000000..7bf458c71
--- /dev/null
+++ b/app/src/main/res/layout/call_ended_actions.xml
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/call_ended_fragment.xml b/app/src/main/res/layout/call_ended_fragment.xml
new file mode 100644
index 000000000..e37c3ae84
--- /dev/null
+++ b/app/src/main/res/layout/call_ended_fragment.xml
@@ -0,0 +1,128 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/navigation/call_nav_graph.xml b/app/src/main/res/navigation/call_nav_graph.xml
index c59eb68bd..3478a670f 100644
--- a/app/src/main/res/navigation/call_nav_graph.xml
+++ b/app/src/main/res/navigation/call_nav_graph.xml
@@ -94,4 +94,14 @@
android:label="CallsListFragment"
tools:layout="@layout/calls_list_fragment" />
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 63351d09d..b3d2f8aa4 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -291,6 +291,7 @@
Outgoing call
Incoming call
+ Call ended
Incoming call for %s
Operation in progress, please wait
diff --git a/build.gradle b/build.gradle
index 7a2a5267d..21f8430a2 100644
--- a/build.gradle
+++ b/build.gradle
@@ -9,8 +9,8 @@ buildscript {
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
- id 'com.android.application' version '8.1.1' apply false
- id 'com.android.library' version '8.1.1' apply false
+ id 'com.android.application' version '8.1.2' apply false
+ id 'com.android.library' version '8.1.2' apply false
id 'org.jetbrains.kotlin.android' version '1.9.0-RC' apply false
id 'com.google.gms.google-services' version '4.3.15' apply false
}
\ No newline at end of file