Implement nested quotes through iteration.
This commit is contained in:
parent
65a72827bc
commit
74d60d0131
|
@ -201,4 +201,7 @@ public final class Config {
|
||||||
public final static float LOCATION_FIX_SPACE_DELTA = 10; // m
|
public final static float LOCATION_FIX_SPACE_DELTA = 10; // m
|
||||||
public final static int LOCATION_FIX_SIGNIFICANT_TIME_DELTA = 1000 * 60 * 2; // ms
|
public final static int LOCATION_FIX_SIGNIFICANT_TIME_DELTA = 1000 * 60 * 2; // ms
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// How deep nested quotes should become. '2' means one quote nested in another.
|
||||||
|
public static final int QUOTE_MAX_DEPTH = 3;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ import eu.siacs.conversations.ui.text.DividerSpan;
|
||||||
import eu.siacs.conversations.ui.text.QuoteSpan;
|
import eu.siacs.conversations.ui.text.QuoteSpan;
|
||||||
import eu.siacs.conversations.ui.util.AvatarWorkerTask;
|
import eu.siacs.conversations.ui.util.AvatarWorkerTask;
|
||||||
import eu.siacs.conversations.ui.util.MyLinkify;
|
import eu.siacs.conversations.ui.util.MyLinkify;
|
||||||
|
import eu.siacs.conversations.ui.util.QuoteHelper;
|
||||||
import eu.siacs.conversations.ui.util.ViewUtil;
|
import eu.siacs.conversations.ui.util.ViewUtil;
|
||||||
import eu.siacs.conversations.ui.widget.ClickableMovementMethod;
|
import eu.siacs.conversations.ui.widget.ClickableMovementMethod;
|
||||||
import eu.siacs.conversations.utils.CryptoHelper;
|
import eu.siacs.conversations.utils.CryptoHelper;
|
||||||
|
@ -359,6 +360,8 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
||||||
*/
|
*/
|
||||||
private boolean handleTextQuotes(SpannableStringBuilder body, boolean darkBackground) {
|
private boolean handleTextQuotes(SpannableStringBuilder body, boolean darkBackground) {
|
||||||
boolean startsWithQuote = false;
|
boolean startsWithQuote = false;
|
||||||
|
int quoteDepth = 1;
|
||||||
|
while (QuoteHelper.bodyContainsQuoteStart(body) && quoteDepth <= Config.QUOTE_MAX_DEPTH) {
|
||||||
char previous = '\n';
|
char previous = '\n';
|
||||||
int lineStart = -1;
|
int lineStart = -1;
|
||||||
int lineTextStart = -1;
|
int lineTextStart = -1;
|
||||||
|
@ -367,8 +370,10 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
||||||
char current = body.length() > i ? body.charAt(i) : '\n';
|
char current = body.length() > i ? body.charAt(i) : '\n';
|
||||||
if (lineStart == -1) {
|
if (lineStart == -1) {
|
||||||
if (previous == '\n') {
|
if (previous == '\n') {
|
||||||
if ((current == '>' && UIHelper.isPositionFollowedByQuoteableCharacter(body, i))
|
if (
|
||||||
|| current == '\u00bb' && !UIHelper.isPositionFollowedByQuote(body, i)) {
|
(QuoteHelper.isPositionQuoteStart(body, i)
|
||||||
|
|| (current == '\u00bb' && !UIHelper.isPositionFollowedByQuote(body, i)
|
||||||
|
))) {
|
||||||
// Line start with quote
|
// Line start with quote
|
||||||
lineStart = i;
|
lineStart = i;
|
||||||
if (quoteStart == -1) quoteStart = i;
|
if (quoteStart == -1) quoteStart = i;
|
||||||
|
@ -377,6 +382,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
||||||
// Line start without quote, apply spans there
|
// Line start without quote, apply spans there
|
||||||
applyQuoteSpan(body, quoteStart, i - 1, darkBackground);
|
applyQuoteSpan(body, quoteStart, i - 1, darkBackground);
|
||||||
quoteStart = -1;
|
quoteStart = -1;
|
||||||
|
quoteDepth++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -401,6 +407,8 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
||||||
if (quoteStart >= 0) {
|
if (quoteStart >= 0) {
|
||||||
// Apply spans to finishing open quote
|
// Apply spans to finishing open quote
|
||||||
applyQuoteSpan(body, quoteStart, body.length(), darkBackground);
|
applyQuoteSpan(body, quoteStart, body.length(), darkBackground);
|
||||||
|
quoteDepth++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return startsWithQuote;
|
return startsWithQuote;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue