Fixed white screen when starting the app sometimes + conversations list fragment stacked twice when opening app from chat notification

This commit is contained in:
Sylvain Berfini 2024-01-24 14:25:35 +01:00
parent d2dc99d7a1
commit 51c6037f3f
2 changed files with 17 additions and 9 deletions

View file

@ -39,6 +39,7 @@ import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.app.Person
import androidx.core.app.RemoteInput
import androidx.core.app.TaskStackBuilder
import androidx.core.content.LocusIdCompat
import androidx.navigation.NavDeepLinkBuilder
import org.linphone.LinphoneApplication.Companion.coreContext
@ -1205,12 +1206,19 @@ class NotificationsManager @MainThread constructor(private val context: Context)
args.putString("RemoteSipUri", chatRoom.peerAddress.asStringUriOnly())
args.putString("LocalSipUri", chatRoom.localAddress.asStringUriOnly())
return NavDeepLinkBuilder(context)
.setComponentName(MainActivity::class.java)
.setGraph(R.navigation.main_nav_graph)
.setDestination(R.id.conversationsListFragment)
.setArguments(args)
.createPendingIntent()
// Not using NavDeepLinkBuilder to prevent stacking a ConversationsListFragment above another one
return TaskStackBuilder.create(context).run {
addNextIntentWithParentStack(
Intent(context, MainActivity::class.java).apply {
putExtras(args) // Need to pass args here for Chat extra
}
)
getPendingIntent(
0,
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
args // Need to pass args here too for Remote & Local SIP URIs
)!!
}
}
class Notifiable(val notificationId: Int) {

View file

@ -359,9 +359,6 @@ class MainActivity : GenericActivity() {
)
when (intent.action) {
Intent.ACTION_MAIN -> {
handleMainIntent(intent, defaultDestination, isNewIntent)
}
Intent.ACTION_SEND -> {
handleSendIntent(intent, false)
}
@ -371,6 +368,9 @@ class MainActivity : GenericActivity() {
Intent.ACTION_VIEW, Intent.ACTION_DIAL, Intent.ACTION_CALL -> {
handleCallIntent(intent)
}
else -> {
handleMainIntent(intent, defaultDestination, isNewIntent)
}
}
}