fix multiline reply quote

This commit is contained in:
kosyak 2024-02-14 18:18:16 +01:00
parent 7db4435e7c
commit 6c8d9c30ab

View file

@ -842,7 +842,7 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
public SpannableStringBuilder getBodyForDisplaying() { public SpannableStringBuilder getBodyForDisplaying() {
if (replyMessage != null) { if (replyMessage != null) {
try { try {
return new SpannableStringBuilder(MessageUtils.filterLtrRtl(">" + removeReplyFallback(replyMessage) + "\n" + removeReplyFallback(this)).trim()); return new SpannableStringBuilder(MessageUtils.filterLtrRtl(getReplyText(replyMessage) + "\n" + removeReplyFallback(this)).trim());
} catch (IndexOutOfBoundsException e) { } catch (IndexOutOfBoundsException e) {
return new SpannableStringBuilder(MessageUtils.filterLtrRtl(this.body).trim()); return new SpannableStringBuilder(MessageUtils.filterLtrRtl(this.body).trim());
} }
@ -853,12 +853,26 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
public SpannableStringBuilder getBodyForReplyPreview() { public SpannableStringBuilder getBodyForReplyPreview() {
try { try {
return new SpannableStringBuilder(MessageUtils.filterLtrRtl(">" + removeReplyFallback(this)).trim()); return new SpannableStringBuilder(MessageUtils.filterLtrRtl(getReplyText(this).toString()).trim());
} catch (IndexOutOfBoundsException e) { } catch (IndexOutOfBoundsException e) {
return new SpannableStringBuilder(MessageUtils.filterLtrRtl(this.body).trim()); return new SpannableStringBuilder(MessageUtils.filterLtrRtl(this.body).trim());
} }
} }
private StringBuilder getReplyText(Message message) {
StringBuilder reply = removeReplyFallback(message);
reply.insert(0, '>');
for (int i=0;i<reply.length();i++) {
char c = reply.charAt(i);
if (c == '\n') {
reply.insert(i+1, ">");
i++;
}
}
return reply;
}
private StringBuilder removeReplyFallback(Message message) { private StringBuilder removeReplyFallback(Message message) {
StringBuilder sb = new StringBuilder(message.body); StringBuilder sb = new StringBuilder(message.body);