From 94903e68184cb9685156723c5b3a56337132e713 Mon Sep 17 00:00:00 2001 From: stefan-niedermann Date: Thu, 2 Jan 2020 12:07:31 +0100 Subject: [PATCH] #451 Toggle checkboxes in view mode wrong checkbox is associated with action --- .../android/fragment/NotePreviewFragment.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NotePreviewFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NotePreviewFragment.java index f18a17661..892ca6818 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NotePreviewFragment.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NotePreviewFragment.java @@ -80,7 +80,21 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { try { String[] lines = TextUtils.split(note.getContent(), "\\r?\\n"); /* - * Workaround for multiple bugs: + * Workaround for RxMarkdown-bug: + * When (un)checking a checkbox in a note which contains code-blocks, the "`"-characters get stripped out in the TextView and therefore the given lineNumber is wrong + * Find number of lines starting with ``` before lineNumber + */ + for(int i = 0; i < lines.length; i++) { + if(lines[i].startsWith("```")) { + lineNumber++; + } + if(i == lineNumber) { + break; + } + } + + /* + * Workaround for multiple RxMarkdown-bugs: * When (un)checking a checkbox which is in the last line, every time it gets toggled, the last character of the line gets lost. * When (un)checking a checkbox, every markdown gets stripped in the given line argument */