mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-02 16:32:57 +01:00
Fix messages not marked as read in split pane mode.
This commit is contained in:
committed by
jeffrey-signal
parent
be920148e7
commit
35cf24b577
@@ -775,7 +775,7 @@ class ConversationFragment :
|
||||
ConversationUtil.refreshRecipientShortcuts()
|
||||
|
||||
if (!args.conversationScreenType.isInBubble) {
|
||||
AppDependencies.messageNotifier.clearVisibleThread()
|
||||
AppDependencies.messageNotifier.clearVisibleThread(ConversationId.forConversation(args.threadId))
|
||||
} else {
|
||||
AppDependencies.messageNotifier.clearVisibleBubbleThread()
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ public interface MessageNotifier {
|
||||
void setVisibleThread(@Nullable ConversationId conversationId);
|
||||
@NonNull Optional<ConversationId> getVisibleThread();
|
||||
void clearVisibleThread();
|
||||
void clearVisibleThread(@NonNull ConversationId conversationId);
|
||||
void setVisibleBubbleThread(@Nullable ConversationId conversationId);
|
||||
void clearVisibleBubbleThread();
|
||||
void setLastDesktopActivityTimestamp(long timestamp);
|
||||
|
||||
@@ -52,6 +52,11 @@ public class OptimizedMessageNotifier implements MessageNotifier {
|
||||
getNotifier().clearVisibleThread();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearVisibleThread(@NonNull ConversationId conversationId) {
|
||||
getNotifier().clearVisibleThread(conversationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisibleBubbleThread(@Nullable ConversationId conversationId) {
|
||||
getNotifier().setVisibleBubbleThread(conversationId);
|
||||
|
||||
@@ -36,6 +36,7 @@ import java.util.concurrent.Executor
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
import kotlin.collections.MutableMap.MutableEntry
|
||||
import kotlin.math.max
|
||||
|
||||
@@ -43,7 +44,7 @@ import kotlin.math.max
|
||||
* MessageNotifier implementation using the new system for creating and showing notifications.
|
||||
*/
|
||||
class DefaultMessageNotifier(context: Application) : MessageNotifier {
|
||||
@Volatile private var visibleThread: ConversationId? = null
|
||||
private val visibleThread: AtomicReference<ConversationId?> = AtomicReference(null)
|
||||
|
||||
@Volatile private var visibleBubbleThread: ConversationId? = null
|
||||
|
||||
@@ -66,7 +67,7 @@ class DefaultMessageNotifier(context: Application) : MessageNotifier {
|
||||
private val executor = CancelableExecutor()
|
||||
|
||||
override fun setVisibleThread(conversationId: ConversationId?) {
|
||||
visibleThread = conversationId
|
||||
visibleThread.set(conversationId)
|
||||
stickyThreads.remove(conversationId)
|
||||
if (conversationId != null) {
|
||||
lastThreadNotification.remove(conversationId)
|
||||
@@ -74,13 +75,17 @@ class DefaultMessageNotifier(context: Application) : MessageNotifier {
|
||||
}
|
||||
|
||||
override fun getVisibleThread(): Optional<ConversationId> {
|
||||
return Optional.ofNullable(visibleThread)
|
||||
return Optional.ofNullable(visibleThread.get())
|
||||
}
|
||||
|
||||
override fun clearVisibleThread() {
|
||||
setVisibleThread(null)
|
||||
}
|
||||
|
||||
override fun clearVisibleThread(conversationId: ConversationId) {
|
||||
visibleThread.compareAndSet(conversationId, null)
|
||||
}
|
||||
|
||||
override fun setVisibleBubbleThread(conversationId: ConversationId?) {
|
||||
visibleBubbleThread = conversationId
|
||||
}
|
||||
@@ -94,7 +99,7 @@ class DefaultMessageNotifier(context: Application) : MessageNotifier {
|
||||
}
|
||||
|
||||
override fun notifyMessageDeliveryFailed(context: Context, recipient: Recipient, conversationId: ConversationId) {
|
||||
NotificationFactory.notifyMessageDeliveryFailed(context, recipient, conversationId, visibleThread, visibleBubbleThread)
|
||||
NotificationFactory.notifyMessageDeliveryFailed(context, recipient, conversationId, visibleThread.get(), visibleBubbleThread)
|
||||
}
|
||||
|
||||
override fun notifyStoryDeliveryFailed(context: Context, recipient: Recipient, conversationId: ConversationId) {
|
||||
@@ -102,7 +107,7 @@ class DefaultMessageNotifier(context: Application) : MessageNotifier {
|
||||
}
|
||||
|
||||
override fun notifyProofRequired(context: Context, recipient: Recipient, conversationId: ConversationId) {
|
||||
NotificationFactory.notifyProofRequired(context, recipient, conversationId, visibleThread)
|
||||
NotificationFactory.notifyProofRequired(context, recipient, conversationId, visibleThread.get())
|
||||
}
|
||||
|
||||
override fun cancelDelayedNotifications() {
|
||||
@@ -194,7 +199,7 @@ class DefaultMessageNotifier(context: Application) : MessageNotifier {
|
||||
val threadsThatAlerted: Set<ConversationId> = NotificationFactory.notify(
|
||||
context = ContextThemeWrapper(context, R.style.TextSecure_LightTheme),
|
||||
state = state,
|
||||
visibleThread = visibleThread,
|
||||
visibleThread = visibleThread.get(),
|
||||
targetThread = conversationId,
|
||||
defaultBubbleState = defaultBubbleState,
|
||||
lastAudibleNotification = lastAudibleNotification,
|
||||
@@ -219,7 +224,7 @@ class DefaultMessageNotifier(context: Application) : MessageNotifier {
|
||||
Log.i(TAG, "threads: ${state.threadCount} messages: ${state.messageCount}")
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
val ids = state.conversations.filter { it.thread != visibleThread }.map { it.notificationId } + stickyThreads.map { (_, stickyThread) -> stickyThread.notificationId }
|
||||
val ids = state.conversations.filter { it.thread != visibleThread.get() }.map { it.notificationId } + stickyThreads.map { (_, stickyThread) -> stickyThread.notificationId }
|
||||
val notShown = ids - ServiceUtil.getNotificationManager(context).getDisplayedNotificationIds().getOrDefault(emptySet())
|
||||
if (notShown.isNotEmpty()) {
|
||||
Log.e(TAG, "Notifications should be showing but are not for ${notShown.size} threads")
|
||||
|
||||
Reference in New Issue
Block a user