forked from upstream-mirrors/quik
Only show notifications if enabled
This commit is contained in:
@@ -22,12 +22,13 @@ import javax.inject.Singleton
|
|||||||
@Singleton
|
@Singleton
|
||||||
class NotificationManager @Inject constructor(
|
class NotificationManager @Inject constructor(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
|
private val prefs: Preferences,
|
||||||
private val colors: Colors) {
|
private val colors: Colors) {
|
||||||
|
|
||||||
private val notificationManager = NotificationManagerCompat.from(context)
|
private val notificationManager = NotificationManagerCompat.from(context)
|
||||||
|
|
||||||
init {
|
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 notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||||
|
|
||||||
val id = "channel_1"
|
val id = "channel_1"
|
||||||
@@ -47,6 +48,8 @@ class NotificationManager @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun update(messageRepo: MessageRepository) {
|
fun update(messageRepo: MessageRepository) {
|
||||||
|
if (!prefs.notifications.get()) return
|
||||||
|
|
||||||
messageRepo.getUnreadUnseenMessages()
|
messageRepo.getUnreadUnseenMessages()
|
||||||
.groupBy { message -> message.threadId }
|
.groupBy { message -> message.threadId }
|
||||||
.forEach { group ->
|
.forEach { group ->
|
||||||
|
|||||||
Reference in New Issue
Block a user