Commit 424531ec authored by Christophe Deschamps's avatar Christophe Deschamps
Browse files

Automatically close the app if it was open from a notifcation of incoming call

parent dd013ec3
......@@ -37,6 +37,7 @@ import org.linhome.ui.tabbar.TabbarViewModel
import org.linhome.ui.toolbar.ToobarButtonClickedListener
import org.linhome.ui.toolbar.ToolbarViewModel
import org.linhome.utils.DialogUtil
import org.linphone.core.tools.Log
import permissions.dispatcher.NeedsPermission
import permissions.dispatcher.OnNeverAskAgain
import permissions.dispatcher.OnPermissionDenied
......@@ -297,5 +298,12 @@ class MainActivity : GenericActivity() {
return super.dispatchTouchEvent(event)
}
override fun onResume() {
super.onResume()
if (LinhomeApplication.coreContext.closeAppUponCallFinish) {
LinhomeApplication.coreContext.closeAppUponCallFinish = false
finish()
}
}
}
......@@ -37,6 +37,7 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import org.linhome.LinhomeApplication
import org.linhome.LinhomeApplication.Companion.corePreferences
import org.linhome.MainActivity
import org.linhome.R
import org.linhome.notifications.NotificationsManager
import org.linhome.ui.call.CallInProgressActivity
......@@ -55,6 +56,7 @@ class CoreContext(val context: Context, coreConfig: Config) {
var stopped = false
val core: Core
val handler: Handler = Handler(Looper.getMainLooper())
var closeAppUponCallFinish = false
val appVersion: String by lazy {
"${org.linhome.BuildConfig.VERSION_NAME} / versionCode: ${org.linhome.BuildConfig.VERSION_CODE} (${org.linhome.BuildConfig.BUILD_TYPE})"
......
......@@ -375,6 +375,7 @@ class NotificationsManager(private val context: Context) {
val incomingCallNotificationIntent = Intent(context, CallIncomingActivity::class.java)
incomingCallNotificationIntent.putExtra("callId", call.callLog.callId)
incomingCallNotificationIntent.putExtra("closeAppUponCallFinish",true)
incomingCallNotificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
val pendingIntent = PendingIntent.getActivity(
context,
......
......@@ -25,6 +25,7 @@ import android.view.View
import org.linhome.GenericActivity
import org.linhome.LinhomeApplication.Companion.coreContext
import org.linphone.core.Call
import org.linphone.core.tools.Log
abstract class CallGenericActivity : GenericActivity() {
......@@ -40,9 +41,14 @@ abstract class CallGenericActivity : GenericActivity() {
decorView.systemUiVisibility = uiOptions
call = intent.getStringExtra("callId")?.let { callId ->
if (intent.getBooleanExtra("closeAppUponCallFinish", false)) {
coreContext.closeAppUponCallFinish = true
}
coreContext.core.calls.filter { it.callLog.callId.equals(callId) }.firstOrNull()
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment