Loading app/src/test/java/it/niedermann/owncloud/notes/shared/util/NoteUtilTest.java→app/src/androidTest/java/it/niedermann/owncloud/notes/shared/util/NoteUtilTest.java +0 −0 File moved. View file app/src/test/java/android/text/TextUtils.javadeleted 100644 → 0 +0 −40 Original line number Diff line number Diff line package android.text; import androidx.annotation.Nullable; import java.util.Iterator; public class TextUtils { /** * Returns a string containing the tokens joined by delimiters. * * @param delimiter a CharSequence that will be inserted between the tokens. If null, the string * "null" will be used as the delimiter. * @param tokens an array objects to be joined. Strings will be formed from the objects by * calling object.toString(). If tokens is null, a NullPointerException will be thrown. If * tokens is empty, an empty string will be returned. */ public static String join(CharSequence delimiter, Iterable<?> tokens) { final Iterator<?> it = tokens.iterator(); if (!it.hasNext()) { return ""; } final StringBuilder sb = new StringBuilder(); sb.append(it.next()); while (it.hasNext()) { sb.append(delimiter); sb.append(it.next()); } return sb.toString(); } /** * Returns true if the string is null or 0-length. * @param str the string to be examined * @return true if str is null or zero length */ public static boolean isEmpty(@Nullable CharSequence str) { return str == null || str.length() == 0; } } markdown/src/androidTest/java/it/niedermann/android/markdown/MarkdownUtilTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -660,5 +660,8 @@ public class MarkdownUtilTest extends TestCase { assertEquals("Title", MarkdownUtil.removeMarkdown("# Title")); assertEquals("Aufzählung", MarkdownUtil.removeMarkdown("* Aufzählung")); // assertEquals("Foo Link Bar", MarkdownUtil.removeMarkdown("Foo [Link](https://example.com) Bar")); assertFalse(MarkdownUtil.removeMarkdown("- [ ] Test").contains("- [ ]")); assertTrue(MarkdownUtil.removeMarkdown("- [ ] Test").endsWith("Test")); } } No newline at end of file markdown/src/main/java/it/niedermann/android/markdown/MarkdownUtil.java +13 −11 Original line number Diff line number Diff line Loading @@ -75,7 +75,8 @@ public class MarkdownUtil { return parseCompat(markdownProcessor, replaceCheckboxesWithEmojis(content)); } private static CharSequence replaceCheckboxesWithEmojis(String content) { @NonNull private static CharSequence replaceCheckboxesWithEmojis(@NonNull String content) { return runForEachCheckbox(content, (line) -> { for (EListType listType : EListType.values()) { if (checkboxCheckedEmoji != null) { Loading Loading @@ -116,6 +117,7 @@ public class MarkdownUtil { /** * Performs the given {@param map} function for each line which contains a checkbox */ @NonNull private static CharSequence runForEachCheckbox(@NonNull String markdownString, @NonNull Function<String, String> map) { final String[] lines = markdownString.split("\n"); boolean isInFencedCodeBlock = false; Loading Loading @@ -432,7 +434,7 @@ public class MarkdownUtil { } /** * Strips all Markdown from the given String * Strips all Markdown from {@param s} and replaces checkboxes with emojis. * * @param s Markdown string * @return Plain text string Loading @@ -441,13 +443,13 @@ public class MarkdownUtil { public static String removeMarkdown(@Nullable String s) { if (s == null) return ""; String result = s; result = PATTERN_LISTS.matcher(result).replaceAll(""); result = PATTERN_HEADINGS.matcher(result).replaceAll("$1"); result = PATTERN_HEADING_LINE.matcher(result).replaceAll(""); result = PATTERN_EMPHASIS.matcher(result).replaceAll("$2"); result = PATTERN_SPACE_1.matcher(result).replaceAll(""); result = PATTERN_SPACE_2.matcher(result).replaceAll(""); return result; s = replaceCheckboxesWithEmojis(s).toString(); s = PATTERN_LISTS.matcher(s).replaceAll(""); s = PATTERN_HEADINGS.matcher(s).replaceAll("$1"); s = PATTERN_HEADING_LINE.matcher(s).replaceAll(""); s = PATTERN_EMPHASIS.matcher(s).replaceAll("$2"); s = PATTERN_SPACE_1.matcher(s).replaceAll(""); s = PATTERN_SPACE_2.matcher(s).replaceAll(""); return s; } } Loading
app/src/test/java/it/niedermann/owncloud/notes/shared/util/NoteUtilTest.java→app/src/androidTest/java/it/niedermann/owncloud/notes/shared/util/NoteUtilTest.java +0 −0 File moved. View file
app/src/test/java/android/text/TextUtils.javadeleted 100644 → 0 +0 −40 Original line number Diff line number Diff line package android.text; import androidx.annotation.Nullable; import java.util.Iterator; public class TextUtils { /** * Returns a string containing the tokens joined by delimiters. * * @param delimiter a CharSequence that will be inserted between the tokens. If null, the string * "null" will be used as the delimiter. * @param tokens an array objects to be joined. Strings will be formed from the objects by * calling object.toString(). If tokens is null, a NullPointerException will be thrown. If * tokens is empty, an empty string will be returned. */ public static String join(CharSequence delimiter, Iterable<?> tokens) { final Iterator<?> it = tokens.iterator(); if (!it.hasNext()) { return ""; } final StringBuilder sb = new StringBuilder(); sb.append(it.next()); while (it.hasNext()) { sb.append(delimiter); sb.append(it.next()); } return sb.toString(); } /** * Returns true if the string is null or 0-length. * @param str the string to be examined * @return true if str is null or zero length */ public static boolean isEmpty(@Nullable CharSequence str) { return str == null || str.length() == 0; } }
markdown/src/androidTest/java/it/niedermann/android/markdown/MarkdownUtilTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -660,5 +660,8 @@ public class MarkdownUtilTest extends TestCase { assertEquals("Title", MarkdownUtil.removeMarkdown("# Title")); assertEquals("Aufzählung", MarkdownUtil.removeMarkdown("* Aufzählung")); // assertEquals("Foo Link Bar", MarkdownUtil.removeMarkdown("Foo [Link](https://example.com) Bar")); assertFalse(MarkdownUtil.removeMarkdown("- [ ] Test").contains("- [ ]")); assertTrue(MarkdownUtil.removeMarkdown("- [ ] Test").endsWith("Test")); } } No newline at end of file
markdown/src/main/java/it/niedermann/android/markdown/MarkdownUtil.java +13 −11 Original line number Diff line number Diff line Loading @@ -75,7 +75,8 @@ public class MarkdownUtil { return parseCompat(markdownProcessor, replaceCheckboxesWithEmojis(content)); } private static CharSequence replaceCheckboxesWithEmojis(String content) { @NonNull private static CharSequence replaceCheckboxesWithEmojis(@NonNull String content) { return runForEachCheckbox(content, (line) -> { for (EListType listType : EListType.values()) { if (checkboxCheckedEmoji != null) { Loading Loading @@ -116,6 +117,7 @@ public class MarkdownUtil { /** * Performs the given {@param map} function for each line which contains a checkbox */ @NonNull private static CharSequence runForEachCheckbox(@NonNull String markdownString, @NonNull Function<String, String> map) { final String[] lines = markdownString.split("\n"); boolean isInFencedCodeBlock = false; Loading Loading @@ -432,7 +434,7 @@ public class MarkdownUtil { } /** * Strips all Markdown from the given String * Strips all Markdown from {@param s} and replaces checkboxes with emojis. * * @param s Markdown string * @return Plain text string Loading @@ -441,13 +443,13 @@ public class MarkdownUtil { public static String removeMarkdown(@Nullable String s) { if (s == null) return ""; String result = s; result = PATTERN_LISTS.matcher(result).replaceAll(""); result = PATTERN_HEADINGS.matcher(result).replaceAll("$1"); result = PATTERN_HEADING_LINE.matcher(result).replaceAll(""); result = PATTERN_EMPHASIS.matcher(result).replaceAll("$2"); result = PATTERN_SPACE_1.matcher(result).replaceAll(""); result = PATTERN_SPACE_2.matcher(result).replaceAll(""); return result; s = replaceCheckboxesWithEmojis(s).toString(); s = PATTERN_LISTS.matcher(s).replaceAll(""); s = PATTERN_HEADINGS.matcher(s).replaceAll("$1"); s = PATTERN_HEADING_LINE.matcher(s).replaceAll(""); s = PATTERN_EMPHASIS.matcher(s).replaceAll("$2"); s = PATTERN_SPACE_1.matcher(s).replaceAll(""); s = PATTERN_SPACE_2.matcher(s).replaceAll(""); return s; } }