Add message editing feature.

This commit is contained in:
Clark
2023-04-14 16:29:26 -04:00
committed by Cody Henthorne
parent 4f06a0d27c
commit 07f6baf7c1
73 changed files with 2051 additions and 304 deletions

View File

@@ -50,11 +50,13 @@ data class OutgoingMessage(
val isEndSession: Boolean = false,
val isIdentityVerified: Boolean = false,
val isIdentityDefault: Boolean = false,
val scheduledDate: Long = -1
val scheduledDate: Long = -1,
val messageToEdit: Long = 0
) {
val isV2Group: Boolean = messageGroupContext != null && GroupV2UpdateMessageUtil.isGroupV2(messageGroupContext)
val isJustAGroupLeave: Boolean = messageGroupContext != null && GroupV2UpdateMessageUtil.isJustAGroupLeave(messageGroupContext)
val isMessageEdit: Boolean = messageToEdit != 0L
/**
* Smaller constructor for calling from Java and legacy code using the original interface.
@@ -80,7 +82,8 @@ data class OutgoingMessage(
giftBadge: GiftBadge? = null,
isSecure: Boolean = false,
bodyRanges: BodyRangeList? = null,
scheduledDate: Long = -1
scheduledDate: Long = -1,
messageToEdit: Long = 0
) : this(
threadRecipient = recipient,
body = body ?: "",
@@ -102,7 +105,8 @@ data class OutgoingMessage(
giftBadge = giftBadge,
isSecure = isSecure,
bodyRanges = bodyRanges,
scheduledDate = scheduledDate
scheduledDate = scheduledDate,
messageToEdit = messageToEdit
)
/**
@@ -200,6 +204,28 @@ data class OutgoingMessage(
)
}
/**
* Edit a secure message that only contains text.
*/
@JvmStatic
fun editText(
recipient: Recipient,
body: String,
sentTimeMillis: Long,
bodyRanges: BodyRangeList?,
messageToEdit: Long
): OutgoingMessage {
return OutgoingMessage(
threadRecipient = recipient,
sentTimeMillis = sentTimeMillis,
body = body,
isUrgent = true,
isSecure = true,
bodyRanges = bodyRanges,
messageToEdit = messageToEdit
)
}
/**
* Helper for creating a group update message when a state change occurs and needs to be sent to others.
*/