diff options
Diffstat (limited to 'src/main/java/eu/siacs/conversations/entities/Message.java')
-rw-r--r-- | src/main/java/eu/siacs/conversations/entities/Message.java | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Message.java b/src/main/java/eu/siacs/conversations/entities/Message.java index 9a52e8c7..821eea39 100644 --- a/src/main/java/eu/siacs/conversations/entities/Message.java +++ b/src/main/java/eu/siacs/conversations/entities/Message.java @@ -2,6 +2,7 @@ package eu.siacs.conversations.entities; import android.content.ContentValues; import android.database.Cursor; +import android.text.SpannableStringBuilder; import java.net.MalformedURLException; import java.net.URL; @@ -19,8 +20,6 @@ public class Message extends AbstractEntity { public static final String TABLENAME = "messages"; - public static final String MERGE_SEPARATOR = "\n\u200B\n"; - public static final int STATUS_RECEIVED = 0; public static final int STATUS_UNSEND = 1; public static final int STATUS_SEND = 2; @@ -491,22 +490,26 @@ public class Message extends AbstractEntity { ); } - public String getMergedBody() { - StringBuilder body = new StringBuilder(this.body.trim()); + public static class MergeSeparator {} + + public SpannableStringBuilder getMergedBody() { + SpannableStringBuilder body = new SpannableStringBuilder(this.body.trim()); Message current = this; - while(current.mergeable(current.next())) { + while (current.mergeable(current.next())) { current = current.next(); if (current == null) { break; } - body.append(MERGE_SEPARATOR); + body.append("\n\n"); + body.setSpan(new MergeSeparator(), body.length() - 2, body.length(), + SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE); body.append(current.getBody().trim()); } - return body.toString(); + return body; } public boolean hasMeCommand() { - return getMergedBody().startsWith(ME_COMMAND); + return this.body.trim().startsWith(ME_COMMAND); } public int getMergedStatus() { @@ -592,7 +595,7 @@ public class Message extends AbstractEntity { if (path == null || path.isEmpty()) { return null; } - + String filename = path.substring(path.lastIndexOf('/') + 1).toLowerCase(); int dotPosition = filename.lastIndexOf("."); |