From 1355c3d75cee80f21719aaebb7196c330135e728 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Wed, 22 May 2024 13:03:59 +0300 Subject: [PATCH] Option to disable nsfw updates notifications --- .../org/koitharu/kotatsu/core/prefs/AppSettings.kt | 4 ++++ .../tracker/work/TrackerNotificationHelper.kt | 3 +++ app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/pref_tracker.xml | 13 +++++++++++-- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/AppSettings.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/AppSettings.kt index dccb102b9..6f9cdc0e7 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/AppSettings.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/AppSettings.kt @@ -155,6 +155,9 @@ class AppSettings @Inject constructor(@ApplicationContext context: Context) { val isTrackerNotificationsEnabled: Boolean get() = prefs.getBoolean(KEY_TRACKER_NOTIFICATIONS, true) + val isTrackerNsfwDisabled: Boolean + get() = prefs.getBoolean(KEY_TRACKER_NO_NSFW, false) + var notificationSound: Uri get() = prefs.getString(KEY_NOTIFICATIONS_SOUND, null)?.toUriOrNull() ?: Settings.System.DEFAULT_NOTIFICATION_URI @@ -587,6 +590,7 @@ class AppSettings @Inject constructor(@ApplicationContext context: Context) { const val KEY_TRACK_CATEGORIES = "track_categories" const val KEY_TRACK_WARNING = "track_warning" const val KEY_TRACKER_NOTIFICATIONS = "tracker_notifications" + const val KEY_TRACKER_NO_NSFW = "tracker_no_nsfw" const val KEY_NOTIFICATIONS_SETTINGS = "notifications_settings" const val KEY_NOTIFICATIONS_SOUND = "notifications_sound" const val KEY_NOTIFICATIONS_VIBRATE = "notifications_vibrate" diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/tracker/work/TrackerNotificationHelper.kt b/app/src/main/kotlin/org/koitharu/kotatsu/tracker/work/TrackerNotificationHelper.kt index 000646210..a6a0feda9 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/tracker/work/TrackerNotificationHelper.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/tracker/work/TrackerNotificationHelper.kt @@ -49,6 +49,9 @@ class TrackerNotificationHelper @Inject constructor( if (newChapters.isEmpty() || !applicationContext.checkNotificationPermission(CHANNEL_ID)) { return null } + if (manga.isNsfw && settings.isTrackerNsfwDisabled) { + return null + } val id = manga.url.hashCode() val builder = NotificationCompat.Builder(applicationContext, CHANNEL_ID) val summary = applicationContext.resources.getQuantityString( diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c072f1951..d8f82781b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -646,4 +646,6 @@ Disable connectivity check You can disable SSL certificates verification in case you face an SSL-related issues when accessing network resources. This may affect your security. Application restarting is required after changing this setting. Skip the connectivity check in case you have issues with it (e.g. going offline mode even though the network is connected) + Disable NSFW notifications + Do not show notifications about NSFW manga updates diff --git a/app/src/main/res/xml/pref_tracker.xml b/app/src/main/res/xml/pref_tracker.xml index f5bf3b479..37069e2a8 100644 --- a/app/src/main/res/xml/pref_tracker.xml +++ b/app/src/main/res/xml/pref_tracker.xml @@ -1,7 +1,8 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools"> + + + app:isPreferenceVisible="false" + tools:isPrefrenceVisible="true" />