From f947fdcc42009cdc2c459b214451cb2c0d4527e4 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Fri, 26 Dec 2025 21:46:22 +0000 Subject: [PATCH 1/2] fix: Prevent broken/strange checklist reordering Updates the checklist reorder moves to filter and just consider those which are visually re-orderable within the UI, since odd behaviour could occur when the fundemental task data had checked items between unchecked items while the "Move checked items to the bottom" setting was enabled. This could occur from toggling the "Move checked items to the bottom" option, or by attempting to move a task item into/below the "Checked items" list. This also adds a check when moving an item down, since the move handling would consider the "Checked items" as an element when emitting position changes. Related to #59 --- CHANGELOG.md | 3 +++ .../fossify/notes/fragments/TasksFragment.kt | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75259ee0f..f634c648c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- Fixed inconsistent checklist sorting when the "Move checked items to the bottom" option is enabled + ## [1.6.0] - 2025-10-29 ### Changed - Compatibility updates for Android 15 & 16 diff --git a/app/src/main/kotlin/org/fossify/notes/fragments/TasksFragment.kt b/app/src/main/kotlin/org/fossify/notes/fragments/TasksFragment.kt index 11117e10d..f444fd2ba 100644 --- a/app/src/main/kotlin/org/fossify/notes/fragments/TasksFragment.kt +++ b/app/src/main/kotlin/org/fossify/notes/fragments/TasksFragment.kt @@ -288,13 +288,28 @@ class TasksFragment : NoteFragment(), TasksActionListener { override fun moveTask(fromPosition: Int, toPosition: Int) { switchToCustomSorting() + + val sortableIndices = mutableListOf() + val checkedCanBeMoved = config?.moveDoneChecklistItems == false + for (i in 0 until tasks.size) { + if (checkedCanBeMoved || !tasks[i].isDone) { + sortableIndices.add(i) + } + } + if (fromPosition < toPosition) { for (i in fromPosition until toPosition) { - tasks.swap(i, i + 1) + val toMoveIndex = sortableIndices[i] + if (i + 1 < sortableIndices.size) { + val headingIndex = sortableIndices[i + 1] + tasks.swap(toMoveIndex, headingIndex) + } } } else { for (i in fromPosition downTo toPosition + 1) { - tasks.swap(i, i - 1) + val toMoveIndex = sortableIndices[i] + val headingIndex = sortableIndices[i - 1] + tasks.swap(toMoveIndex, headingIndex) } } From 18063a7a10f96b3aa496241a3227ad1391cc5687 Mon Sep 17 00:00:00 2001 From: Naveen Singh <36371707+naveensingh@users.noreply.github.com> Date: Sat, 27 Dec 2025 17:54:02 +0530 Subject: [PATCH 2/2] docs(changelog): reference issue in changelog entry It helps in the release notes. --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f634c648c..c202b8417 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Fixed -- Fixed inconsistent checklist sorting when the "Move checked items to the bottom" option is enabled +- Fixed inconsistent checklist sorting when the "Move checked items to the bottom" option is enabled ([#59]) ## [1.6.0] - 2025-10-29 ### Changed @@ -94,6 +94,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Initial release +[#59]: https://github.com/FossifyOrg/Notes/issues/59 [#81]: https://github.com/FossifyOrg/Notes/issues/81 [#83]: https://github.com/FossifyOrg/Notes/issues/83 [#99]: https://github.com/FossifyOrg/Notes/issues/99