handle checklists at Open Text intent

This commit is contained in:
tibbi 2018-12-09 20:25:29 +01:00
parent b6f8bea868
commit cf12439771
1 changed files with 11 additions and 4 deletions

View File

@ -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)
}
}