diff options
author | Guillaume Jacquart <guillaume.jacquart@hoodbrains.com> | 2023-06-09 06:34:10 +0000 |
---|---|---|
committer | Guillaume Jacquart <guillaume.jacquart@hoodbrains.com> | 2023-06-09 06:34:10 +0000 |
commit | 8b1855bce1313ad84df8f96efdbb62e2acf7ff33 (patch) | |
tree | 94e19efed58b931139a86c7c9c8aced91767e6c3 /app/src/main/java/foundation/e/advancedprivacy/Notifications.kt | |
parent | 333623483246398c76bed4aa5ee5b43c843f65cd (diff) | |
parent | 74b9860784913c097ae59e58b0958da7744ebc2e (diff) | |
download | advanced-privacy-8b1855bce1313ad84df8f96efdbb62e2acf7ff33.tar.gz |
Merge branch '1227-navigation_graph' into 'main'
1227: use navigation graph component, avoid view (fragments) duplications
See merge request e/os/advanced-privacy!136
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 } |