diff --git a/app/src/main/java/org/linphone/notifications/NotificationsManager.kt b/app/src/main/java/org/linphone/notifications/NotificationsManager.kt index bedf07b11..07613f337 100644 --- a/app/src/main/java/org/linphone/notifications/NotificationsManager.kt +++ b/app/src/main/java/org/linphone/notifications/NotificationsManager.kt @@ -393,6 +393,12 @@ class NotificationsManager @MainThread constructor(private val context: Context) val callNotificationIntent = Intent(context, CallActivity::class.java) callNotificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + if (isIncoming) { + callNotificationIntent.putExtra("IncomingCall", true) + } else { + callNotificationIntent.putExtra("ActiveCall", true) + } + val pendingIntent = PendingIntent.getActivity( context, 0, @@ -866,6 +872,7 @@ class NotificationsManager @MainThread constructor(private val context: Context) setWhen(System.currentTimeMillis()) setAutoCancel(false) setOngoing(true) + setContentIntent(pendingIntent) setFullScreenIntent(pendingIntent, true) } 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 cd0f75555..f24dfd247 100644 --- a/app/src/main/java/org/linphone/ui/call/CallActivity.kt +++ b/app/src/main/java/org/linphone/ui/call/CallActivity.kt @@ -21,6 +21,7 @@ package org.linphone.ui.call import android.Manifest import android.app.PictureInPictureParams +import android.content.Intent import android.content.pm.PackageManager import android.os.Bundle import android.view.ViewGroup @@ -232,52 +233,7 @@ class CallActivity : GenericActivity() { callsViewModel.goToActiveCallEvent.observe(this) { it.consume { singleCall -> - val navController = findNavController(R.id.call_nav_container) - val action = when (navController.currentDestination?.id) { - R.id.outgoingCallFragment -> { - if (singleCall) { - Log.i("$TAG Going from outgoing call fragment to call fragment") - OutgoingCallFragmentDirections.actionOutgoingCallFragmentToActiveCallFragment() - } else { - Log.i( - "$TAG Going from outgoing call fragment to conference call fragment" - ) - OutgoingCallFragmentDirections.actionOutgoingCallFragmentToActiveConferenceCallFragment() - } - } - R.id.incomingCallFragment -> { - if (singleCall) { - Log.i("$TAG Going from incoming call fragment to call fragment") - IncomingCallFragmentDirections.actionIncomingCallFragmentToActiveCallFragment() - } else { - Log.i( - "$TAG Going from incoming call fragment to conference call fragment" - ) - IncomingCallFragmentDirections.actionIncomingCallFragmentToActiveConferenceCallFragment() - } - } - R.id.activeConferenceCallFragment -> { - if (singleCall) { - Log.i("$TAG Going from conference call fragment to call fragment") - ActiveConferenceCallFragmentDirections.actionActiveConferenceCallFragmentToActiveCallFragment() - } else { - Log.i( - "$TAG Going from conference call fragment to conference call fragment" - ) - ActiveConferenceCallFragmentDirections.actionGlobalActiveConferenceCallFragment() - } - } - else -> { - if (singleCall) { - Log.i("$TAG Going from call fragment to call fragment") - ActiveCallFragmentDirections.actionGlobalActiveCallFragment() - } else { - Log.i("$TAG Going from call fragment to conference call fragment") - ActiveCallFragmentDirections.actionActiveCallFragmentToActiveConferenceCallFragment() - } - } - } - navController.navigate(action) + navigateToActiveCall(singleCall) } } @@ -333,6 +289,19 @@ class CallActivity : GenericActivity() { } } + override fun onNewIntent(intent: Intent?) { + super.onNewIntent(intent) + + if (intent?.extras?.getBoolean("ActiveCall", false) == true) { + navigateToActiveCall( + callViewModel.conferenceModel.isCurrentCallInConference.value == false + ) + } else if (intent?.extras?.getBoolean("IncomingCall", false) == true) { + val action = IncomingCallFragmentDirections.actionGlobalIncomingCallFragment() + findNavController(R.id.call_nav_container).navigate(action) + } + } + override fun onUserLeaveHint() { super.onUserLeaveHint() @@ -446,6 +415,55 @@ class CallActivity : GenericActivity() { ) } + private fun navigateToActiveCall(notInConference: Boolean) { + val navController = findNavController(R.id.call_nav_container) + val action = when (navController.currentDestination?.id) { + R.id.outgoingCallFragment -> { + if (notInConference) { + Log.i("$TAG Going from outgoing call fragment to call fragment") + OutgoingCallFragmentDirections.actionOutgoingCallFragmentToActiveCallFragment() + } else { + Log.i( + "$TAG Going from outgoing call fragment to conference call fragment" + ) + OutgoingCallFragmentDirections.actionOutgoingCallFragmentToActiveConferenceCallFragment() + } + } + R.id.incomingCallFragment -> { + if (notInConference) { + Log.i("$TAG Going from incoming call fragment to call fragment") + IncomingCallFragmentDirections.actionIncomingCallFragmentToActiveCallFragment() + } else { + Log.i( + "$TAG Going from incoming call fragment to conference call fragment" + ) + IncomingCallFragmentDirections.actionIncomingCallFragmentToActiveConferenceCallFragment() + } + } + R.id.activeConferenceCallFragment -> { + if (notInConference) { + Log.i("$TAG Going from conference call fragment to call fragment") + ActiveConferenceCallFragmentDirections.actionActiveConferenceCallFragmentToActiveCallFragment() + } else { + Log.i( + "$TAG Going from conference call fragment to conference call fragment" + ) + ActiveConferenceCallFragmentDirections.actionGlobalActiveConferenceCallFragment() + } + } + else -> { + if (notInConference) { + Log.i("$TAG Going from call fragment to call fragment") + ActiveCallFragmentDirections.actionGlobalActiveCallFragment() + } else { + Log.i("$TAG Going from call fragment to conference call fragment") + ActiveCallFragmentDirections.actionActiveCallFragmentToActiveConferenceCallFragment() + } + } + } + navController.navigate(action) + } + private fun hideUI(hide: Boolean) { Log.i("$TAG Switching full screen mode to ${if (hide) "ON" else "OFF"}") val windowInsetsCompat = WindowInsetsControllerCompat(window, window.decorView)