From 77aaa15082f82b6f4d2d102b9ee873b9cb7ddb97 Mon Sep 17 00:00:00 2001 From: TobiGr Date: Mon, 25 Oct 2021 13:59:49 +0200 Subject: [PATCH] Fix toggling the system's settings for app notification Do not open the setting for a specific notification channel (Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS), but the settings for all notifications by the app (Settings.ACTION_APP_NOTIFICATION_SETTINGS) --- .../newpipe/local/feed/notifications/NotificationHelper.kt | 6 ++---- .../newpipe/settings/NotificationsSettingsFragment.kt | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/feed/notifications/NotificationHelper.kt b/app/src/main/java/org/schabi/newpipe/local/feed/notifications/NotificationHelper.kt index fa26be37a..87101abcd 100644 --- a/app/src/main/java/org/schabi/newpipe/local/feed/notifications/NotificationHelper.kt +++ b/app/src/main/java/org/schabi/newpipe/local/feed/notifications/NotificationHelper.kt @@ -142,15 +142,13 @@ class NotificationHelper(val context: Context) { } /** - * Open the system's notification settings for NewPipe on Android O (API 26) and later. + * Open the system's notification settings for NewPipe on Android Oreo (API 26) and later. * Open the system's app settings for NewPipe on previous Android versions. */ fun openNewPipeSystemNotificationSettings(context: Context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - val channelId = context.getString(R.string.streams_notification_channel_id) - val intent = Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS) + val intent = Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS) .putExtra(Settings.EXTRA_APP_PACKAGE, context.packageName) - .putExtra(Settings.EXTRA_CHANNEL_ID, channelId) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) context.startActivity(intent) } else { diff --git a/app/src/main/java/org/schabi/newpipe/settings/NotificationsSettingsFragment.kt b/app/src/main/java/org/schabi/newpipe/settings/NotificationsSettingsFragment.kt index 938b7ff8d..e1f7ed2c2 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/NotificationsSettingsFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/settings/NotificationsSettingsFragment.kt @@ -57,7 +57,7 @@ class NotificationsSettingsFragment : BasePreferenceFragment(), OnSharedPreferen Snackbar.LENGTH_INDEFINITE ).apply { setAction(R.string.settings) { - activity?.let { NotificationHelper.openNewPipeSystemNotificationSettings(it) } + NotificationHelper.openNewPipeSystemNotificationSettings(it.context) } setActionTextColor(Color.YELLOW) addCallback(object : Snackbar.Callback() {