From cf124397711d08c937445040507cb17a6d88697f Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 9 Dec 2018 20:25:29 +0100 Subject: [PATCH] handle checklists at Open Text intent --- .../notes/pro/activities/MainActivity.kt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt index 78e0bf5b..17d148f6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt @@ -403,12 +403,19 @@ class MainActivity : SimpleActivity() { private fun openPath(path: String) { openFile(path, false) { - var title = path.getFilenameFromPath() - if (mNotes.any { it.title.equals(title, true) }) { - title += " (file)" + val title = path.getFilenameFromPath() + val fileText = it.readText().trim() + val checklistItems = fileText.parseChecklistItems() + val note = if (checklistItems != null) { + Note(null, title.substringBeforeLast('.'), fileText, TYPE_CHECKLIST) + } else { + Note(null, title, "", TYPE_TEXT, path) + } + + if (mNotes.any { it.title.equals(note.title, true) }) { + note.title += " (file)" } - val note = Note(null, title, "", TYPE_TEXT, path) addNewNote(note) } }