From 18712b166f493a94b0f326c49b50ff1be4d8bd8c Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 19 Jun 2020 16:27:17 -0400 Subject: [PATCH] Combine chapter sort asc/desc and sorting mode menus --- .../chapter/MangaInfoChaptersController.kt | 6 ++- .../chapter/MangaInfoChaptersPresenter.kt | 2 +- app/src/main/res/drawable/ic_sort_24dp.xml | 10 +++++ .../ic_sort_by_numeric_white_24dp.xml | 9 ---- app/src/main/res/menu/chapters.xml | 44 +++++++++---------- app/src/main/res/values/strings.xml | 1 + 6 files changed, 39 insertions(+), 33 deletions(-) create mode 100644 app/src/main/res/drawable/ic_sort_24dp.xml delete mode 100644 app/src/main/res/drawable/ic_sort_by_numeric_white_24dp.xml diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/MangaInfoChaptersController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/MangaInfoChaptersController.kt index 759beddd7d..46c60707e3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/MangaInfoChaptersController.kt +++ b/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() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/MangaInfoChaptersPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/MangaInfoChaptersPresenter.kt index 42a01bf200..72cfc7bc26 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/MangaInfoChaptersPresenter.kt +++ b/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() diff --git a/app/src/main/res/drawable/ic_sort_24dp.xml b/app/src/main/res/drawable/ic_sort_24dp.xml new file mode 100644 index 0000000000..28b2c9ecb5 --- /dev/null +++ b/app/src/main/res/drawable/ic_sort_24dp.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_sort_by_numeric_white_24dp.xml b/app/src/main/res/drawable/ic_sort_by_numeric_white_24dp.xml deleted file mode 100644 index 5bddea0f52..0000000000 --- a/app/src/main/res/drawable/ic_sort_by_numeric_white_24dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/menu/chapters.xml b/app/src/main/res/menu/chapters.xml index 312825790e..1530bb7591 100644 --- a/app/src/main/res/menu/chapters.xml +++ b/app/src/main/res/menu/chapters.xml @@ -32,11 +32,29 @@ + app:showAsAction="ifRoom"> + + + + + + + + + + - - - - - - - - - - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9d488dc7d9..cd13cc1444 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -96,6 +96,7 @@ Cancel Cancel all Sort + Descending Reorder Newest Oldest