Revert "Revert "fix reply text handling""
This reverts commit 705cc33347
.
This commit is contained in:
parent
705cc33347
commit
162b0bf928
|
@ -841,7 +841,7 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
|
|||
public SpannableStringBuilder getBodyForDisplaying() {
|
||||
if (replyMessage != null) {
|
||||
try {
|
||||
return new SpannableStringBuilder(MessageUtils.filterLtrRtl(getReplyText(replyMessage) + "\n" + removeReplyFallback(this)).trim());
|
||||
return new SpannableStringBuilder(MessageUtils.filterLtrRtl(getReplyText(replyMessage) + "\n" + removeReplyFallback(this, replyMessage)).trim());
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
return new SpannableStringBuilder(MessageUtils.filterLtrRtl(this.body).trim());
|
||||
}
|
||||
|
@ -859,7 +859,7 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
|
|||
}
|
||||
|
||||
private StringBuilder getReplyText(Message message) {
|
||||
StringBuilder reply = removeReplyFallback(message);
|
||||
StringBuilder reply = removeReplyFallback(message, message.replyMessage);
|
||||
reply.insert(0, '>');
|
||||
for (int i=0;i<reply.length();i++) {
|
||||
char c = reply.charAt(i);
|
||||
|
@ -872,11 +872,14 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
|
|||
return reply;
|
||||
}
|
||||
|
||||
private StringBuilder removeReplyFallback(Message message) {
|
||||
private StringBuilder removeReplyFallback(Message message, Message replyMessage) {
|
||||
StringBuilder sb = new StringBuilder(message.body);
|
||||
|
||||
if (replyMessage != null && replyMessage.edits.isEmpty()) {
|
||||
sb.replace(0, replyMessage.body.codePointCount(0, replyMessage.body.length()) + 3, "");
|
||||
} else {
|
||||
List<Element> replyFallback = message.getFallbacks("urn:xmpp:reply:0");
|
||||
if (replyFallback.size() == 0) {
|
||||
if (replyFallback.isEmpty()) {
|
||||
return sb;
|
||||
}
|
||||
|
||||
|
@ -888,6 +891,8 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
|
|||
if (endCodePoint > sb.length()) return sb;
|
||||
|
||||
sb.replace(message.body.offsetByCodePoints(0, startCodePoint), message.body.offsetByCodePoints(0, endCodePoint), "");
|
||||
}
|
||||
|
||||
return sb;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue