kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix notification issues introduced when adding lower API versions.
rodzic
ac71c02dfa
commit
751afadebd
|
@ -30,7 +30,6 @@ import org.thoughtcrime.securesms.util.ServiceUtil
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||||
import org.thoughtcrime.securesms.webrtc.CallNotificationBuilder
|
import org.thoughtcrime.securesms.webrtc.CallNotificationBuilder
|
||||||
import org.whispersystems.signalservice.internal.util.Util
|
import org.whispersystems.signalservice.internal.util.Util
|
||||||
import java.lang.UnsupportedOperationException
|
|
||||||
import java.util.concurrent.ConcurrentHashMap
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
import java.util.concurrent.Executor
|
import java.util.concurrent.Executor
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
|
@ -167,6 +166,7 @@ class MessageNotifierV2(context: Application) : MessageNotifier {
|
||||||
targetThreadId = threadId,
|
targetThreadId = threadId,
|
||||||
defaultBubbleState = defaultBubbleState,
|
defaultBubbleState = defaultBubbleState,
|
||||||
lastAudibleNotification = lastAudibleNotification,
|
lastAudibleNotification = lastAudibleNotification,
|
||||||
|
notificationConfigurationChanged = notificationConfigurationChanged,
|
||||||
alertOverrides = alertOverrides
|
alertOverrides = alertOverrides
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ object NotificationFactory {
|
||||||
targetThreadId: Long,
|
targetThreadId: Long,
|
||||||
defaultBubbleState: BubbleUtil.BubbleState,
|
defaultBubbleState: BubbleUtil.BubbleState,
|
||||||
lastAudibleNotification: Long,
|
lastAudibleNotification: Long,
|
||||||
|
notificationConfigurationChanged: Boolean,
|
||||||
alertOverrides: Set<Long>
|
alertOverrides: Set<Long>
|
||||||
): Set<Long> {
|
): Set<Long> {
|
||||||
if (state.isEmpty) {
|
if (state.isEmpty) {
|
||||||
|
@ -72,6 +73,7 @@ object NotificationFactory {
|
||||||
targetThreadId = targetThreadId,
|
targetThreadId = targetThreadId,
|
||||||
defaultBubbleState = defaultBubbleState,
|
defaultBubbleState = defaultBubbleState,
|
||||||
lastAudibleNotification = lastAudibleNotification,
|
lastAudibleNotification = lastAudibleNotification,
|
||||||
|
notificationConfigurationChanged = notificationConfigurationChanged,
|
||||||
alertOverrides = alertOverrides,
|
alertOverrides = alertOverrides,
|
||||||
nonVisibleThreadCount = nonVisibleThreadCount
|
nonVisibleThreadCount = nonVisibleThreadCount
|
||||||
)
|
)
|
||||||
|
@ -127,6 +129,7 @@ object NotificationFactory {
|
||||||
targetThreadId: Long,
|
targetThreadId: Long,
|
||||||
defaultBubbleState: BubbleUtil.BubbleState,
|
defaultBubbleState: BubbleUtil.BubbleState,
|
||||||
lastAudibleNotification: Long,
|
lastAudibleNotification: Long,
|
||||||
|
notificationConfigurationChanged: Boolean,
|
||||||
alertOverrides: Set<Long>,
|
alertOverrides: Set<Long>,
|
||||||
nonVisibleThreadCount: Int
|
nonVisibleThreadCount: Int
|
||||||
): Set<Long> {
|
): Set<Long> {
|
||||||
|
@ -136,7 +139,7 @@ object NotificationFactory {
|
||||||
if (conversation.threadId == visibleThreadId && conversation.hasNewNotifications()) {
|
if (conversation.threadId == visibleThreadId && conversation.hasNewNotifications()) {
|
||||||
Log.internal().i(TAG, "Thread is visible, notifying in thread. notificationId: ${conversation.notificationId}")
|
Log.internal().i(TAG, "Thread is visible, notifying in thread. notificationId: ${conversation.notificationId}")
|
||||||
notifyInThread(context, conversation.recipient, lastAudibleNotification)
|
notifyInThread(context, conversation.recipient, lastAudibleNotification)
|
||||||
} else {
|
} else if (notificationConfigurationChanged || conversation.hasNewNotifications() || alertOverrides.contains(conversation.threadId)) {
|
||||||
if (conversation.hasNewNotifications()) {
|
if (conversation.hasNewNotifications()) {
|
||||||
threadsThatNewlyAlerted += conversation.threadId
|
threadsThatNewlyAlerted += conversation.threadId
|
||||||
}
|
}
|
||||||
|
@ -165,6 +168,10 @@ object NotificationFactory {
|
||||||
defaultBubbleState: BubbleUtil.BubbleState,
|
defaultBubbleState: BubbleUtil.BubbleState,
|
||||||
shouldAlert: Boolean
|
shouldAlert: Boolean
|
||||||
) {
|
) {
|
||||||
|
if (conversation.notificationItems.isEmpty()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
val builder: NotificationBuilder = NotificationBuilder.create(context)
|
val builder: NotificationBuilder = NotificationBuilder.create(context)
|
||||||
|
|
||||||
builder.apply {
|
builder.apply {
|
||||||
|
@ -205,6 +212,10 @@ object NotificationFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun notifySummary(context: Context, state: NotificationStateV2) {
|
private fun notifySummary(context: Context, state: NotificationStateV2) {
|
||||||
|
if (state.messageCount == 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
val builder: NotificationBuilder = NotificationBuilder.create(context)
|
val builder: NotificationBuilder = NotificationBuilder.create(context)
|
||||||
|
|
||||||
builder.apply {
|
builder.apply {
|
||||||
|
|
Ładowanie…
Reference in New Issue