Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added support for custom fonts

### Changed
- Checklists are now shared as plain text ([#96])
- Disabled touch outside the checklist dialog to prevent loss of content ([#291])

### Fixed
Expand Down Expand Up @@ -102,6 +103,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#59]: https://github.com/FossifyOrg/Notes/issues/59
[#81]: https://github.com/FossifyOrg/Notes/issues/81
[#83]: https://github.com/FossifyOrg/Notes/issues/83
[#96]: https://github.com/FossifyOrg/Notes/issues/96
[#99]: https://github.com/FossifyOrg/Notes/issues/99
[#110]: https://github.com/FossifyOrg/Notes/issues/110
[#156]: https://github.com/FossifyOrg/Notes/issues/156
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ import org.fossify.notes.dialogs.OpenFileDialog
import org.fossify.notes.dialogs.OpenNoteDialog
import org.fossify.notes.dialogs.RenameNoteDialog
import org.fossify.notes.dialogs.SortChecklistDialog
import org.fossify.notes.extensions.checklistToPlainText
import org.fossify.notes.extensions.config
import org.fossify.notes.extensions.getPercentageFontSize
import org.fossify.notes.extensions.notesDB
Expand Down Expand Up @@ -1457,7 +1458,7 @@ class MainActivity : SimpleActivity() {
val text = if (mCurrentNote.type == NoteType.TYPE_TEXT) {
getCurrentNoteText()
} else {
mCurrentNote.value
mCurrentNote.value.checklistToPlainText(config.moveDoneChecklistItems) ?: mCurrentNote.value
}

if (text.isNullOrEmpty()) {
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/kotlin/org/fossify/notes/extensions/String.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,12 @@ fun String.parseChecklistItems(): ArrayList<Task>? {
}
return null
}

fun String.checklistToPlainText(moveDoneToBottom: Boolean = true): String? {
val tasks = parseChecklistItems() ?: return null
val sortedTasks = if (moveDoneToBottom) tasks.sortedBy { it.isDone } else tasks
return sortedTasks.joinToString("\n") { task ->
val checkbox = if (task.isDone) "[x]" else "[ ]"
"$checkbox ${task.title}"
}
}
Loading