From 003fa1b05980d07fa1122edcd12ef73dca1f1290 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Fri, 1 Mar 2019 18:14:47 -0800 Subject: [PATCH] Make long text attachments contain the entire message. Instead of just containing the 'overflow', long text attachments now contain the entire body in full. --- .../securesms/conversation/ConversationActivity.java | 10 +++++----- .../securesms/conversation/ConversationFragment.java | 4 ++-- .../securesms/longmessage/LongMessage.java | 10 ++++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java index e23679e838..a90f4e773d 100644 --- a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java @@ -1968,20 +1968,20 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity private Pair> getSplitMessage(String rawText, int maxPrimaryMessageSize) { String bodyText = rawText; - Optional extraText = Optional.absent(); + Optional textSlide = Optional.absent(); if (bodyText.length() > maxPrimaryMessageSize) { bodyText = rawText.substring(0, maxPrimaryMessageSize); - byte[] extraData = rawText.substring(maxPrimaryMessageSize).getBytes(); - Uri textUri = MemoryBlobProvider.getInstance().createUri(extraData); + byte[] textData = rawText.getBytes(); + Uri textUri = MemoryBlobProvider.getInstance().createUri(textData); String timestamp = new SimpleDateFormat("yyyy-MM-dd-HHmmss", Locale.US).format(new Date()); String filename = String.format("signal-%s.txt", timestamp); - extraText = Optional.of(new TextSlide(this, textUri, filename, extraData.length)); + textSlide = Optional.of(new TextSlide(this, textUri, filename, textData.length)); } - return new Pair<>(bodyText, extraText); + return new Pair<>(bodyText, textSlide); } private MediaConstraints getCurrentMediaConstraints() { diff --git a/src/org/thoughtcrime/securesms/conversation/ConversationFragment.java b/src/org/thoughtcrime/securesms/conversation/ConversationFragment.java index 1dceaa181c..939efb8850 100644 --- a/src/org/thoughtcrime/securesms/conversation/ConversationFragment.java +++ b/src/org/thoughtcrime/securesms/conversation/ConversationFragment.java @@ -564,8 +564,8 @@ public class ConversationFragment extends Fragment if (mediaMessage.getSlideDeck().getTextSlide() != null && mediaMessage.getSlideDeck().getTextSlide().getUri() != null) { try (InputStream stream = PartAuthority.getAttachmentStream(requireContext(), mediaMessage.getSlideDeck().getTextSlide().getUri())) { - String extraText = Util.readFullyAsString(stream); - composeIntent.putExtra(Intent.EXTRA_TEXT, message.getDisplayBody().toString() + extraText); + String fullBody = Util.readFullyAsString(stream); + composeIntent.putExtra(Intent.EXTRA_TEXT, fullBody); } catch (IOException e) { Log.w(TAG, "Failed to read long message text when forwarding."); } diff --git a/src/org/thoughtcrime/securesms/longmessage/LongMessage.java b/src/org/thoughtcrime/securesms/longmessage/LongMessage.java index 4e2c8c1219..7369405d11 100644 --- a/src/org/thoughtcrime/securesms/longmessage/LongMessage.java +++ b/src/org/thoughtcrime/securesms/longmessage/LongMessage.java @@ -1,5 +1,7 @@ package org.thoughtcrime.securesms.longmessage; +import android.text.TextUtils; + import org.thoughtcrime.securesms.database.model.MessageRecord; /** @@ -9,11 +11,11 @@ import org.thoughtcrime.securesms.database.model.MessageRecord; class LongMessage { private final MessageRecord messageRecord; - private final String extraBody; + private final String fullBody; - LongMessage(MessageRecord messageRecord, String extraBody) { + LongMessage(MessageRecord messageRecord, String fullBody) { this.messageRecord = messageRecord; - this.extraBody = extraBody; + this.fullBody = fullBody; } MessageRecord getMessageRecord() { @@ -21,6 +23,6 @@ class LongMessage { } String getFullBody() { - return messageRecord.getBody() + extraBody; + return !TextUtils.isEmpty(fullBody) ? fullBody : messageRecord.getBody(); } }