parent
888ed9643f
commit
705cc33347
|
@ -841,7 +841,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(getReplyText(replyMessage) + "\n" + removeReplyFallback(this, replyMessage)).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());
|
||||||
}
|
}
|
||||||
|
@ -859,7 +859,7 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
|
||||||
}
|
}
|
||||||
|
|
||||||
private StringBuilder getReplyText(Message message) {
|
private StringBuilder getReplyText(Message message) {
|
||||||
StringBuilder reply = removeReplyFallback(message, message.replyMessage);
|
StringBuilder reply = removeReplyFallback(message);
|
||||||
reply.insert(0, '>');
|
reply.insert(0, '>');
|
||||||
for (int i=0;i<reply.length();i++) {
|
for (int i=0;i<reply.length();i++) {
|
||||||
char c = reply.charAt(i);
|
char c = reply.charAt(i);
|
||||||
|
@ -872,27 +872,22 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
private StringBuilder removeReplyFallback(Message message, Message replyMessage) {
|
private StringBuilder removeReplyFallback(Message message) {
|
||||||
StringBuilder sb = new StringBuilder(message.body);
|
StringBuilder sb = new StringBuilder(message.body);
|
||||||
|
|
||||||
if (replyMessage != null && replyMessage.edits.isEmpty()) {
|
List<Element> replyFallback = message.getFallbacks("urn:xmpp:reply:0");
|
||||||
sb.replace(0, replyMessage.body.codePointCount(0, replyMessage.body.length()) + 3, "");
|
if (replyFallback.size() == 0) {
|
||||||
} else {
|
return sb;
|
||||||
List<Element> replyFallback = message.getFallbacks("urn:xmpp:reply:0");
|
|
||||||
if (replyFallback.isEmpty()) {
|
|
||||||
return sb;
|
|
||||||
}
|
|
||||||
|
|
||||||
Element bodyFallback = replyFallback.get(0).findChild("body");
|
|
||||||
int startCodePoint = Integer.parseInt(bodyFallback.getAttribute("start"));
|
|
||||||
int endCodePoint = Integer.parseInt(bodyFallback.getAttribute("end"));
|
|
||||||
|
|
||||||
if (startCodePoint < 0) return sb;
|
|
||||||
if (endCodePoint > sb.length()) return sb;
|
|
||||||
|
|
||||||
sb.replace(message.body.offsetByCodePoints(0, startCodePoint), message.body.offsetByCodePoints(0, endCodePoint), "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Element bodyFallback = replyFallback.get(0).findChild("body");
|
||||||
|
int startCodePoint = Integer.parseInt(bodyFallback.getAttribute("start"));
|
||||||
|
int endCodePoint = Integer.parseInt(bodyFallback.getAttribute("end"));
|
||||||
|
|
||||||
|
if (startCodePoint < 0) return sb;
|
||||||
|
if (endCodePoint > sb.length()) return sb;
|
||||||
|
|
||||||
|
sb.replace(message.body.offsetByCodePoints(0, startCodePoint), message.body.offsetByCodePoints(0, endCodePoint), "");
|
||||||
return sb;
|
return sb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue