From f1ab81f5eed2b7f6890a20d0a33fda8dafd06ab5 Mon Sep 17 00:00:00 2001 From: Moez Bhatti Date: Mon, 4 Dec 2017 02:56:53 -0500 Subject: [PATCH] Only show notifications if enabled --- .../java/com/moez/QKSMS/common/util/NotificationManager.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qksms/src/main/java/com/moez/QKSMS/common/util/NotificationManager.kt b/qksms/src/main/java/com/moez/QKSMS/common/util/NotificationManager.kt index fab0ef46..0c9f00a7 100644 --- a/qksms/src/main/java/com/moez/QKSMS/common/util/NotificationManager.kt +++ b/qksms/src/main/java/com/moez/QKSMS/common/util/NotificationManager.kt @@ -22,12 +22,13 @@ import javax.inject.Singleton @Singleton class NotificationManager @Inject constructor( private val context: Context, + private val prefs: Preferences, private val colors: Colors) { private val notificationManager = NotificationManagerCompat.from(context) init { - if (Build.VERSION.SDK_INT >= 26) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager val id = "channel_1" @@ -47,6 +48,8 @@ class NotificationManager @Inject constructor( } fun update(messageRepo: MessageRepository) { + if (!prefs.notifications.get()) return + messageRepo.getUnreadUnseenMessages() .groupBy { message -> message.threadId } .forEach { group ->