Merge branch 'master' of https://dev.narayana.im/narayana/Conversations
This commit is contained in:
commit
e0231493d0
|
@ -599,7 +599,12 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
|||
message.markable = packet.hasChild("markable", "urn:xmpp:chat-markers:0");
|
||||
|
||||
for (Element el : packet.getChildren()) {
|
||||
if (el.getName().equals("reply") && el.getNamespace() != null && el.getNamespace().equals("urn:xmpp:reply:0")) {
|
||||
String name = el.getName();
|
||||
String ns = el.getNamespace();
|
||||
if (
|
||||
("reply".equals(name) && "urn:xmpp:reply:0".equals(ns)) ||
|
||||
("fallback".equals(name) && "urn:xmpp:fallback:0".equals(ns))
|
||||
) {
|
||||
message.addPayload(el);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,6 +87,7 @@ import eu.siacs.conversations.utils.MessageUtils;
|
|||
import eu.siacs.conversations.utils.StylingHelper;
|
||||
import eu.siacs.conversations.utils.TimeFrameUtils;
|
||||
import eu.siacs.conversations.utils.UIHelper;
|
||||
import eu.siacs.conversations.xml.Element;
|
||||
import eu.siacs.conversations.xmpp.Jid;
|
||||
import eu.siacs.conversations.xmpp.mam.MamReference;
|
||||
|
||||
|
@ -458,8 +459,11 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
*/
|
||||
public boolean handleTextQuotes(SpannableStringBuilder body, boolean darkBackground, boolean highlightReply, Message message) {
|
||||
boolean startsWithQuote = false;
|
||||
int quoteDepth = 1;
|
||||
int quoteDepth = 0;
|
||||
while (QuoteHelper.bodyContainsQuoteStart(body) && quoteDepth <= Config.QUOTE_MAX_DEPTH) {
|
||||
if (quoteDepth == 0) {
|
||||
quoteDepth = 1;
|
||||
}
|
||||
char previous = '\n';
|
||||
int lineStart = -1;
|
||||
int lineTextStart = -1;
|
||||
|
@ -504,6 +508,38 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
}
|
||||
quoteDepth++;
|
||||
}
|
||||
if (quoteDepth == 0 && highlightReply) {
|
||||
// Quote was not detected, use a reply anyway if provided
|
||||
int start = -1;
|
||||
int end = -1;
|
||||
for (Element el : message.getPayloads()) {
|
||||
if ("fallback".equals(el.getName()) && "urn:xmpp:fallback:0".equals(el.getNamespace()) && "urn:xmpp:reply:0".equals(el.getAttribute("for"))) {
|
||||
Element bodyEl = el.findChild("body", "urn:xmpp:fallback:0");
|
||||
if (bodyEl != null) {
|
||||
String startString = bodyEl.getAttribute("start");
|
||||
String endString = bodyEl.getAttribute("end");
|
||||
try {
|
||||
start = Integer.parseInt(startString);
|
||||
end = Integer.parseInt(endString);
|
||||
} catch (final NumberFormatException ignored) {
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (start == -1 && end == -1) {
|
||||
// Quirk for messages which were saved without the fallback element
|
||||
final String quirk = "reply\n";
|
||||
body.insert(0, quirk);
|
||||
start = 0;
|
||||
end = quirk.length();
|
||||
} else if (start == -1) {
|
||||
start = 0;
|
||||
} else if (end == -1) {
|
||||
end = body.length();
|
||||
}
|
||||
applyQuoteSpan(body, start, end, darkBackground, true, message);
|
||||
}
|
||||
return startsWithQuote;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue