@@ -145,7 +145,13 @@ public class EditMessage extends AppCompatEditText {
public void insertAsQuote(String text) {
text = QuoteHelper.replaceAltQuoteCharsInText(text);
- text = text.replaceAll("(\n *){2,}", "\n").replaceAll("(^|\n)(" + QuoteHelper.QUOTE_CHAR + ")", "$1$2$2").replaceAll("(^|\n)([^" + QuoteHelper.QUOTE_CHAR + "])", "$1> $2").replaceAll("\n$", "");
+ text = text
+ // first replace all '>' at the beginning of the line with nice and tidy '>>'
+ // for nested quoting
+ .replaceAll("(^|\n)(" + QuoteHelper.QUOTE_CHAR + ")", "$1$2$2")
+ // then find all other lines and have them start with a '> '
+ .replaceAll("(^|\n)(?!" + QuoteHelper.QUOTE_CHAR + ")(.*)", "$1> $2")
+ ;
Editable editable = getEditableText();
int position = getSelectionEnd();
if (position == -1) position = editable.length();
@@ -66,11 +66,7 @@ public class MessageUtils {
body = message.getMergedBody().toString();
}
for (String line : body.split("\n")) {
- if (line.length() <= 0) {- continue;- }- final char c = line.charAt(0);- if (QuoteHelper.isNestedTooDeeply(line)) {
+ if (!(line.length() <= 0) && QuoteHelper.isNestedTooDeeply(line)) {
continue;
}
if (builder.length() != 0) {