From a083e1f71ace454a1081e2a673175a5e4b58ba66 Mon Sep 17 00:00:00 2001 From: Riztard Lanthorn Date: Sun, 24 Jan 2021 01:10:57 +0700 Subject: [PATCH] add sort by chapter number in download queue (#4337) * add sort by chapter number in download queue * Bigest, smallest chapter download * grouped --- .../ui/download/DownloadController.kt | 11 ++++++++ app/src/main/res/menu/download_queue.xml | 28 ++++++++++++++++--- app/src/main/res/values/strings.xml | 4 +++ 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadController.kt index 9768fda63a..fac8963516 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadController.kt @@ -157,6 +157,17 @@ class DownloadController : val downloads = items.mapNotNull { it.download } presenter.reorder(downloads) } + R.id.bigest, R.id.smallest -> { + val adapter = adapter ?: return false + val items = adapter.currentItems.sortedBy { it.download.chapter.chapter_number } + .toMutableList() + if (item.itemId == R.id.bigest) { + items.reverse() + } + adapter.updateDataSet(items) + val downloads = items.mapNotNull { it.download } + presenter.reorder(downloads) + } } return super.onOptionsItemSelected(item) } diff --git a/app/src/main/res/menu/download_queue.xml b/app/src/main/res/menu/download_queue.xml index 799cdfe2c3..b400bb8501 100644 --- a/app/src/main/res/menu/download_queue.xml +++ b/app/src/main/res/menu/download_queue.xml @@ -8,11 +8,31 @@ app:showAsAction="never"> + android:id="@+id/action_sort_date" + android:title="@string/action_order_by_upload_date" + app:showAsAction="never"> + + + + + + android:id="@+id/action_sort_chapter" + android:title="@string/action_order_by_chapter_number" + app:showAsAction="never"> + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5048277ee5..cb021c9eb3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -103,8 +103,12 @@ Sort Descending Reorder + By upload date + By chapter number Newest Oldest + Bigest + Smallest Move to top Move to bottom Install