mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
Send read receipts
This commit is contained in:
parent
7f1af51013
commit
851f4c5cf7
@ -2,12 +2,13 @@ package org.thoughtcrime.securesms.conversation.v2
|
||||
|
||||
import android.animation.FloatEvaluator
|
||||
import android.animation.ValueAnimator
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import android.database.Cursor
|
||||
import android.graphics.Rect
|
||||
import android.graphics.Typeface
|
||||
import android.os.AsyncTask
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.util.TypedValue
|
||||
import android.view.*
|
||||
import android.widget.RelativeLayout
|
||||
@ -30,6 +31,7 @@ import org.session.libsession.messaging.contacts.Contact
|
||||
import org.session.libsession.messaging.mentions.MentionsManager
|
||||
import org.session.libsession.messaging.open_groups.OpenGroupAPIV2
|
||||
import org.session.libsession.utilities.TextSecurePreferences
|
||||
import org.session.libsession.utilities.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.ApplicationContext
|
||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||
import org.thoughtcrime.securesms.conversation.v2.dialogs.*
|
||||
@ -47,8 +49,10 @@ import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||
import org.thoughtcrime.securesms.linkpreview.LinkPreviewRepository
|
||||
import org.thoughtcrime.securesms.linkpreview.LinkPreviewViewModel
|
||||
import org.thoughtcrime.securesms.linkpreview.LinkPreviewViewModel.LinkPreviewState
|
||||
import org.thoughtcrime.securesms.loki.protocol.SessionMetaProtocol.shouldSendReadReceipt
|
||||
import org.thoughtcrime.securesms.loki.utilities.toPx
|
||||
import org.thoughtcrime.securesms.mms.GlideApp
|
||||
import org.thoughtcrime.securesms.notifications.MarkReadReceiver
|
||||
import org.thoughtcrime.securesms.util.DateUtils
|
||||
import java.util.*
|
||||
import kotlin.math.*
|
||||
@ -130,7 +134,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
getLatestOpenGroupInfoIfNeeded()
|
||||
setUpBlockedBanner()
|
||||
setUpLinkPreviewObserver()
|
||||
scrollToFirstUnreadMessage()
|
||||
scrollToFirstUnreadMessageIfNeeded()
|
||||
markAllAsRead()
|
||||
}
|
||||
|
||||
@ -244,9 +248,10 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
})
|
||||
}
|
||||
|
||||
private fun scrollToFirstUnreadMessage() {
|
||||
private fun scrollToFirstUnreadMessageIfNeeded() {
|
||||
val lastSeenTimestamp = DatabaseFactory.getThreadDatabase(this).getLastSeenAndHasSent(threadID).first()
|
||||
val lastSeenItemPosition = adapter.findLastSeenItemPosition(lastSeenTimestamp) ?: return
|
||||
if (lastSeenItemPosition <= 3) { return }
|
||||
conversationRecyclerView.scrollToPosition(lastSeenItemPosition)
|
||||
}
|
||||
|
||||
@ -264,7 +269,15 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
|
||||
// region Updating & Animation
|
||||
private fun markAllAsRead() {
|
||||
DatabaseFactory.getThreadDatabase(this).setRead(threadID, true)
|
||||
val messages = DatabaseFactory.getThreadDatabase(this).setRead(threadID, true)
|
||||
if (thread.isGroupRecipient) {
|
||||
for (message in messages) {
|
||||
MarkReadReceiver.scheduleDeletion(this, message.expirationInfo)
|
||||
}
|
||||
} else {
|
||||
MarkReadReceiver.process(this, messages)
|
||||
}
|
||||
ApplicationContext.getInstance(this).messageNotifier.updateNotification(this)
|
||||
}
|
||||
|
||||
override fun inputBarHeightChanged(newValue: Int) {
|
||||
|
@ -81,7 +81,6 @@ public class MarkReadReceiver extends BroadcastReceiver {
|
||||
|
||||
for (Address address : addressMap.keySet()) {
|
||||
List<Long> timestamps = Stream.of(addressMap.get(address)).map(SyncMessageId::getTimetamp).toList();
|
||||
// Loki - Check whether we want to send a read receipt to this user
|
||||
if (!SessionMetaProtocol.shouldSendReadReceipt(address)) { continue; }
|
||||
ReadReceipt readReceipt = new ReadReceipt(timestamps);
|
||||
readReceipt.setSentTimestamp(System.currentTimeMillis());
|
||||
|
@ -9,6 +9,7 @@ import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId
|
||||
|
||||
class ReadReceiptManager: SSKEnvironment.ReadReceiptManagerProtocol {
|
||||
|
||||
override fun processReadReceipts(context: Context, fromRecipientId: String, sentTimestamps: List<Long>, readTimestamp: Long) {
|
||||
if (TextSecurePreferences.isReadReceiptsEnabled(context)) {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user