Fixed click on call notification not opening in-call activity

This commit is contained in:
Sylvain Berfini 2024-01-16 17:27:22 +01:00
parent 1d122abb17
commit 43d5e8ff23
2 changed files with 71 additions and 46 deletions

View file

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

View file

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