Setting whether chat notifications should repeatedly alert

Closes https://github.com/SchildiChat/SchildiChat-android/issues/111

Change-Id: I4c963caabdb10fa601799d3cb3fed2ad96d3d54c
This commit is contained in:
SpiritCroc 2022-03-15 20:03:18 +01:00
parent 4bb246ffe1
commit 5bdb6a5dfd
5 changed files with 21 additions and 3 deletions

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -163,6 +163,9 @@
<string name="settings_enable_space_pager">Swipe chat list to switch space</string>
<string name="settings_enable_space_pager_summary">Allow to switch between root spaces by swiping horizontally in the chat list</string>
<string name="settings_notif_only_alert_once">Only alert once</string>
<string name="settings_notif_only_alert_once_summary">Omit alert sounds for new messages if there is already an open notification for that chat</string>
<!-- Default notification rule -->
<string name="room_settings_default">Default</string>

View File

@ -77,6 +77,14 @@
android:summary="@string/settings_system_preferences_summary"
android:title="@string/settings_call_notifications_preferences" />
<!-- SC addition -->
<im.vector.app.core.preference.VectorSwitchPreference
android:defaultValue="true"
android:dependency="SETTINGS_ENABLE_ALL_NOTIF_PREFERENCE_KEY"
android:key="SETTINGS_NOTIF_ONLY_ALERT_ONCE"
android:title="@string/settings_notif_only_alert_once"
android:summary="@string/settings_notif_only_alert_once_summary" />
</im.vector.app.core.preference.VectorPreferenceCategory>
<im.vector.app.core.preference.VectorPreferenceCategory