diff options
Diffstat (limited to 'app/src/main/java/foundation/e/advancedprivacy/Notifications.kt')
-rw-r--r-- | app/src/main/java/foundation/e/advancedprivacy/Notifications.kt | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/app/src/main/java/foundation/e/advancedprivacy/Notifications.kt b/app/src/main/java/foundation/e/advancedprivacy/Notifications.kt index 68c4bd3..291f9bc 100644 --- a/app/src/main/java/foundation/e/advancedprivacy/Notifications.kt +++ b/app/src/main/java/foundation/e/advancedprivacy/Notifications.kt @@ -1,4 +1,5 @@ /* + * Copyright (C) 2023 MURENA SAS * Copyright (C) 2022 MURENA SAS * * This program is free software: you can redistribute it and/or modify @@ -21,7 +22,6 @@ import android.app.NotificationChannel import android.app.NotificationManager import android.app.PendingIntent import android.content.Context -import android.content.Intent import androidx.annotation.StringRes import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat @@ -54,8 +54,9 @@ object Notifications { icon = R.drawable.ic_notification_logo, title = R.string.first_notification_title, description = R.string.first_notification_summary, - destinationIntent = - context.packageManager.getLaunchIntentForPackage(context.packageName) + pendingIntent = MainActivity.deepLinkBuilder(context) + .setDestination(R.id.dashboardFragment) + .createPendingIntent() ) ) .setAutoCancel(true) @@ -140,7 +141,9 @@ object Notifications { icon = R.drawable.ic_fmd_bad, title = R.string.notifications_fake_location_title, description = R.string.notifications_fake_location_content, - destinationIntent = MainActivity.createFakeLocationIntent(context), + pendingIntent = MainActivity.deepLinkBuilder(context) + .addDestination(R.id.fakeLocationFragment) + .createPendingIntent() ) ) MainFeatures.IP_SCRAMBLING -> showFlagNotification( @@ -151,7 +154,9 @@ object Notifications { icon = R.drawable.ic_language, title = R.string.notifications_ipscrambling_title, description = R.string.notifications_ipscrambling_content, - destinationIntent = MainActivity.createIpScramblingIntent(context), + pendingIntent = MainActivity.deepLinkBuilder(context) + .addDestination(R.id.internetPrivacyFragment) + .createPendingIntent() ) ) else -> {} @@ -184,7 +189,7 @@ object Notifications { val icon: Int, val title: Int, val description: Int, - val destinationIntent: Intent? + val pendingIntent: PendingIntent? ) private fun notificationBuilder( @@ -196,14 +201,7 @@ object Notifications { .setPriority(NotificationCompat.PRIORITY_LOW) .setContentTitle(context.getString(content.title)) .setStyle(NotificationCompat.BigTextStyle().bigText(context.getString(content.description))) - - content.destinationIntent?.let { - it.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK - val pendingIntent: PendingIntent = PendingIntent.getActivity( - context, 0, it, PendingIntent.FLAG_IMMUTABLE - ) - builder.setContentIntent(pendingIntent) - } + content.pendingIntent?.let { builder.setContentIntent(it) } return builder } |