Fix notification issues introduced when adding lower API versions.

fork-5.53.8
Cody Henthorne 2021-04-28 20:49:36 -04:00
rodzic ac71c02dfa
commit 751afadebd
2 zmienionych plików z 13 dodań i 2 usunięć

Wyświetl plik

@ -30,7 +30,6 @@ import org.thoughtcrime.securesms.util.ServiceUtil
import org.thoughtcrime.securesms.util.TextSecurePreferences
import org.thoughtcrime.securesms.webrtc.CallNotificationBuilder
import org.whispersystems.signalservice.internal.util.Util
import java.lang.UnsupportedOperationException
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.Executor
import java.util.concurrent.Executors
@ -167,6 +166,7 @@ class MessageNotifierV2(context: Application) : MessageNotifier {
targetThreadId = threadId,
defaultBubbleState = defaultBubbleState,
lastAudibleNotification = lastAudibleNotification,
notificationConfigurationChanged = notificationConfigurationChanged,
alertOverrides = alertOverrides
)

Wyświetl plik

@ -45,6 +45,7 @@ object NotificationFactory {
targetThreadId: Long,
defaultBubbleState: BubbleUtil.BubbleState,
lastAudibleNotification: Long,
notificationConfigurationChanged: Boolean,
alertOverrides: Set<Long>
): Set<Long> {
if (state.isEmpty) {
@ -72,6 +73,7 @@ object NotificationFactory {
targetThreadId = targetThreadId,
defaultBubbleState = defaultBubbleState,
lastAudibleNotification = lastAudibleNotification,
notificationConfigurationChanged = notificationConfigurationChanged,
alertOverrides = alertOverrides,
nonVisibleThreadCount = nonVisibleThreadCount
)
@ -127,6 +129,7 @@ object NotificationFactory {
targetThreadId: Long,
defaultBubbleState: BubbleUtil.BubbleState,
lastAudibleNotification: Long,
notificationConfigurationChanged: Boolean,
alertOverrides: Set<Long>,
nonVisibleThreadCount: Int
): Set<Long> {
@ -136,7 +139,7 @@ object NotificationFactory {
if (conversation.threadId == visibleThreadId && conversation.hasNewNotifications()) {
Log.internal().i(TAG, "Thread is visible, notifying in thread. notificationId: ${conversation.notificationId}")
notifyInThread(context, conversation.recipient, lastAudibleNotification)
} else {
} else if (notificationConfigurationChanged || conversation.hasNewNotifications() || alertOverrides.contains(conversation.threadId)) {
if (conversation.hasNewNotifications()) {
threadsThatNewlyAlerted += conversation.threadId
}
@ -165,6 +168,10 @@ object NotificationFactory {
defaultBubbleState: BubbleUtil.BubbleState,
shouldAlert: Boolean
) {
if (conversation.notificationItems.isEmpty()) {
return
}
val builder: NotificationBuilder = NotificationBuilder.create(context)
builder.apply {
@ -205,6 +212,10 @@ object NotificationFactory {
}
private fun notifySummary(context: Context, state: NotificationStateV2) {
if (state.messageCount == 0) {
return
}
val builder: NotificationBuilder = NotificationBuilder.create(context)
builder.apply {