mirror of
				https://github.com/SimpleMobileTools/Simple-Notes.git
				synced 2025-06-05 17:00:23 +02:00 
			
		
		
		
	Merge pull request #388 from tanvir-ahmod/fix_382
Fix #382 , Implement deleting done checklist items
This commit is contained in:
		| @@ -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 | ||||
| @@ -1058,4 +1060,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" | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">إضافة عنصر قائمة تدقيق جديد</string> | ||||
|     <string name="add_new_checklist_items">إضافة عناصر قائمة تدقيق جديدة</string> | ||||
|     <string name="checklist_is_empty">قائمة التدقيق فارغة</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">تصدير جميع الملاحظات كملفات</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">Add a new checklist item</string> | ||||
|     <string name="add_new_checklist_items">Add new checklist items</string> | ||||
|     <string name="checklist_is_empty">The checklist is empty</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">Bütün qeydləri fayl şəklində çıxar</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">Přidat do seznamu novou položku</string> | ||||
|     <string name="add_new_checklist_items">Přidat do seznamu nové položky</string> | ||||
|     <string name="checklist_is_empty">Seznam položek je prázdný</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">Exportovat všechny poznámky jako soubory</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">Ychwanegu eitem newydd at restr wirio</string> | ||||
|     <string name="add_new_checklist_items">Ychwanegu eitemau newydd at restr wirio</string> | ||||
|     <string name="checklist_is_empty">Mae\'r rhestr wirio yn wag</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">Allforio pob nodyn fel ffeil</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">Føj et nyt punkt til tjeklisten</string> | ||||
|     <string name="add_new_checklist_items">Føj nye punkter til tjeklisten</string> | ||||
|     <string name="checklist_is_empty">Tjeklisten er tom</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">Eksporter alle noter som filer</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">Einen neuen Checklisteneintrag hinzufügen</string> | ||||
|     <string name="add_new_checklist_items">Neue Checklisteneinträge hinzufügen</string> | ||||
|     <string name="checklist_is_empty">Die Checkliste ist leer</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">Alle Notizen als Dateien exportieren</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">Προσθήκη νέου στοιχείου λίστας ελέγχου</string> | ||||
|     <string name="add_new_checklist_items">Προσθήκη νέων στοιχείων λίστας ελέγχου</string> | ||||
|     <string name="checklist_is_empty">Η λίστα ελέγχου είναι κενή</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">Εξαγωγή όλων των σημειώσεων ως αρχεία</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">Añadir un nuevo item a la lista</string> | ||||
|     <string name="add_new_checklist_items">Añadir nuevos items a la lista</string> | ||||
|     <string name="checklist_is_empty">La lista está vacía</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">Exportar todas las notas como archivos</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">Ajouter un nouvel élément</string> | ||||
|     <string name="add_new_checklist_items">Ajouter de nouveaux éléments</string> | ||||
|     <string name="checklist_is_empty">La checklist est vide</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">Exporter toutes les notes en tant que fichiers</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">Engadir un elemento a unha nova lista de verificación</string> | ||||
|     <string name="add_new_checklist_items">Engadir elementos a unha nova lista de verificación</string> | ||||
|     <string name="checklist_is_empty">A lista de verificación está baleira</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">Exportar todas as notas como ficheiros</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">Dodajte novu stavku na spisak</string> | ||||
|     <string name="add_new_checklist_items">Dodajte nove stavke na spisak</string> | ||||
|     <string name="checklist_is_empty">Spisak je prazan</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">Izvezi sve bilješke kao datoteke</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">Add a new checklist item</string> | ||||
|     <string name="add_new_checklist_items">Add new checklist items</string> | ||||
|     <string name="checklist_is_empty">The checklist is empty</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">Export all notes as files</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">Tambah item checklist baru</string> | ||||
|     <string name="add_new_checklist_items">Tambah item checklist baru</string> | ||||
|     <string name="checklist_is_empty">Checklist kosong</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">Ekspor semua catatan ke berkas</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">Tambah item checklist baru</string> | ||||
|     <string name="add_new_checklist_items">Tambah item checklist baru</string> | ||||
|     <string name="checklist_is_empty">Checklist kosong</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">Ekspor semua catatan ke berkas</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">Aggiungi un nuovo elemento</string> | ||||
|     <string name="add_new_checklist_items">Aggiungi nuovi elementi</string> | ||||
|     <string name="checklist_is_empty">La scaletta è vuota</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">Esporta le note come file</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">新しいチェックリスト項目を追加</string> | ||||
|     <string name="add_new_checklist_items">新しいチェックリスト項目を追加</string> | ||||
|     <string name="checklist_is_empty">チェックリストが空です</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">すべてのメモをファイルとしてエクスポート</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">Pridėti naują kontrolinio sąrašo objektą</string> | ||||
|     <string name="add_new_checklist_items">Pridėti naujus kontrolinio sąrašo objektus</string> | ||||
|     <string name="checklist_is_empty">Kontrolinis sąršas tuščias</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">Eksportuoti visus užrašus kaip bylas</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">Item toevoegen</string> | ||||
|     <string name="add_new_checklist_items">Items toevoegen</string> | ||||
|     <string name="checklist_is_empty">De lijst is leeg</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">Alle notities naar bestanden exporteren</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">Add a new checklist item</string> | ||||
|     <string name="add_new_checklist_items">Add new checklist items</string> | ||||
|     <string name="checklist_is_empty">The checklist is empty</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">Eksportuj wszystkie notatki jako pliki</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">Adicionar novo item de lista de verificação</string> | ||||
|     <string name="add_new_checklist_items">Adicionar novos itens de lista de verificação</string> | ||||
|     <string name="checklist_is_empty">A lista de verificação está vazia</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">Exportar todas as notas como arquivo</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">Adicionar item à lista de verificações</string> | ||||
|     <string name="add_new_checklist_items">Adicionar itens à lista de verificação</string> | ||||
|     <string name="checklist_is_empty">A lista está vazia</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">Exportar todas as notas como ficheiros</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">Добавить позицию в список</string> | ||||
|     <string name="add_new_checklist_items">Добавить позиции в список</string> | ||||
|     <string name="checklist_is_empty">Список пуст</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">Экспортировать все заметки в файлы</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">Pridať do zoznamu novú položku</string> | ||||
|     <string name="add_new_checklist_items">Pridať do zoznamu nové položky</string> | ||||
|     <string name="checklist_is_empty">Zoznam položiek je prázdny</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">Exportovať všetky poznámky ako súbory</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">Lägg till ett nytt checklisteobjekt</string> | ||||
|     <string name="add_new_checklist_items">Lägg till nya checklisteobjekt</string> | ||||
|     <string name="checklist_is_empty">Checklistan är tom</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">Exportera alla anteckningar som filer</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">Yeni bir yapılacak listesi öğesi ekle</string> | ||||
|     <string name="add_new_checklist_items">Yeni yapılacak listesi öğeleri ekle</string> | ||||
|     <string name="checklist_is_empty">Yapılacak listesi boş</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">Tüm notları dosya olarak dışa aktar</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">Додати нову позицію у списку</string> | ||||
|     <string name="add_new_checklist_items">Додати нові позиції у списку</string> | ||||
|     <string name="checklist_is_empty">Список порожній</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">Експортувати всі нотатки як файли</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">添加一个新的清单项目</string> | ||||
|     <string name="add_new_checklist_items">添加新的清单项目</string> | ||||
|     <string name="checklist_is_empty">清单为空</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">以文件导出所有笔记</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">新增新的核對清單項目</string> | ||||
|     <string name="add_new_checklist_items">新增新的核對清單項目</string> | ||||
|     <string name="checklist_is_empty">核對清單為空白</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">將全部筆記匯出成檔案</string> | ||||
|   | ||||
| @@ -55,6 +55,7 @@ | ||||
|     <string name="add_new_checklist_item">Add a new checklist item</string> | ||||
|     <string name="add_new_checklist_items">Add new checklist items</string> | ||||
|     <string name="checklist_is_empty">The checklist is empty</string> | ||||
|     <string name="remove_done_items">Remove done items</string> | ||||
|  | ||||
|     <!-- Import / Export --> | ||||
|     <string name="export_all_notes">Export all notes as files</string> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user