Add option to move checklist item all the way top or bottom #370
This commit is contained in:
Tibor Kaputa 2021-01-21 18:48:58 +01:00 committed by GitHub
commit 39e48b8977
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 117 additions and 0 deletions

View File

@ -60,6 +60,8 @@ class ChecklistAdapter(activity: BaseSimpleActivity, var items: ArrayList<Checkl
}
when (id) {
R.id.cab_move_to_top -> moveSelectedItemsToTop()
R.id.cab_move_to_bottom -> moveSelectedItemsToBottom()
R.id.cab_rename -> renameChecklistItem()
R.id.cab_delete -> deleteSelection()
}
@ -145,6 +147,31 @@ class ChecklistAdapter(activity: BaseSimpleActivity, var items: ArrayList<Checkl
}
}
private fun moveSelectedItemsToTop() {
selectedKeys.withIndex()
.reversed()
.forEach { keys ->
val position = items.indexOfFirst { it.id == keys.value }
val tempItem = items[position]
items.removeAt(position)
items.add(0, tempItem)
}
notifyDataSetChanged()
listener?.saveChecklist()
}
private fun moveSelectedItemsToBottom() {
selectedKeys.withIndex()
.forEach { keys ->
val position = items.indexOfFirst { it.id == keys.value }
val tempItem = items[position]
items.removeAt(position)
items.add(items.size, tempItem)
}
notifyDataSetChanged()
listener?.saveChecklist()
}
private fun getItemWithKey(key: Int): ChecklistItem? = items.firstOrNull { it.id == key }
private fun getSelectedItems() = items.filter { selectedKeys.contains(it.id) } as ArrayList<ChecklistItem>

View File

@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#FFFFFF"
android:alpha="0.8">
<path
android:fillColor="@android:color/white"
android:pathData="M16,13h-3V3h-2v10H8l4,4 4,-4zM4,19v2h16v-2H4z"/>
</vector>

View File

@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#FFFFFF"
android:alpha="0.8">
<path
android:fillColor="@android:color/white"
android:pathData="M8,11h3v10h2V11h3l-4,-4 -4,4zM4,3v2h16V3H4z"/>
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

View File

@ -1,6 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/cab_move_to_top"
android:icon="@drawable/ic_move_to_top"
android:title="@string/move_to_top"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/cab_move_to_bottom"
android:icon="@drawable/ic_move_to_bottom"
android:title="@string/move_to_bottom"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/cab_rename"
android:icon="@drawable/ic_rename_new"

View File

@ -56,6 +56,8 @@
<string name="add_new_checklist_items">إضافة عناصر قائمة تدقيق جديدة</string>
<string name="checklist_is_empty">قائمة التدقيق فارغة</string>
<string name="remove_done_items">Remove done items</string>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">تصدير جميع الملاحظات كملفات</string>

View File

@ -56,6 +56,8 @@
<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>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">Bütün qeydləri fayl şəklində çıxar</string>

View File

@ -56,6 +56,8 @@
<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>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">Exportovat všechny poznámky jako soubory</string>

View File

@ -56,6 +56,8 @@
<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>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">Allforio pob nodyn fel ffeil</string>

View File

@ -56,6 +56,8 @@
<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>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">Eksporter alle noter som filer</string>

View File

@ -56,6 +56,8 @@
<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>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">Alle Notizen als Dateien exportieren</string>

View File

@ -56,6 +56,8 @@
<string name="add_new_checklist_items">Προσθήκη νέων στοιχείων λίστας ελέγχου</string>
<string name="checklist_is_empty">Η λίστα ελέγχου είναι κενή</string>
<string name="remove_done_items">Remove done items</string>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">Εξαγωγή όλων των σημειώσεων ως αρχεία</string>

View File

@ -56,6 +56,8 @@
<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>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">Exportar todas las notas como archivos</string>

View File

@ -56,6 +56,8 @@
<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>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">Exporter toutes les notes en tant que fichiers</string>

View File

@ -56,6 +56,8 @@
<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>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">Exportar todas as notas como ficheiros</string>

View File

@ -56,6 +56,8 @@
<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>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">Izvezi sve bilješke kao datoteke</string>

View File

@ -56,6 +56,8 @@
<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>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">Export all notes as files</string>

View File

@ -56,6 +56,8 @@
<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>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">Ekspor semua catatan ke berkas</string>

View File

@ -56,6 +56,8 @@
<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>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">Ekspor semua catatan ke berkas</string>

View File

@ -56,6 +56,8 @@
<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>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">Esporta le note come file</string>

View File

@ -56,6 +56,8 @@
<string name="add_new_checklist_items">新しいチェックリスト項目を追加</string>
<string name="checklist_is_empty">チェックリストが空です</string>
<string name="remove_done_items">Remove done items</string>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">すべてのメモをファイルとしてエクスポート</string>

View File

@ -56,6 +56,8 @@
<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>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">Eksportuoti visus užrašus kaip bylas</string>

View File

@ -56,6 +56,8 @@
<string name="add_new_checklist_items">Items toevoegen</string>
<string name="checklist_is_empty">De lijst is leeg</string>
<string name="remove_done_items">Afgeronde items wissen</string>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">Alle notities naar bestanden exporteren</string>

View File

@ -56,6 +56,8 @@
<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>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">Eksportuj wszystkie notatki jako pliki</string>

View File

@ -56,6 +56,8 @@
<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>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">Exportar todas as notas como arquivo</string>

View File

@ -56,6 +56,8 @@
<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">Remover itens realizados</string>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">Exportar todas as notas como ficheiros</string>

View File

@ -56,6 +56,8 @@
<string name="add_new_checklist_items">Добавить позиции в список</string>
<string name="checklist_is_empty">Список пуст</string>
<string name="remove_done_items">Remove done items</string>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">Экспортировать все заметки в файлы</string>

View File

@ -56,6 +56,8 @@
<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">Odstrániť splnené položky</string>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">Exportovať všetky poznámky ako súbory</string>

View File

@ -56,6 +56,8 @@
<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>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">Exportera alla anteckningar som filer</string>

View File

@ -56,6 +56,8 @@
<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>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">Tüm notları dosya olarak dışa aktar</string>

View File

@ -56,6 +56,8 @@
<string name="add_new_checklist_items">Додати нові позиції у списку</string>
<string name="checklist_is_empty">Список порожній</string>
<string name="remove_done_items">Remove done items</string>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">Експортувати всі нотатки як файли</string>

View File

@ -56,6 +56,8 @@
<string name="add_new_checklist_items">添加新的清单项目</string>
<string name="checklist_is_empty">清单为空</string>
<string name="remove_done_items">Remove done items</string>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">以文件导出所有笔记</string>

View File

@ -56,6 +56,8 @@
<string name="add_new_checklist_items">新增新的核對清單項目</string>
<string name="checklist_is_empty">核對清單為空白</string>
<string name="remove_done_items">Remove done items</string>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">將全部筆記匯出成檔案</string>

View File

@ -56,6 +56,8 @@
<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>
<string name="move_to_top">Move to top</string>
<string name="move_to_bottom">Move to bottom</string>
<!-- Import / Export -->
<string name="export_all_notes">Export all notes as files</string>