Search in sources :

Example 6 with MessageNotifier

use of org.thoughtcrime.securesms.notifications.MessageNotifier in project Signal-Android by signalapp.

the class MessageContentProcessor method handleSynchronizeReadMessage.

private void handleSynchronizeReadMessage(@NonNull List<ReadMessage> readMessages, long envelopeTimestamp, @NonNull Recipient senderRecipient) {
    log(envelopeTimestamp, "Synchronize read message. Count: " + readMessages.size() + ", Timestamps: " + readMessages.stream().map(ReadMessage::getTimestamp));
    Map<Long, Long> threadToLatestRead = new HashMap<>();
    SignalDatabase.mmsSms().setTimestampRead(senderRecipient, readMessages, envelopeTimestamp, threadToLatestRead);
    List<MessageDatabase.MarkedMessageInfo> markedMessages = SignalDatabase.threads().setReadSince(threadToLatestRead, false);
    if (Util.hasItems(markedMessages)) {
        Log.i(TAG, "Updating past messages: " + markedMessages.size());
        MarkReadReceiver.process(context, markedMessages);
    }
    MessageNotifier messageNotifier = ApplicationDependencies.getMessageNotifier();
    messageNotifier.setLastDesktopActivityTimestamp(envelopeTimestamp);
    messageNotifier.cancelDelayedNotifications();
    messageNotifier.updateNotification(context);
}
Also used : ReadMessage(org.whispersystems.signalservice.api.messages.multidevice.ReadMessage) HashMap(java.util.HashMap) MessageNotifier(org.thoughtcrime.securesms.notifications.MessageNotifier)

Aggregations

MessageNotifier (org.thoughtcrime.securesms.notifications.MessageNotifier)6 HashMap (java.util.HashMap)4 MessageRecord (org.thoughtcrime.securesms.database.model.MessageRecord)4 MmsMessageRecord (org.thoughtcrime.securesms.database.model.MmsMessageRecord)4 RecipientId (org.thoughtcrime.securesms.recipients.RecipientId)4 ReadMessage (org.whispersystems.signalservice.api.messages.multidevice.ReadMessage)4 SuppressLint (android.annotation.SuppressLint)2 Context (android.content.Context)2 Build (android.os.Build)2 TextUtils (android.text.TextUtils)2 NonNull (androidx.annotation.NonNull)2 Nullable (androidx.annotation.Nullable)2 Collectors (com.annimon.stream.Collectors)2 Stream (com.annimon.stream.Stream)2 SerializationException (com.mobilecoin.lib.exceptions.SerializationException)2 IOException (java.io.IOException)2 SecureRandom (java.security.SecureRandom)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2