mirror of
https://github.com/FossifyOrg/Notes.git
synced 2026-06-13 19:24:34 -04:00
feat: share checklists as simple text (#302)
Refs: https://github.com/FossifyOrg/Notes/issues/96
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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}"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user