Move quote code to quote helper

Stephen Paul Weber created

Change summary

src/main/java/eu/siacs/conversations/ui/util/QuoteHelper.java   | 13 ++
src/main/java/eu/siacs/conversations/ui/widget/EditMessage.java |  9 -
2 files changed, 13 insertions(+), 9 deletions(-)

Detailed changes

src/main/java/eu/siacs/conversations/ui/util/QuoteHelper.java 🔗

@@ -103,4 +103,15 @@ public class QuoteHelper {
         }
         return text;
     }
-}
+
+    public static String quote(String text) {
+        text = replaceAltQuoteCharsInText(text);
+        return text
+                // first replace all '>' at the beginning of the line with nice and tidy '>>'
+                // for nested quoting
+                .replaceAll("(^|\n)(" + QUOTE_CHAR + ")", "$1$2$2")
+                // then find all other lines and have them start with a '> '
+                .replaceAll("(^|\n)(?!" + QUOTE_CHAR + ")(.*)", "$1> $2")
+        ;
+    }
+}

src/main/java/eu/siacs/conversations/ui/widget/EditMessage.java 🔗

@@ -144,14 +144,7 @@ public class EditMessage extends AppCompatEditText {
     }
 
     public void insertAsQuote(String text) {
-        text = QuoteHelper.replaceAltQuoteCharsInText(text);
-        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")
-        ;
+        text = QuoteHelper.quote(text);
         Editable editable = getEditableText();
         int position = getSelectionEnd();
         if (position == -1) position = editable.length();