Add text formatting send and receive support for conversations.

This commit is contained in:
Cody Henthorne
2023-01-25 10:31:36 -05:00
committed by Greyson Parrelli
parent aa2075c78f
commit cc490f4b73
73 changed files with 1664 additions and 516 deletions

View File

@@ -90,6 +90,7 @@ class IncomingMediaMessage(
isPaymentsActivated = paymentsActivated
)
@JvmOverloads
constructor(
from: RecipientId?,
sentTimeMillis: Long,
@@ -114,7 +115,8 @@ class IncomingMediaMessage(
serverGuid: String?,
giftBadge: GiftBadge?,
activatePaymentsRequest: Boolean,
paymentsActivated: Boolean
paymentsActivated: Boolean,
messageRanges: BodyRangeList? = null
) : this(
from = from,
groupId = if (group.isPresent) GroupId.v2(group.get().masterKey) else null,
@@ -139,7 +141,8 @@ class IncomingMediaMessage(
mentions = mentions.orElse(emptyList()),
giftBadge = giftBadge,
isActivatePaymentsRequest = activatePaymentsRequest,
isPaymentsActivated = paymentsActivated
isPaymentsActivated = paymentsActivated,
messageRanges = messageRanges
)
companion object {

View File

@@ -8,6 +8,7 @@ import org.thoughtcrime.securesms.database.documents.NetworkFailure
import org.thoughtcrime.securesms.database.model.Mention
import org.thoughtcrime.securesms.database.model.ParentStoryId
import org.thoughtcrime.securesms.database.model.StoryType
import org.thoughtcrime.securesms.database.model.databaseprotos.BodyRangeList
import org.thoughtcrime.securesms.database.model.databaseprotos.DecryptedGroupV2Context
import org.thoughtcrime.securesms.database.model.databaseprotos.GiftBadge
import org.thoughtcrime.securesms.linkpreview.LinkPreview
@@ -34,6 +35,7 @@ data class OutgoingMessage(
val attachments: List<Attachment> = emptyList(),
val sharedContacts: List<Contact> = emptyList(),
val linkPreviews: List<LinkPreview> = emptyList(),
val bodyRanges: BodyRangeList? = null,
val mentions: List<Mention> = emptyList(),
val isGroup: Boolean = false,
val isGroupUpdate: Boolean = false,
@@ -75,7 +77,8 @@ data class OutgoingMessage(
networkFailures: Set<NetworkFailure> = emptySet(),
mismatches: Set<IdentityKeyMismatch> = emptySet(),
giftBadge: GiftBadge? = null,
isSecure: Boolean = false
isSecure: Boolean = false,
bodyRanges: BodyRangeList? = null
) : this(
recipient = recipient,
body = body ?: "",
@@ -95,7 +98,8 @@ data class OutgoingMessage(
networkFailures = networkFailures,
identityKeyMismatches = mismatches,
giftBadge = giftBadge,
isSecure = isSecure
isSecure = isSecure,
bodyRanges = bodyRanges
)
/**
@@ -112,7 +116,8 @@ data class OutgoingMessage(
storyType: StoryType = StoryType.NONE,
linkPreviews: List<LinkPreview> = emptyList(),
mentions: List<Mention> = emptyList(),
isSecure: Boolean = false
isSecure: Boolean = false,
bodyRanges: BodyRangeList? = null
) : this(
recipient = recipient,
body = buildMessage(slideDeck, body ?: ""),
@@ -124,7 +129,8 @@ data class OutgoingMessage(
storyType = storyType,
linkPreviews = linkPreviews,
mentions = mentions,
isSecure = isSecure
isSecure = isSecure,
bodyRanges = bodyRanges
)
fun withExpiry(expiresIn: Long): OutgoingMessage {
@@ -167,14 +173,21 @@ data class OutgoingMessage(
* A secure message that only contains text.
*/
@JvmStatic
fun text(recipient: Recipient, body: String, expiresIn: Long, sentTimeMillis: Long = System.currentTimeMillis()): OutgoingMessage {
fun text(
recipient: Recipient,
body: String,
expiresIn: Long,
sentTimeMillis: Long = System.currentTimeMillis(),
bodyRanges: BodyRangeList? = null
): OutgoingMessage {
return OutgoingMessage(
recipient = recipient,
sentTimeMillis = sentTimeMillis,
body = body,
expiresIn = expiresIn,
isUrgent = true,
isSecure = true
isSecure = true,
bodyRanges = bodyRanges
)
}
@@ -239,7 +252,8 @@ data class OutgoingMessage(
body: String,
sentTimeMillis: Long,
storyType: StoryType,
linkPreviews: List<LinkPreview>
linkPreviews: List<LinkPreview>,
bodyRanges: BodyRangeList?
): OutgoingMessage {
return OutgoingMessage(
recipient = recipient,
@@ -247,6 +261,7 @@ data class OutgoingMessage(
sentTimeMillis = sentTimeMillis,
storyType = storyType,
linkPreviews = linkPreviews,
bodyRanges = bodyRanges,
isSecure = true
)
}

View File

@@ -6,6 +6,7 @@ import androidx.annotation.Nullable;
import org.thoughtcrime.securesms.attachments.Attachment;
import org.thoughtcrime.securesms.database.model.Mention;
import org.thoughtcrime.securesms.database.model.databaseprotos.BodyRangeList;
import org.thoughtcrime.securesms.recipients.RecipientId;
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
@@ -21,6 +22,7 @@ public class QuoteModel {
private final List<Attachment> attachments;
private final List<Mention> mentions;
private final Type type;
private final BodyRangeList bodyRanges;
public QuoteModel(long id,
@NonNull RecipientId author,
@@ -28,7 +30,8 @@ public class QuoteModel {
boolean missing,
@Nullable List<Attachment> attachments,
@Nullable List<Mention> mentions,
@NonNull Type type)
@NonNull Type type,
@Nullable BodyRangeList bodyRanges)
{
this.id = id;
this.author = author;
@@ -37,6 +40,7 @@ public class QuoteModel {
this.attachments = attachments;
this.mentions = mentions != null ? mentions : Collections.emptyList();
this.type = type;
this.bodyRanges = bodyRanges;
}
public long getId() {
@@ -67,6 +71,10 @@ public class QuoteModel {
return type;
}
public @Nullable BodyRangeList getBodyRanges() {
return bodyRanges;
}
public enum Type {
NORMAL(0, SignalServiceDataMessage.Quote.Type.NORMAL),
GIFT_BADGE(1, SignalServiceDataMessage.Quote.Type.GIFT_BADGE);