kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix issue where forwarded link preview would overwrite original message id.
rodzic
87c024e968
commit
ff7dcd26c8
|
@ -17,11 +17,11 @@ import org.signal.core.util.ThreadUtil;
|
||||||
import org.signal.core.util.concurrent.SimpleTask;
|
import org.signal.core.util.concurrent.SimpleTask;
|
||||||
import org.signal.core.util.logging.Log;
|
import org.signal.core.util.logging.Log;
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.thoughtcrime.securesms.attachments.Attachment;
|
||||||
|
import org.thoughtcrime.securesms.attachments.UriAttachment;
|
||||||
import org.thoughtcrime.securesms.contacts.paged.ContactSearchKey;
|
import org.thoughtcrime.securesms.contacts.paged.ContactSearchKey;
|
||||||
import org.thoughtcrime.securesms.conversation.MessageSendType;
|
import org.thoughtcrime.securesms.conversation.MessageSendType;
|
||||||
import org.thoughtcrime.securesms.conversation.colors.ChatColors;
|
import org.thoughtcrime.securesms.conversation.colors.ChatColors;
|
||||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
|
||||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||||
import org.thoughtcrime.securesms.database.model.Mention;
|
import org.thoughtcrime.securesms.database.model.Mention;
|
||||||
|
@ -67,7 +67,7 @@ import java.util.stream.Collectors;
|
||||||
/**
|
/**
|
||||||
* MultiShareSender encapsulates send logic (stolen from {@link org.thoughtcrime.securesms.conversation.ConversationActivity}
|
* MultiShareSender encapsulates send logic (stolen from {@link org.thoughtcrime.securesms.conversation.ConversationActivity}
|
||||||
* and provides a means to:
|
* and provides a means to:
|
||||||
*
|
* <p>
|
||||||
* 1. Send messages based off a {@link MultiShareArgs} object and
|
* 1. Send messages based off a {@link MultiShareArgs} object and
|
||||||
* 1. Parse through the result of the send via a {@link MultiShareSendResultCollection}
|
* 1. Parse through the result of the send via a {@link MultiShareSendResultCollection}
|
||||||
*/
|
*/
|
||||||
|
@ -255,14 +255,13 @@ public final class MultiShareSender {
|
||||||
false,
|
false,
|
||||||
null,
|
null,
|
||||||
Collections.emptyList(),
|
Collections.emptyList(),
|
||||||
multiShareArgs.getLinkPreview() != null ? Collections.singletonList(multiShareArgs.getLinkPreview())
|
buildLinkPreviews(context, multiShareArgs.getLinkPreview()),
|
||||||
: Collections.emptyList(),
|
|
||||||
Collections.emptyList(),
|
Collections.emptyList(),
|
||||||
null);
|
null);
|
||||||
|
|
||||||
outgoingMessages.add(outgoingMediaMessage);
|
outgoingMessages.add(outgoingMediaMessage);
|
||||||
} else if (canSendAsTextStory) {
|
} else if (canSendAsTextStory) {
|
||||||
outgoingMessages.add(generateTextStory(recipient, multiShareArgs, sentTimestamp, storyType, generatedTextStoryBackgroundColor));
|
outgoingMessages.add(generateTextStory(context, recipient, multiShareArgs, sentTimestamp, storyType, generatedTextStoryBackgroundColor));
|
||||||
} else {
|
} else {
|
||||||
List<Slide> storySupportedSlides = slideDeck.getSlides()
|
List<Slide> storySupportedSlides = slideDeck.getSlides()
|
||||||
.stream()
|
.stream()
|
||||||
|
@ -316,8 +315,7 @@ public final class MultiShareSender {
|
||||||
false,
|
false,
|
||||||
null,
|
null,
|
||||||
Collections.emptyList(),
|
Collections.emptyList(),
|
||||||
multiShareArgs.getLinkPreview() != null ? Collections.singletonList(multiShareArgs.getLinkPreview())
|
buildLinkPreviews(context, multiShareArgs.getLinkPreview()),
|
||||||
: Collections.emptyList(),
|
|
||||||
validatedMentions,
|
validatedMentions,
|
||||||
null);
|
null);
|
||||||
|
|
||||||
|
@ -351,6 +349,32 @@ public final class MultiShareSender {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static List<LinkPreview> buildLinkPreviews(@NonNull Context context, @Nullable LinkPreview linkPreview) {
|
||||||
|
if (linkPreview == null) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
} else {
|
||||||
|
return Collections.singletonList(new LinkPreview(
|
||||||
|
linkPreview.getUrl(),
|
||||||
|
linkPreview.getTitle(),
|
||||||
|
linkPreview.getDescription(),
|
||||||
|
linkPreview.getDate(),
|
||||||
|
linkPreview.getThumbnail().map(thumbnail ->
|
||||||
|
thumbnail instanceof UriAttachment ? thumbnail
|
||||||
|
: new ImageSlide(context,
|
||||||
|
thumbnail.getUri(),
|
||||||
|
thumbnail.getContentType(),
|
||||||
|
thumbnail.getSize(),
|
||||||
|
thumbnail.getWidth(),
|
||||||
|
thumbnail.getHeight(),
|
||||||
|
thumbnail.isBorderless(),
|
||||||
|
thumbnail.getCaption(),
|
||||||
|
thumbnail.getBlurHash(),
|
||||||
|
thumbnail.getTransformProperties()).asAttachment()
|
||||||
|
)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Slide ensureDefaultQuality(@NonNull Context context, @NonNull ImageSlide imageSlide) {
|
private static Slide ensureDefaultQuality(@NonNull Context context, @NonNull ImageSlide imageSlide) {
|
||||||
Attachment attachment = imageSlide.asAttachment();
|
Attachment attachment = imageSlide.asAttachment();
|
||||||
if (attachment.getTransformProperties().getSentMediaQuality() == SentMediaQuality.HIGH.getCode()) {
|
if (attachment.getTransformProperties().getSentMediaQuality() == SentMediaQuality.HIGH.getCode()) {
|
||||||
|
@ -390,7 +414,8 @@ public final class MultiShareSender {
|
||||||
MessageSender.send(context, outgoingTextMessage, threadId, forceSms, null, null);
|
MessageSender.send(context, outgoingTextMessage, threadId, forceSms, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static @NonNull OutgoingMediaMessage generateTextStory(@NonNull Recipient recipient,
|
private static @NonNull OutgoingMediaMessage generateTextStory(@NonNull Context context,
|
||||||
|
@NonNull Recipient recipient,
|
||||||
@NonNull MultiShareArgs multiShareArgs,
|
@NonNull MultiShareArgs multiShareArgs,
|
||||||
long sentTimestamp,
|
long sentTimestamp,
|
||||||
@NonNull StoryType storyType,
|
@NonNull StoryType storyType,
|
||||||
|
@ -417,8 +442,7 @@ public final class MultiShareSender {
|
||||||
false,
|
false,
|
||||||
null,
|
null,
|
||||||
Collections.emptyList(),
|
Collections.emptyList(),
|
||||||
multiShareArgs.getLinkPreview() != null ? Collections.singletonList(multiShareArgs.getLinkPreview())
|
buildLinkPreviews(context, multiShareArgs.getLinkPreview()),
|
||||||
: Collections.emptyList(),
|
|
||||||
Collections.emptyList(),
|
Collections.emptyList(),
|
||||||
Collections.emptySet(),
|
Collections.emptySet(),
|
||||||
Collections.emptySet(),
|
Collections.emptySet(),
|
||||||
|
|
Ładowanie…
Reference in New Issue