mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 20:48:43 +00:00
Allow long text to be sent via notification replies.
This commit is contained in:
committed by
Michelle Tang
parent
5bce2884a7
commit
acbab9e736
@@ -15,6 +15,7 @@ import org.thoughtcrime.securesms.database.model.databaseprotos.MessageExtras
|
|||||||
import org.thoughtcrime.securesms.linkpreview.LinkPreview
|
import org.thoughtcrime.securesms.linkpreview.LinkPreview
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient
|
import org.thoughtcrime.securesms.recipients.Recipient
|
||||||
import org.thoughtcrime.securesms.sms.GroupV2UpdateMessageUtil
|
import org.thoughtcrime.securesms.sms.GroupV2UpdateMessageUtil
|
||||||
|
import kotlin.time.Duration.Companion.seconds
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents all the data needed for an outgoing message.
|
* Represents all the data needed for an outgoing message.
|
||||||
@@ -469,6 +470,24 @@ data class OutgoingMessage(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun quickReply(
|
||||||
|
threadRecipient: Recipient,
|
||||||
|
slideDeck: SlideDeck?,
|
||||||
|
body: String,
|
||||||
|
parentStoryId: ParentStoryId?
|
||||||
|
): OutgoingMessage {
|
||||||
|
return OutgoingMessage(
|
||||||
|
threadRecipient = threadRecipient,
|
||||||
|
sentTimeMillis = System.currentTimeMillis(),
|
||||||
|
expiresIn = threadRecipient.expiresInSeconds.seconds.inWholeMilliseconds,
|
||||||
|
attachments = slideDeck?.asAttachments() ?: emptyList(),
|
||||||
|
body = body,
|
||||||
|
parentStoryId = parentStoryId,
|
||||||
|
isSecure = true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun buildMessage(slideDeck: SlideDeck, message: String): String {
|
fun buildMessage(slideDeck: SlideDeck, message: String): String {
|
||||||
return if (message.isNotEmpty() && slideDeck.body.isNotEmpty()) {
|
return if (message.isNotEmpty() && slideDeck.body.isNotEmpty()) {
|
||||||
|
|||||||
@@ -29,19 +29,17 @@ import org.signal.core.util.concurrent.SignalExecutors;
|
|||||||
import org.thoughtcrime.securesms.database.MessageTable.MarkedMessageInfo;
|
import org.thoughtcrime.securesms.database.MessageTable.MarkedMessageInfo;
|
||||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||||
import org.thoughtcrime.securesms.database.model.ParentStoryId;
|
import org.thoughtcrime.securesms.database.model.ParentStoryId;
|
||||||
import org.thoughtcrime.securesms.database.model.StoryType;
|
|
||||||
import org.thoughtcrime.securesms.dependencies.AppDependencies;
|
import org.thoughtcrime.securesms.dependencies.AppDependencies;
|
||||||
import org.thoughtcrime.securesms.mms.OutgoingMessage;
|
import org.thoughtcrime.securesms.mms.OutgoingMessage;
|
||||||
import org.thoughtcrime.securesms.notifications.v2.DefaultMessageNotifier;
|
import org.thoughtcrime.securesms.mms.SlideDeck;
|
||||||
import org.thoughtcrime.securesms.notifications.v2.ConversationId;
|
import org.thoughtcrime.securesms.notifications.v2.ConversationId;
|
||||||
|
import org.thoughtcrime.securesms.notifications.v2.DefaultMessageNotifier;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||||
import org.thoughtcrime.securesms.sms.MessageSender;
|
import org.thoughtcrime.securesms.sms.MessageSender;
|
||||||
|
import org.thoughtcrime.securesms.util.MessageUtil;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the response text from the Wearable Device and sends an message as a reply
|
* Get the response text from the Wearable Device and sends an message as a reply
|
||||||
@@ -75,40 +73,25 @@ public class RemoteReplyReceiver extends BroadcastReceiver {
|
|||||||
SignalExecutors.BOUNDED.execute(() -> {
|
SignalExecutors.BOUNDED.execute(() -> {
|
||||||
long threadId;
|
long threadId;
|
||||||
|
|
||||||
Recipient recipient = Recipient.resolved(recipientId);
|
Recipient recipient = Recipient.resolved(recipientId);
|
||||||
long expiresIn = TimeUnit.SECONDS.toMillis(recipient.getExpiresInSeconds());
|
String body = responseText.toString();
|
||||||
int expireTimerVersion = recipient.getExpireTimerVersion();
|
ParentStoryId parentStoryId = groupStoryId != Long.MIN_VALUE ? ParentStoryId.deserialize(groupStoryId) : null;
|
||||||
ParentStoryId parentStoryId = groupStoryId != Long.MIN_VALUE ? ParentStoryId.deserialize(groupStoryId) : null;
|
MessageUtil.SplitResult splitMessage = MessageUtil.getSplitMessage(context, body);
|
||||||
|
SlideDeck slideDeck = null;
|
||||||
|
|
||||||
|
if (splitMessage.getTextSlide().isPresent()) {
|
||||||
|
slideDeck = new SlideDeck();
|
||||||
|
slideDeck.addSlide(splitMessage.getTextSlide().get());
|
||||||
|
}
|
||||||
|
|
||||||
switch (replyMethod) {
|
switch (replyMethod) {
|
||||||
|
case SecureMessage:
|
||||||
case GroupMessage: {
|
case GroupMessage: {
|
||||||
OutgoingMessage reply = new OutgoingMessage(recipient,
|
OutgoingMessage reply = OutgoingMessage.quickReply(recipient,
|
||||||
responseText.toString(),
|
slideDeck,
|
||||||
new LinkedList<>(),
|
splitMessage.getBody(),
|
||||||
System.currentTimeMillis(),
|
parentStoryId);
|
||||||
expiresIn,
|
|
||||||
expireTimerVersion,
|
|
||||||
false,
|
|
||||||
0,
|
|
||||||
StoryType.NONE,
|
|
||||||
parentStoryId,
|
|
||||||
false,
|
|
||||||
null,
|
|
||||||
Collections.emptyList(),
|
|
||||||
Collections.emptyList(),
|
|
||||||
Collections.emptyList(),
|
|
||||||
Collections.emptySet(),
|
|
||||||
Collections.emptySet(),
|
|
||||||
null,
|
|
||||||
recipient.isPushGroup(),
|
|
||||||
null,
|
|
||||||
-1,
|
|
||||||
0);
|
|
||||||
threadId = MessageSender.send(context, reply, -1, MessageSender.SendType.SIGNAL, null, null);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SecureMessage: {
|
|
||||||
OutgoingMessage reply = OutgoingMessage.text(recipient, responseText.toString(), expiresIn, System.currentTimeMillis(), null);
|
|
||||||
threadId = MessageSender.send(context, reply, -1, MessageSender.SendType.SIGNAL, null, null);
|
threadId = MessageSender.send(context, reply, -1, MessageSender.SendType.SIGNAL, null, null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user