浏览代码

add sort by chapter number in download queue (#4337)

* add sort by chapter number in download queue

* Bigest, smallest chapter download

* grouped
Riztard Lanthorn 4 年之前
父节点
当前提交
a083e1f71a

+ 11 - 0
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)
     }

+ 24 - 4
app/src/main/res/menu/download_queue.xml

@@ -8,11 +8,31 @@
         app:showAsAction="never">
         <menu>
             <item
-                android:id="@+id/newest"
-                android:title="@string/action_newest" />
+                android:id="@+id/action_sort_date"
+                android:title="@string/action_order_by_upload_date"
+                app:showAsAction="never">
+                <menu>
+                    <item
+                        android:id="@+id/newest"
+                        android:title="@string/action_newest" />
+                    <item
+                        android:id="@+id/oldest"
+                        android:title="@string/action_oldest" />
+                </menu>
+            </item>
             <item
-                android:id="@+id/oldest"
-                android:title="@string/action_oldest" />
+                android:id="@+id/action_sort_chapter"
+                android:title="@string/action_order_by_chapter_number"
+                app:showAsAction="never">
+                <menu>
+                    <item
+                        android:id="@+id/bigest"
+                        android:title="@string/action_bigest" />
+                    <item
+                        android:id="@+id/smallest"
+                        android:title="@string/action_smallest" />
+                </menu>
+            </item>
         </menu>
     </item>
 

+ 4 - 0
app/src/main/res/values/strings.xml

@@ -103,8 +103,12 @@
     <string name="action_sort">Sort</string>
     <string name="action_sort_descending">Descending</string>
     <string name="action_reorganize_by">Reorder</string>
+    <string name="action_order_by_upload_date">By upload date</string>
+    <string name="action_order_by_chapter_number">By chapter number</string>
     <string name="action_newest">Newest</string>
     <string name="action_oldest">Oldest</string>
+    <string name="action_bigest">Bigest</string>
+    <string name="action_smallest">Smallest</string>
     <string name="action_move_to_top">Move to top</string>
     <string name="action_move_to_bottom">Move to bottom</string>
     <string name="action_install">Install</string>