Prevent notification sound when voice recording.

This commit is contained in:
lisa-signal
2025-06-13 13:45:18 -04:00
committed by Michelle Tang
parent e7140a14a3
commit f3857ed933
3 changed files with 29 additions and 2 deletions

View File

@@ -0,0 +1,23 @@
package org.thoughtcrime.securesms.notifications.v2
import org.signal.core.util.logging.Log
/**
* Suppressor for notification sounds.
*/
object InChatNotificationSoundSuppressor {
private val TAG = Log.tag(InChatNotificationSoundSuppressor::class.java)
var isSuppressed: Boolean = false
@JvmStatic
fun suppressNotification() {
isSuppressed = true
Log.d(TAG, "Notification is suppressed.")
}
@JvmStatic
fun allowNotification() {
isSuppressed = false
Log.d(TAG, "Notification is allowed.")
}
}

View File

@@ -311,7 +311,8 @@ object NotificationFactory {
if (!NotificationChannels.getInstance().areNotificationsEnabled() ||
!SignalStore.settings.isMessageNotificationsInChatSoundsEnabled ||
ServiceUtil.getAudioManager(context).ringerMode != AudioManager.RINGER_MODE_NORMAL ||
(System.currentTimeMillis() - lastAudibleNotification) < DefaultMessageNotifier.MIN_AUDIBLE_PERIOD_MILLIS
(System.currentTimeMillis() - lastAudibleNotification) < DefaultMessageNotifier.MIN_AUDIBLE_PERIOD_MILLIS ||
InChatNotificationSoundSuppressor.isSuppressed
) {
return
}