From 5bdb6a5dfddea58a6551cdf381c00cf055f5b308 Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Tue, 15 Mar 2022 20:03:18 +0100 Subject: [PATCH] Setting whether chat notifications should repeatedly alert Closes https://github.com/SchildiChat/SchildiChat-android/issues/111 Change-Id: I4c963caabdb10fa601799d3cb3fed2ad96d3d54c --- FEATURES.md | 1 + .../app/features/notifications/NotificationUtils.kt | 6 +++--- .../im/vector/app/features/settings/VectorPreferences.kt | 6 ++++++ vector/src/main/res/values/strings_sc.xml | 3 +++ vector/src/main/res/xml/vector_settings_notifications.xml | 8 ++++++++ 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/FEATURES.md b/FEATURES.md index 1609d9afa5..ed14ba5f9a 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -26,6 +26,7 @@ Here you can find some extra features and changes compared to Element Android (w - Chat options menu: add entry for member list (to skip the step of clicking on the room name, to enter room settings), and hide the less frequently used invite option (which is still available from the member list) - Smaller compose area (as before Element 1.0.12) - Compose area: emoji button on the left, attachments button on the right (flipped compared to Element, but what most other messengers do, thus more familiar to most users) +- Setting to re-alert for new messages even if there's still an old notification for that room - Branding (name, app icon, links) - Show a toast instead of a snackbar after copying text, in order to not block the input area right after copying diff --git a/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt b/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt index 5194df102f..d23f1e7653 100755 --- a/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt +++ b/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt @@ -559,7 +559,7 @@ class NotificationUtils @Inject constructor(private val context: Context, val channelID = if (roomInfo.shouldBing) NOISY_NOTIFICATION_CHANNEL_ID else SILENT_NOTIFICATION_CHANNEL_ID return NotificationCompat.Builder(context, channelID) - .setOnlyAlertOnce(true) + .setOnlyAlertOnce(vectorPreferences.onlyAlertOnce()) .setWhen(lastMessageTimestamp) // MESSAGING_STYLE sets title and content for API 16 and above devices. .setStyle(messageStyle) @@ -743,7 +743,7 @@ class NotificationUtils @Inject constructor(private val context: Context, val channelID = if (simpleNotifiableEvent.noisy) NOISY_NOTIFICATION_CHANNEL_ID else SILENT_NOTIFICATION_CHANNEL_ID return NotificationCompat.Builder(context, channelID) - .setOnlyAlertOnce(true) + .setOnlyAlertOnce(vectorPreferences.onlyAlertOnce()) .setContentTitle(stringProvider.getString(R.string.app_name)) .setContentText(simpleNotifiableEvent.description) .setGroup(stringProvider.getString(R.string.app_name)) @@ -853,7 +853,7 @@ class NotificationUtils @Inject constructor(private val context: Context, val smallIcon = R.drawable.ic_status_bar_sc return NotificationCompat.Builder(context, if (noisy) NOISY_NOTIFICATION_CHANNEL_ID else SILENT_NOTIFICATION_CHANNEL_ID) - .setOnlyAlertOnce(true) + .setOnlyAlertOnce(vectorPreferences.onlyAlertOnce()) // used in compat < N, after summary is built based on child notifications .setWhen(lastMessageTimestamp) .setStyle(style) diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt index 22e053fc22..c47b937a13 100755 --- a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt @@ -215,6 +215,7 @@ class VectorPreferences @Inject constructor(private val context: Context, privat private const val SETTINGS_JUMP_TO_BOTTOM_ON_SEND = "SETTINGS_JUMP_TO_BOTTOM_ON_SEND" private const val SETTINGS_SPACE_MEMBERS_IN_SPACE_ROOMS = "SETTINGS_SPACE_MEMBERS_IN_SPACE_ROOMS" private const val SETTINGS_ENABLE_SPACE_PAGER = "SETTINGS_ENABLE_SPACE_PAGER" + private const val SETTINGS_NOTIF_ONLY_ALERT_ONCE = "SETTINGS_NOTIF_ONLY_ALERT_ONCE" private const val DID_ASK_TO_ENABLE_SESSION_PUSH = "DID_ASK_TO_ENABLE_SESSION_PUSH" @@ -1077,6 +1078,11 @@ class VectorPreferences @Inject constructor(private val context: Context, privat return defaultPrefs.getBoolean(SETTINGS_ENABLE_SPACE_PAGER, false) } + // SC addition + fun onlyAlertOnce(): Boolean { + return defaultPrefs.getBoolean(SETTINGS_NOTIF_ONLY_ALERT_ONCE, true) + } + /** * I likely do more fresh installs of the app than anyone else, so a shortcut to change some of the default settings to * my preferred values can safe me some time diff --git a/vector/src/main/res/values/strings_sc.xml b/vector/src/main/res/values/strings_sc.xml index 00f3caf219..17cb616cac 100644 --- a/vector/src/main/res/values/strings_sc.xml +++ b/vector/src/main/res/values/strings_sc.xml @@ -163,6 +163,9 @@ Swipe chat list to switch space Allow to switch between root spaces by swiping horizontally in the chat list + Only alert once + Omit alert sounds for new messages if there is already an open notification for that chat + Default diff --git a/vector/src/main/res/xml/vector_settings_notifications.xml b/vector/src/main/res/xml/vector_settings_notifications.xml index 5859e76441..751a165cfa 100644 --- a/vector/src/main/res/xml/vector_settings_notifications.xml +++ b/vector/src/main/res/xml/vector_settings_notifications.xml @@ -77,6 +77,14 @@ android:summary="@string/settings_system_preferences_summary" android:title="@string/settings_call_notifications_preferences" /> + + +