handle checklists at Open Text intent

This commit is contained in:
tibbi 2018-12-09 20:25:29 +01:00
parent b6f8bea868
commit cf12439771

View File

@ -403,12 +403,19 @@ class MainActivity : SimpleActivity() {
private fun openPath(path: String) { private fun openPath(path: String) {
openFile(path, false) { openFile(path, false) {
var title = path.getFilenameFromPath() val title = path.getFilenameFromPath()
if (mNotes.any { it.title.equals(title, true) }) { val fileText = it.readText().trim()
title += " (file)" 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) addNewNote(note)
} }
} }