From 2ef82f1b827eeca512c7f05badbc2f13ef3cf3ae Mon Sep 17 00:00:00 2001 From: ganfra Date: Thu, 2 Jul 2020 16:05:05 +0200 Subject: [PATCH 1/2] Use HomeActivity.newIntent to make sure we have args --- .../features/notifications/NotificationUtils.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/notifications/NotificationUtils.kt b/vector/src/main/java/im/vector/riotx/features/notifications/NotificationUtils.kt index d7dabd0778..36874d5782 100755 --- a/vector/src/main/java/im/vector/riotx/features/notifications/NotificationUtils.kt +++ b/vector/src/main/java/im/vector/riotx/features/notifications/NotificationUtils.kt @@ -205,7 +205,7 @@ class NotificationUtils @Inject constructor(private val context: Context, @SuppressLint("NewApi") fun buildForegroundServiceNotification(@StringRes subTitleResId: Int, withProgress: Boolean = true): Notification { // build the pending intent go to the home screen if this is clicked. - val i = Intent(context, HomeActivity::class.java) + val i = HomeActivity.newIntent(context) i.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP val pi = PendingIntent.getActivity(context, 0, i, 0) @@ -307,7 +307,7 @@ class NotificationUtils @Inject constructor(private val context: Context, val contentPendingIntent = PendingIntent.getActivity(context, System.currentTimeMillis().toInt(), contentIntent, 0) val answerCallPendingIntent = TaskStackBuilder.create(context) - .addNextIntentWithParentStack(Intent(context, HomeActivity::class.java)) + .addNextIntentWithParentStack(HomeActivity.newIntent(context)) .addNextIntent(VectorCallActivity.newIntent( context = context, callId = callId, @@ -459,7 +459,7 @@ class NotificationUtils @Inject constructor(private val context: Context, ) val contentPendingIntent = TaskStackBuilder.create(context) - .addNextIntentWithParentStack(Intent(context, HomeActivity::class.java)) + .addNextIntentWithParentStack(HomeActivity.newIntent(context)) // TODO other userId .addNextIntent(VectorCallActivity.newIntent(context, callId, roomId, "otherUserId", true, isVideo, null)) .getPendingIntent(System.currentTimeMillis().toInt(), PendingIntent.FLAG_UPDATE_CURRENT) @@ -651,7 +651,7 @@ class NotificationUtils @Inject constructor(private val context: Context, stringProvider.getString(R.string.join), joinIntentPendingIntent) - val contentIntent = Intent(context, HomeActivity::class.java) + val contentIntent = HomeActivity.newIntent(context) contentIntent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP // pending intent get reused by system, this will mess up the extra params, so put unique info to avoid that contentIntent.data = Uri.parse("foobar://" + inviteNotifiableEvent.eventId) @@ -689,7 +689,7 @@ class NotificationUtils @Inject constructor(private val context: Context, .setColor(accentColor) .setAutoCancel(true) .apply { - val contentIntent = Intent(context, HomeActivity::class.java) + val contentIntent = HomeActivity.newIntent(context) contentIntent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP // pending intent get reused by system, this will mess up the extra params, so put unique info to avoid that contentIntent.data = Uri.parse("foobar://" + simpleNotifiableEvent.eventId) @@ -718,7 +718,7 @@ class NotificationUtils @Inject constructor(private val context: Context, // Recreate the back stack return TaskStackBuilder.create(context) - .addNextIntentWithParentStack(Intent(context, HomeActivity::class.java)) + .addNextIntentWithParentStack(HomeActivity.newIntent(context)) .addNextIntent(roomIntentTap) .getPendingIntent(System.currentTimeMillis().toInt(), PendingIntent.FLAG_UPDATE_CURRENT) } From 5008bfd6a9c7daf42196ec15749fd4b01e99954d Mon Sep 17 00:00:00 2001 From: ganfra Date: Thu, 2 Jul 2020 16:17:00 +0200 Subject: [PATCH 2/2] Update CHANGES --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 4a7d0d70af..519a42db4e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,7 +8,7 @@ Improvements 🙌: - Bugfix 🐛: - - + - Fix crash when coming from a notification (#1601) Translations 🗣: -