Search in sources :

Example 1 with MarkedMessageInfo

use of org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo in project Signal-Android by WhisperSystems.

the class ThreadDatabase method setRead.

public List<MarkedMessageInfo> setRead(long threadId, boolean lastSeen) {
    ContentValues contentValues = new ContentValues(1);
    contentValues.put(READ, 1);
    if (lastSeen) {
        contentValues.put(LAST_SEEN, System.currentTimeMillis());
    }
    SQLiteDatabase db = databaseHelper.getWritableDatabase();
    db.update(TABLE_NAME, contentValues, ID_WHERE, new String[] { threadId + "" });
    final List<MarkedMessageInfo> smsRecords = DatabaseFactory.getSmsDatabase(context).setMessagesRead(threadId);
    final List<MarkedMessageInfo> mmsRecords = DatabaseFactory.getMmsDatabase(context).setMessagesRead(threadId);
    notifyConversationListListeners();
    return new LinkedList<MarkedMessageInfo>() {

        {
            addAll(smsRecords);
            addAll(mmsRecords);
        }
    };
}
Also used : ContentValues(android.content.ContentValues) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) MarkedMessageInfo(org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo) LinkedList(java.util.LinkedList)

Example 2 with MarkedMessageInfo

use of org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo in project Signal-Android by WhisperSystems.

the class MarkReadReceiver method process.

public static void process(@NonNull Context context, @NonNull List<MarkedMessageInfo> markedReadMessages) {
    if (markedReadMessages.isEmpty())
        return;
    List<SyncMessageId> syncMessageIds = new LinkedList<>();
    for (MarkedMessageInfo messageInfo : markedReadMessages) {
        scheduleDeletion(context, messageInfo.getExpirationInfo());
        syncMessageIds.add(messageInfo.getSyncMessageId());
    }
    ApplicationContext.getInstance(context).getJobManager().add(new MultiDeviceReadUpdateJob(context, syncMessageIds));
}
Also used : SyncMessageId(org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId) MarkedMessageInfo(org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo) MultiDeviceReadUpdateJob(org.thoughtcrime.securesms.jobs.MultiDeviceReadUpdateJob) LinkedList(java.util.LinkedList)

Example 3 with MarkedMessageInfo

use of org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo in project Signal-Android by WhisperSystems.

the class MessageNotifier method updateNotification.

public static void updateNotification(@NonNull Context context, @Nullable MasterSecret masterSecret, long threadId, boolean signal) {
    boolean isVisible = visibleThread == threadId;
    ThreadDatabase threads = DatabaseFactory.getThreadDatabase(context);
    Recipients recipients = DatabaseFactory.getThreadDatabase(context).getRecipientsForThreadId(threadId);
    if (isVisible) {
        List<MarkedMessageInfo> messageIds = threads.setRead(threadId, false);
        MarkReadReceiver.process(context, messageIds);
    }
    if (!TextSecurePreferences.isNotificationsEnabled(context) || (recipients != null && recipients.isMuted())) {
        return;
    }
    if (isVisible) {
        sendInThreadNotification(context, threads.getRecipientsForThreadId(threadId));
    } else {
        updateNotification(context, masterSecret, signal, 0);
    }
}
Also used : Recipients(org.thoughtcrime.securesms.recipients.Recipients) ThreadDatabase(org.thoughtcrime.securesms.database.ThreadDatabase) MarkedMessageInfo(org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo)

Aggregations

MarkedMessageInfo (org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo)3 LinkedList (java.util.LinkedList)2 ContentValues (android.content.ContentValues)1 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 SyncMessageId (org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId)1 ThreadDatabase (org.thoughtcrime.securesms.database.ThreadDatabase)1 MultiDeviceReadUpdateJob (org.thoughtcrime.securesms.jobs.MultiDeviceReadUpdateJob)1 Recipients (org.thoughtcrime.securesms.recipients.Recipients)1