forked from mirror/monocles_chat_clean
update fork #128
4 changed files with 15 additions and 3 deletions
Add blank line after quote fallback and reduce quote length
commit
e71c8b99a8
|
|
@ -491,7 +491,7 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
|
|||
clearReplyReact();
|
||||
|
||||
if (body == null) body = new SpannableStringBuilder(getBody(false));
|
||||
setBody(QuoteHelper.quote(MessageUtils.prepareQuote(replyTo)) + "\n");
|
||||
setBody(QuoteHelper.quote(MessageUtils.prepareQuote(replyTo)) + "\n\n");
|
||||
|
||||
final String replyId = replyTo.replyId();
|
||||
if (replyId == null) return;
|
||||
|
|
|
|||
|
|
@ -6831,7 +6831,7 @@ public class XmppConnectionService extends Service {
|
|||
final var packet =
|
||||
mMessageGenerator.reaction(reactTo, typeGroupChat, message, reactToId, reactions);
|
||||
|
||||
final var quote = QuoteHelper.quote(MessageUtils.prepareQuote(message)) + "\n";
|
||||
final var quote = QuoteHelper.quote(MessageUtils.prepareQuote(message, 1, 2)) + "\n\n";
|
||||
final var body = quote + String.join(" ", newReactions);
|
||||
if (conversation.getNextEncryption() == Message.ENCRYPTION_AXOLOTL && newReactions.size() > 0) {
|
||||
FILE_ATTACHMENT_EXECUTOR.execute(() -> {
|
||||
|
|
|
|||
|
|
@ -98,6 +98,10 @@ public class QuoteHelper {
|
|||
}
|
||||
|
||||
public static boolean isNestedTooDeeply(CharSequence line) {
|
||||
return isNestedTooDeeply(line, Config.QUOTING_MAX_DEPTH);
|
||||
}
|
||||
|
||||
public static boolean isNestedTooDeeply(CharSequence line, int maxDepth) {
|
||||
if (isPositionQuoteStart(line, 0)) {
|
||||
int nestingDepth = 1;
|
||||
for (int i = 1; i < line.length(); i++) {
|
||||
|
|
@ -107,7 +111,7 @@ public class QuoteHelper {
|
|||
break;
|
||||
}
|
||||
}
|
||||
return nestingDepth >= (Config.QUOTING_MAX_DEPTH);
|
||||
return nestingDepth >= maxDepth;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ package eu.siacs.conversations.utils;
|
|||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.entities.Conversational;
|
||||
import eu.siacs.conversations.entities.Message;
|
||||
|
|
@ -49,6 +50,10 @@ public class MessageUtils {
|
|||
public static final String EMPTY_STRING = "";
|
||||
|
||||
public static String prepareQuote(final Message message) {
|
||||
return prepareQuote(message, Config.QUOTING_MAX_DEPTH, -1);
|
||||
}
|
||||
|
||||
public static String prepareQuote(final Message message, int maxDepth, int maxLines) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
final String body;
|
||||
if (message.hasMeCommand()) {
|
||||
|
|
@ -66,14 +71,17 @@ public class MessageUtils {
|
|||
} else {
|
||||
body = message.getQuoteableBody();
|
||||
}
|
||||
int lines = 0;
|
||||
for (String line : body.split("\n")) {
|
||||
if (!(line.length() <= 0) && QuoteHelper.isNestedTooDeeply(line)) {
|
||||
continue;
|
||||
}
|
||||
if (maxLines > 0 && maxLines <= lines) break;
|
||||
if (builder.length() != 0) {
|
||||
builder.append('\n');
|
||||
}
|
||||
builder.append(line.trim());
|
||||
lines++;
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue