Эх сурвалжийг харах

Combine chapter sort asc/desc and sorting mode menus

arkon 4 жил өмнө
parent
commit
18712b166f

+ 5 - 1
app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/MangaInfoChaptersController.kt

@@ -227,6 +227,7 @@ class MangaInfoChaptersController(private val fromSource: Boolean = false) :
             else -> throw NotImplementedError("Unimplemented sorting method")
         }
         menu.findItem(sortingItem).isChecked = true
+        menu.findItem(R.id.action_sort_descending).isChecked = presenter.manga.sortDescending()
     }
 
     override fun onOptionsItemSelected(item: MenuItem): Boolean {
@@ -252,6 +253,10 @@ class MangaInfoChaptersController(private val fromSource: Boolean = false) :
                 item.isChecked = true
                 presenter.setSorting(Manga.SORTING_UPLOAD_DATE)
             }
+            R.id.action_sort_descending -> {
+                presenter.reverseSortOrder()
+                activity?.invalidateOptionsMenu()
+            }
 
             R.id.download_next, R.id.download_next_5, R.id.download_next_10,
             R.id.download_custom, R.id.download_unread, R.id.download_all
@@ -281,7 +286,6 @@ class MangaInfoChaptersController(private val fromSource: Boolean = false) :
                 presenter.removeFilters()
                 activity?.invalidateOptionsMenu()
             }
-            R.id.action_sort -> presenter.revertSortOrder()
 
             R.id.action_migrate -> migrateManga()
         }

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/MangaInfoChaptersPresenter.kt

@@ -441,7 +441,7 @@ class MangaInfoChaptersPresenter(
     /**
      * Reverses the sorting and requests an UI update.
      */
-    fun revertSortOrder() {
+    fun reverseSortOrder() {
         manga.setChapterOrder(if (sortDescending()) Manga.SORT_ASC else Manga.SORT_DESC)
         db.updateFlags(manga).executeAsBlocking()
         refreshChapters()

+ 10 - 0
app/src/main/res/drawable/ic_sort_24dp.xml

@@ -0,0 +1,10 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:autoMirrored="true"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+    <path
+        android:fillColor="#FF000000"
+        android:pathData="M3,18h6v-2L3,16v2zM3,6v2h18L21,6L3,6zM3,13h12v-2L3,11v2z" />
+</vector>

+ 0 - 9
app/src/main/res/drawable/ic_sort_by_numeric_white_24dp.xml

@@ -1,9 +0,0 @@
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:width="24dp"
-        android:height="24dp"
-        android:viewportHeight="24.0"
-        android:viewportWidth="24.0">
-    <path
-        android:fillColor="#FFFFFFFF"
-        android:pathData="M7.78,7C9.08,7.04 10,7.53 10.57,8.46C11.13,9.4 11.41,10.56 11.39,11.95C11.4,13.5 11.09,14.73 10.5,15.62C9.88,16.5 8.95,16.97 7.71,17C6.45,16.96 5.54,16.5 4.96,15.56C4.38,14.63 4.09,13.45 4.09,12C4.09,10.55 4.39,9.36 5,8.44C5.59,7.5 6.5,7.04 7.78,7M7.75,8.63C7.31,8.63 6.96,8.9 6.7,9.46C6.44,10 6.32,10.87 6.32,12C6.31,13.15 6.44,14 6.69,14.54C6.95,15.1 7.31,15.37 7.77,15.37C8.69,15.37 9.16,14.24 9.17,12C9.17,9.77 8.7,8.65 7.75,8.63M13.33,17V15.22L13.76,15.24L14.3,15.22L15.34,15.03C15.68,14.92 16,14.78 16.26,14.58C16.59,14.35 16.86,14.08 17.07,13.76C17.29,13.45 17.44,13.12 17.53,12.78L17.5,12.77C17.05,13.19 16.38,13.4 15.47,13.41C14.62,13.4 13.91,13.15 13.34,12.65C12.77,12.15 12.5,11.43 12.46,10.5C12.47,9.5 12.81,8.69 13.47,8.03C14.14,7.37 15,7.03 16.12,7C17.37,7.04 18.29,7.45 18.88,8.24C19.47,9 19.76,10 19.76,11.19C19.75,12.15 19.61,13 19.32,13.76C19.03,14.5 18.64,15.13 18.12,15.64C17.66,16.06 17.11,16.38 16.47,16.61C15.83,16.83 15.12,16.96 14.34,17H13.33M16.06,8.63C15.65,8.64 15.32,8.8 15.06,9.11C14.81,9.42 14.68,9.84 14.68,10.36C14.68,10.8 14.8,11.16 15.03,11.46C15.27,11.77 15.63,11.92 16.11,11.93C16.43,11.93 16.7,11.86 16.92,11.74C17.14,11.61 17.3,11.46 17.41,11.28C17.5,11.17 17.53,10.97 17.53,10.71C17.54,10.16 17.43,9.69 17.2,9.28C16.97,8.87 16.59,8.65 16.06,8.63M9.25,5L12.5,1.75L15.75,5H9.25M15.75,19L12.5,22.25L9.25,19H15.75Z"/>
-</vector>

+ 20 - 20
app/src/main/res/menu/chapters.xml

@@ -32,41 +32,41 @@
     </item>
 
     <item
-        android:id="@+id/action_sort"
-        android:icon="@drawable/ic_sort_by_numeric_white_24dp"
-        android:title="@string/action_sort"
+        android:icon="@drawable/ic_sort_24dp"
+        android:title="@string/sorting_mode"
         app:iconTint="?attr/colorOnPrimary"
-        app:showAsAction="ifRoom" />
-
-    <item
-        android:title="@string/action_display_mode"
-        app:showAsAction="never">
+        app:showAsAction="ifRoom">
         <menu>
             <group android:checkableBehavior="single">
                 <item
-                    android:id="@+id/display_title"
-                    android:title="@string/show_title" />
+                    android:id="@+id/sort_by_source"
+                    android:title="@string/sort_by_source" />
                 <item
-                    android:id="@+id/display_chapter_number"
-                    android:title="@string/show_chapter_number" />
+                    android:id="@+id/sort_by_number"
+                    android:title="@string/sort_by_number" />
+                <item
+                    android:id="@+id/sort_by_upload_date"
+                    android:title="@string/sort_by_upload_date" />
             </group>
+
+            <item
+                android:id="@+id/action_sort_descending"
+                android:checkable="true"
+                android:title="@string/action_sort_descending" />
         </menu>
     </item>
 
     <item
-        android:title="@string/sorting_mode"
+        android:title="@string/action_display_mode"
         app:showAsAction="never">
         <menu>
             <group android:checkableBehavior="single">
                 <item
-                    android:id="@+id/sort_by_source"
-                    android:title="@string/sort_by_source" />
-                <item
-                    android:id="@+id/sort_by_number"
-                    android:title="@string/sort_by_number" />
+                    android:id="@+id/display_title"
+                    android:title="@string/show_title" />
                 <item
-                    android:id="@+id/sort_by_upload_date"
-                    android:title="@string/sort_by_upload_date" />
+                    android:id="@+id/display_chapter_number"
+                    android:title="@string/show_chapter_number" />
             </group>
         </menu>
     </item>

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

@@ -96,6 +96,7 @@
     <string name="action_cancel">Cancel</string>
     <string name="action_cancel_all">Cancel all</string>
     <string name="action_sort">Sort</string>
+    <string name="action_sort_descending">Descending</string>
     <string name="action_reorganize_by">Reorder</string>
     <string name="action_newest">Newest</string>
     <string name="action_oldest">Oldest</string>