Allow per-contact notification settings for pre-oreo

This commit is contained in:
Moez Bhatti
2018-02-27 21:38:44 -05:00
parent 59a40c5372
commit 30f6dac784
6 changed files with 52 additions and 26 deletions
@@ -76,7 +76,7 @@ class NotificationManager @Inject constructor(
*/
fun update(threadId: Long) {
// If notifications are disabled, don't do anything
if (!prefs.notifications.get()) {
if (!prefs.notifications(threadId).get()) {
return
}
@@ -119,9 +119,9 @@ class NotificationManager @Inject constructor(
.setDeleteIntent(seenPI)
.addAction(readAction)
.setStyle(style)
.setSound(Uri.parse(prefs.ringtone.get()))
.setSound(Uri.parse(prefs.ringtone(threadId).get()))
.setLights(Color.WHITE, 500, 2000)
.setVibrate(if (prefs.vibration.get()) VIBRATE_PATTERN else longArrayOf(0))
.setVibrate(if (prefs.vibration(threadId).get()) VIBRATE_PATTERN else longArrayOf(0))
if (Build.VERSION.SDK_INT >= 24) {
notification.addAction(getReplyAction(conversation.recipients[0]?.address.orEmpty(), threadId))
@@ -154,9 +154,9 @@ class NotificationManager @Inject constructor(
.setSmallIcon(R.drawable.ic_notification_failed)
.setAutoCancel(true)
.setContentIntent(contentPI)
.setSound(Uri.parse(prefs.ringtone.get()))
.setSound(Uri.parse(prefs.ringtone(threadId).get()))
.setLights(Color.WHITE, 500, 2000)
.setVibrate(if (prefs.vibration.get()) VIBRATE_PATTERN else longArrayOf(0))
.setVibrate(if (prefs.vibration(threadId).get()) VIBRATE_PATTERN else longArrayOf(0))
notificationManager.notify(threadId.toInt() + 50000, notification.build())
}