diff --git a/app/src/main/java/io/heckel/ntfy/msg/NotificationService.kt b/app/src/main/java/io/heckel/ntfy/msg/NotificationService.kt index b6ac8c1..0c0dede 100644 --- a/app/src/main/java/io/heckel/ntfy/msg/NotificationService.kt +++ b/app/src/main/java/io/heckel/ntfy/msg/NotificationService.kt @@ -73,6 +73,10 @@ class NotificationService(val context: Context) { maybeDeleteNotificationGroup(groupId) } + fun channelsSupported(): Boolean { + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O + } + private fun subscriptionGroupId(subscription: Subscription): String { return subscription.id.toString() } @@ -339,7 +343,7 @@ class NotificationService(val context: Context) { } private fun maybeCreateNotificationChannel(group: String, priority: Int) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + if (channelsSupported()) { // Note: To change a notification channel, you must delete the old one and create a new one! val channelId = toChannelId(group, priority) @@ -378,19 +382,19 @@ class NotificationService(val context: Context) { } private fun maybeDeleteNotificationChannel(group: String, priority: Int) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + if (channelsSupported()) { notificationManager.deleteNotificationChannel(toChannelId(group, priority)) } } private fun maybeCreateNotificationGroup(id: String, name: String) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + if (channelsSupported()) { notificationManager.createNotificationChannelGroup(NotificationChannelGroup(id, name)) } } private fun maybeDeleteNotificationGroup(id: String) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + if (channelsSupported()) { notificationManager.deleteNotificationChannelGroup(id) } } diff --git a/app/src/main/java/io/heckel/ntfy/ui/DetailSettingsActivity.kt b/app/src/main/java/io/heckel/ntfy/ui/DetailSettingsActivity.kt index 06b2927..819b421 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/DetailSettingsActivity.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/DetailSettingsActivity.kt @@ -115,13 +115,15 @@ class DetailSettingsActivity : AppCompatActivity() { private fun loadView() { if (subscription.upAppId == null) { loadInstantPref() - loadDedicatedChannelsPrefs() - loadOpenChannelsPrefs() loadMutedUntilPref() loadMinPriorityPref() loadAutoDeletePref() loadIconSetPref() loadIconRemovePref() + if (notificationService.channelsSupported()) { + loadDedicatedChannelsPrefs() + loadOpenChannelsPrefs() + } } else { val notificationsHeaderId = context?.getString(R.string.detail_settings_notifications_header_key) ?: return val notificationsHeader: PreferenceCategory? = findPreference(notificationsHeaderId) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fa054e3..deecdbe 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -350,10 +350,10 @@ Instant delivery Notifications are delivered instantly. Requires a foreground service and consumes more battery. Notifications are delivered using Firebase. Delivery may be delayed, but consumes less battery. - Use dedicated channels - Use dedicated notification channels for this subscription - Use default notification channels - Configure dedicated channels + Custom notification settings + Using dedicated notification channels for this subscription + Using default settings (sounds, Do Not Disturb override, etc.) + Configure notification settings Do Not Disturb (DND) override, sounds, etc. Appearance Subscription icon