From 5dc6569a683da47f5323c252fce1bd4094a5d232 Mon Sep 17 00:00:00 2001 From: Roshan Varughese <40583749+Animeboynz@users.noreply.github.com> Date: Mon, 26 Aug 2024 01:47:25 +1200 Subject: [PATCH] Respect privacy settings in extension update notification (#1156) * Hide Extension Names in Update Notifications when Content is Hidden * Moving `val` inside if * [skip ci] Update CHANGELOG.md --- CHANGELOG.md | 1 + .../extension/api/ExtensionUpdateNotifier.kt | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7affa28c9..447104f36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Extension trust system ([@AntsyLich](https://github.com/AntsyLich), [@Animeboynz](https://github.com/Animeboynz) ([#570](https://github.com/mihonapp/mihon/pull/570), [#1057](https://github.com/mihonapp/mihon/pull/1057)) - Make category backup/restore not dependant on library backup ([@AntsyLich](https://github.com/AntsyLich)) ([`56fb4f6`](https://github.com/mihonapp/mihon/commit/56fb4f62a152e87a71892aa68c78cac51a2c8596)) - Kitsu domain to `kitsu.app` ([@MajorTanya](https://github.com/MajorTanya)) ([#1106](https://github.com/mihonapp/mihon/pull/1106)) +- Respect privacy settings in extension update notification ([@Animeboynz](https://github.com/Animeboynz)) ([#1156](https://github.com/mihonapp/mihon/pull/1156)) ### Improvement - Long strip reader performance ([@FooIbar](https://github.com/FooIbar), [@wwww-wwww](https://github.com/wwww-wwww)) ([#687](https://github.com/mihonapp/mihon/pull/687)) diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionUpdateNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionUpdateNotifier.kt index ff764271e..2b675ae60 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionUpdateNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionUpdateNotifier.kt @@ -3,15 +3,20 @@ package eu.kanade.tachiyomi.extension.api import android.content.Context import androidx.core.app.NotificationCompat import eu.kanade.tachiyomi.R +import eu.kanade.tachiyomi.core.security.SecurityPreferences import eu.kanade.tachiyomi.data.notification.NotificationReceiver import eu.kanade.tachiyomi.data.notification.Notifications import eu.kanade.tachiyomi.util.system.cancelNotification import eu.kanade.tachiyomi.util.system.notify import tachiyomi.core.common.i18n.pluralStringResource import tachiyomi.i18n.MR +import uy.kohesive.injekt.Injekt +import uy.kohesive.injekt.api.get -class ExtensionUpdateNotifier(private val context: Context) { - +class ExtensionUpdateNotifier( + private val context: Context, + private val securityPreferences: SecurityPreferences = Injekt.get(), +) { fun promptUpdates(names: List) { context.notify( Notifications.ID_UPDATES_TO_EXTS, @@ -24,9 +29,11 @@ class ExtensionUpdateNotifier(private val context: Context) { names.size, ), ) - val extNames = names.joinToString(", ") - setContentText(extNames) - setStyle(NotificationCompat.BigTextStyle().bigText(extNames)) + if (!securityPreferences.hideNotificationContent().get()) { + val extNames = names.joinToString(", ") + setContentText(extNames) + setStyle(NotificationCompat.BigTextStyle().bigText(extNames)) + } setSmallIcon(R.drawable.ic_extension_24dp) setContentIntent(NotificationReceiver.openExtensionsPendingActivity(context)) setAutoCancel(true)