aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/services
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-04-21 20:22:11 -0400
committerAllan Wang <me@allanwang.ca>2019-04-21 20:22:11 -0400
commitbbafb7b65ce655c1fdda8badd3098d2a0e1f7f08 (patch)
tree354b0bb6f021af54d1e3586e3e9bda064ad4ef02 /app/src/main/kotlin/com/pitchedapps/frost/services
parente5eb928feacba8d1c634ad8e5d85259ae161cabd (diff)
parentf0f95295bdb2b853aa6262ec4bed2353ce326eee (diff)
downloadfrost-bbafb7b65ce655c1fdda8badd3098d2a0e1f7f08.tar.gz
frost-bbafb7b65ce655c1fdda8badd3098d2a0e1f7f08.tar.bz2
frost-bbafb7b65ce655c1fdda8badd3098d2a0e1f7f08.zip
Merge dev
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/services')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt19
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt4
2 files changed, 14 insertions, 9 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt
index 631912a3..6f039784 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt
@@ -122,14 +122,19 @@ enum class NotificationType(
L.v { "$name notification data not found" }
return -1
}
- val notifContents = response.data.getUnreadNotifications(data).filter { notif ->
- val inText = notif.text.let { text ->
- Prefs.notificationKeywords.none { text.contains(it, true) }
+
+ /**
+ * Checks that the text doesn't contain any blacklisted keywords
+ */
+ fun validText(text: String?): Boolean {
+ val t = text ?: return true
+ return Prefs.notificationKeywords.none {
+ t.contains(it, true)
}
- val inTitle = notif.title?.let { title ->
- Prefs.notificationKeywords.none { title.contains(it, true) }
- } ?: false
- inText || inTitle
+ }
+
+ val notifContents = response.data.getUnreadNotifications(data).filter { notif ->
+ validText(notif.title) && validText(notif.text)
}
if (notifContents.isEmpty()) return 0
val userId = data.id
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt
index 20a497e3..bba2a9a1 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt
@@ -46,14 +46,14 @@ fun setupNotificationChannels(c: Context) {
val manager = c.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val appName = c.string(R.string.frost_name)
val msg = c.string(R.string.messages)
+ manager.createNotificationChannel(NOTIF_CHANNEL_GENERAL, appName)
+ manager.createNotificationChannel(NOTIF_CHANNEL_MESSAGES, "$appName: $msg")
manager.notificationChannels
.filter {
it.id != NOTIF_CHANNEL_GENERAL &&
it.id != NOTIF_CHANNEL_MESSAGES
}
.forEach { manager.deleteNotificationChannel(it.id) }
- manager.createNotificationChannel(NOTIF_CHANNEL_GENERAL, appName)
- manager.createNotificationChannel(NOTIF_CHANNEL_MESSAGES, "$appName: $msg")
L.d { "Created notification channels: ${manager.notificationChannels.size} channels, ${manager.notificationChannelGroups.size} groups" }
}