mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-05-28 21:04:17 +02:00
Implement deleting done checklist items
This commit is contained in:
parent
ab9407ee7a
commit
75da88ba33
@ -153,6 +153,7 @@ class MainActivity : SimpleActivity() {
|
||||
findItem(R.id.delete_note).isVisible = multipleNotesExist
|
||||
findItem(R.id.export_all_notes).isVisible = multipleNotesExist && hasPermission(PERMISSION_WRITE_STORAGE)
|
||||
findItem(R.id.open_search).isVisible = !isCurrentItemChecklist()
|
||||
findItem(R.id.remove_done_items).isVisible = isCurrentItemChecklist()
|
||||
findItem(R.id.import_folder).isVisible = hasPermission(PERMISSION_READ_STORAGE)
|
||||
|
||||
saveNoteButton = findItem(R.id.save_note)
|
||||
@ -185,6 +186,7 @@ class MainActivity : SimpleActivity() {
|
||||
R.id.delete_note -> displayDeleteNotePrompt()
|
||||
R.id.settings -> startActivity(Intent(applicationContext, SettingsActivity::class.java))
|
||||
R.id.about -> launchAbout()
|
||||
R.id.remove_done_items -> removeDoneItems()
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
}
|
||||
return true
|
||||
@ -241,7 +243,8 @@ class MainActivity : SimpleActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun isCurrentItemChecklist() = mAdapter?.isChecklistFragment(view_pager.currentItem) ?: false
|
||||
private fun isCurrentItemChecklist() = mAdapter?.isChecklistFragment(view_pager.currentItem)
|
||||
?: false
|
||||
|
||||
private fun checkIntents(intent: Intent) {
|
||||
intent.apply {
|
||||
@ -904,7 +907,8 @@ class MainActivity : SimpleActivity() {
|
||||
private fun saveCurrentNote(force: Boolean) {
|
||||
getPagerAdapter().saveCurrentNote(view_pager.currentItem, force)
|
||||
if (mCurrentNote.type == NoteType.TYPE_CHECKLIST.value) {
|
||||
mCurrentNote.value = getPagerAdapter().getNoteChecklistItems(view_pager.currentItem) ?: ""
|
||||
mCurrentNote.value = getPagerAdapter().getNoteChecklistItems(view_pager.currentItem)
|
||||
?: ""
|
||||
}
|
||||
}
|
||||
|
||||
@ -1052,4 +1056,8 @@ class MainActivity : SimpleActivity() {
|
||||
checkWhatsNew(this, BuildConfig.VERSION_CODE)
|
||||
}
|
||||
}
|
||||
|
||||
private fun removeDoneItems() {
|
||||
getPagerAdapter().removeDoneCheckListItems(view_pager.currentItem)
|
||||
}
|
||||
}
|
||||
|
@ -89,4 +89,8 @@ class NotesPagerAdapter(fm: FragmentManager, val notes: List<Note>, val activity
|
||||
fragments[position] = fragment
|
||||
return fragment
|
||||
}
|
||||
|
||||
fun removeDoneCheckListItems(position: Int) {
|
||||
(fragments[position] as? ChecklistFragment)?.removeDoneItems()
|
||||
}
|
||||
}
|
||||
|
@ -135,11 +135,7 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
|
||||
}
|
||||
|
||||
private fun setupAdapter() {
|
||||
with(view) {
|
||||
fragment_placeholder.beVisibleIf(items.isEmpty())
|
||||
fragment_placeholder_2.beVisibleIf(items.isEmpty())
|
||||
checklist_list.beVisibleIf(items.isNotEmpty())
|
||||
}
|
||||
updateUIVisibility()
|
||||
|
||||
ChecklistAdapter(
|
||||
activity = activity as SimpleActivity,
|
||||
@ -176,6 +172,21 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
|
||||
}
|
||||
}
|
||||
|
||||
fun removeDoneItems() {
|
||||
items.removeIf { it.isDone }
|
||||
updateUIVisibility()
|
||||
view.checklist_list.adapter?.notifyDataSetChanged()
|
||||
saveNote()
|
||||
}
|
||||
|
||||
private fun updateUIVisibility() {
|
||||
with(view) {
|
||||
fragment_placeholder.beVisibleIf(items.isEmpty())
|
||||
fragment_placeholder_2.beVisibleIf(items.isEmpty())
|
||||
checklist_list.beVisibleIf(items.isNotEmpty())
|
||||
}
|
||||
}
|
||||
|
||||
override fun saveChecklist() {
|
||||
saveNote()
|
||||
}
|
||||
|
@ -36,6 +36,11 @@
|
||||
android:icon="@drawable/ic_rename_new"
|
||||
android:title="@string/rename_note"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/remove_done_items"
|
||||
android:title="@string/remove_done_items"
|
||||
android:icon="@drawable/ic_delete_vector"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/share"
|
||||
android:icon="@drawable/ic_share_vector"
|
||||
|
@ -101,6 +101,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -101,6 +101,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -101,6 +101,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -101,6 +101,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -101,6 +101,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -99,6 +99,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -101,6 +101,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -99,6 +99,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -101,6 +101,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -100,6 +100,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -101,6 +101,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -101,6 +101,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -101,6 +101,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -101,6 +101,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -100,6 +100,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -99,6 +99,7 @@
|
||||
<b> Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -101,6 +101,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -97,6 +97,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -101,6 +101,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -101,6 +101,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -101,6 +101,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Não encontrou todas as cadeias a traduzir? Existem mais algumas em:
|
||||
|
@ -101,6 +101,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -101,6 +101,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -101,6 +101,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -101,6 +101,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -101,6 +101,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -101,6 +101,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -101,6 +101,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
@ -101,6 +101,7 @@
|
||||
<b>Reddit:</b>
|
||||
https://www.reddit.com/r/SimpleMobileTools
|
||||
</string>
|
||||
<string name="remove_done_items">Remove done items</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
Loading…
x
Reference in New Issue
Block a user