feat(tasks): add option to uncheck all checked items (#184)

* feat(tasks): uncheck all checked items

* docs(changelog): added new feature to CHANGELOG.md

* docs(changelog): add issue link and adjust wording for the new feature

* refactor: Use "uncheck all items" uniformly

* docs(changelog): fix issue reference
This commit is contained in:
TopFox
2025-07-13 11:39:09 +02:00
committed by GitHub
parent c60ce4756d
commit 92aedb7a30
6 changed files with 23 additions and 0 deletions

View File

@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- Option to uncheck all checked items ([#156])
## [1.3.1] - 2025-07-12
### Changed
@@ -61,6 +63,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#83]: https://github.com/FossifyOrg/Notes/issues/83
[#99]: https://github.com/FossifyOrg/Notes/issues/99
[#110]: https://github.com/FossifyOrg/Notes/issues/110
[#156]: https://github.com/FossifyOrg/Notes/issues/156
[#164]: https://github.com/FossifyOrg/Notes/issues/164
[#178]: https://github.com/FossifyOrg/Notes/issues/178

View File

@@ -269,6 +269,7 @@ class MainActivity : SimpleActivity() {
findItem(R.id.delete_note).isVisible = multipleNotesExist
findItem(R.id.open_search).isVisible = !isCurrentItemChecklist
findItem(R.id.remove_done_items).isVisible = isCurrentItemChecklist
findItem(R.id.uncheck_all_items).isVisible = isCurrentItemChecklist
findItem(R.id.sort_checklist).isVisible = isCurrentItemChecklist
findItem(R.id.import_folder).isVisible = !isQPlus()
findItem(R.id.lock_note).isVisible =
@@ -316,6 +317,7 @@ class MainActivity : SimpleActivity() {
R.id.settings -> launchSettings()
R.id.about -> launchAbout()
R.id.remove_done_items -> fragment?.handleUnlocking { removeDoneItems() }
R.id.uncheck_all_items -> fragment?.handleUnlocking { uncheckAllItems() }
R.id.sort_checklist -> fragment?.handleUnlocking { displaySortChecklistDialog() }
else -> return@setOnMenuItemClickListener false
}
@@ -1555,6 +1557,10 @@ class MainActivity : SimpleActivity() {
getPagerAdapter().removeDoneCheckListItems(binding.viewPager.currentItem)
}
private fun uncheckAllItems() {
getPagerAdapter().uncheckAllItems(binding.viewPager.currentItem)
}
private fun displaySortChecklistDialog() {
SortChecklistDialog(this, mCurrentNote.id) {
getPagerAdapter().refreshChecklist(binding.viewPager.currentItem)

View File

@@ -96,6 +96,10 @@ class NotesPagerAdapter(fm: FragmentManager, val notes: List<Note>, val activity
(fragments[position] as? TasksFragment)?.removeCheckedItems()
}
fun uncheckAllItems(position: Int) {
(fragments[position] as? TasksFragment)?.uncheckAllItems()
}
fun refreshChecklist(position: Int) {
(fragments[position] as? TasksFragment)?.saveAndReload()
}

View File

@@ -256,6 +256,11 @@ class TasksFragment : NoteFragment(), TasksActionListener {
setupAdapter()
}
fun uncheckAllItems() {
tasks = tasks.map { it.copy(isDone = false) }.toMutableList()
saveAndReload()
}
private fun updateUIVisibility() {
binding.apply {
fragmentPlaceholder.beVisibleIf(tasks.isEmpty())

View File

@@ -40,6 +40,10 @@
android:id="@+id/remove_done_items"
android:title="@string/delete_checked_items"
app:showAsAction="never" />
<item
android:id="@+id/uncheck_all_items"
android:title="@string/uncheck_all_items"
app:showAsAction="never" />
<item
android:id="@+id/sort_checklist"
android:icon="@drawable/ic_sort_vector"

View File

@@ -71,6 +71,7 @@
<string name="add_new_checklist_items">Add new checklist items</string>
<string name="checklist_is_empty">The checklist is empty</string>
<string name="delete_checked_items">Delete checked items</string>
<string name="uncheck_all_items">Uncheck all items</string>
<string name="add_to_the_top">Add to the top</string>
<string name="use_for_this_checklist">Use for this checklist only</string>
<plurals name="num_checked_items">