From bc473055b94d49dd3a1fde95664893a487b48574 Mon Sep 17 00:00:00 2001 From: NoodleMage Date: Fri, 18 Mar 2016 00:13:29 +0100 Subject: [PATCH] Changed fragment_manga_chapters.xml. Fix #221 --- .../tachiyomi/ui/library/LibraryFragment.kt | 4 +- .../ui/manga/chapter/ChaptersFragment.kt | 48 +++++------ .../drawable/ic_sort_by_alpha_white_24dp.xml | 9 ++ .../res/layout/fragment_manga_chapters.xml | 83 ++----------------- app/src/main/res/menu/chapters.xml | 30 ++++++- app/src/main/res/values/strings.xml | 1 + 6 files changed, 67 insertions(+), 108 deletions(-) create mode 100644 app/src/main/res/drawable/ic_sort_by_alpha_white_24dp.xml diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryFragment.kt index d064cf55f..4708ca9ed 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryFragment.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryFragment.kt @@ -76,12 +76,12 @@ class LibraryFragment : BaseRxFragment(), ActionMode.Callback /** - * TODO + * Status of isFilterDownloaded */ var isFilterDownloaded = false /** - * TODO + * Status of isFilterUnread */ var isFilterUnread = false diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.kt index fdc634e6e..83c22e734 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.kt @@ -1,7 +1,6 @@ package eu.kanade.tachiyomi.ui.manga.chapter import android.os.Bundle -import android.support.v4.content.ContextCompat import android.support.v7.view.ActionMode import android.support.v7.widget.LinearLayoutManager import android.view.* @@ -71,7 +70,7 @@ class ChaptersFragment : BaseRxFragment(), ActionMode.Callbac swipe_refresh.setOnRefreshListener { fetchChapters() } - next_unread_btn.setOnClickListener { v -> + fab.setOnClickListener { v -> val chapter = presenter.getNextUnreadChapter() if (chapter != null) { openChapter(chapter) @@ -93,35 +92,37 @@ class ChaptersFragment : BaseRxFragment(), ActionMode.Callbac override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { inflater.inflate(R.menu.chapters, menu) + menu.findItem(R.id.action_filter_unread).isChecked = presenter.onlyUnread() + menu.findItem(R.id.action_filter_downloaded).isChecked = presenter.onlyDownloaded() } override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { R.id.action_display_mode -> showDisplayModeDialog() R.id.manga_download -> showDownloadDialog() + R.id.action_filter_unread -> { + item.isChecked = !item.isChecked + presenter.setReadFilter(item.isChecked) + } + R.id.action_filter_downloaded -> { + item.isChecked = !item.isChecked + presenter.setDownloadedFilter(item.isChecked) + } + R.id.action_filter_empty -> { + presenter.setReadFilter(false) + presenter.setDownloadedFilter(false) + activity.supportInvalidateOptionsMenu(); + } + R.id.action_sort -> presenter.revertSortOrder() else -> return super.onOptionsItemSelected(item) } return true } fun onNextManga(manga: Manga) { - // Remove listeners before setting the values - show_unread.setOnCheckedChangeListener(null) - show_downloaded.setOnCheckedChangeListener(null) - sort_btn.setOnClickListener(null) - // Set initial values setReadFilter() setDownloadedFilter() - setSortIcon() - - // Init listeners - show_unread.setOnCheckedChangeListener { arg, isChecked -> presenter.setReadFilter(isChecked) } - show_downloaded.setOnCheckedChangeListener { v, isChecked -> presenter.setDownloadedFilter(isChecked) } - sort_btn.setOnClickListener { - presenter.revertSortOrder() - setSortIcon() - } } fun onNextChapters(chapters: List) { @@ -341,23 +342,12 @@ class ChaptersFragment : BaseRxFragment(), ActionMode.Callbac actionMode?.title = getString(R.string.label_selected, count) } - fun setSortIcon() { - sort_btn?.let { - val aToZ = presenter.sortOrder() - it.setImageResource(if (!aToZ) R.drawable.ic_expand_less_white_36dp else R.drawable.ic_expand_more_white_36dp) - } - } - fun setReadFilter() { - show_unread?.let { - it.isChecked = presenter.onlyUnread() - } + this.activity.supportInvalidateOptionsMenu() } fun setDownloadedFilter() { - show_downloaded?.let { - it.isChecked = presenter.onlyDownloaded() - } + this.activity.supportInvalidateOptionsMenu() } } diff --git a/app/src/main/res/drawable/ic_sort_by_alpha_white_24dp.xml b/app/src/main/res/drawable/ic_sort_by_alpha_white_24dp.xml new file mode 100644 index 000000000..34602f23b --- /dev/null +++ b/app/src/main/res/drawable/ic_sort_by_alpha_white_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/fragment_manga_chapters.xml b/app/src/main/res/layout/fragment_manga_chapters.xml index d5f5770ba..b62c2bf33 100644 --- a/app/src/main/res/layout/fragment_manga_chapters.xml +++ b/app/src/main/res/layout/fragment_manga_chapters.xml @@ -1,5 +1,6 @@ - + - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/menu/chapters.xml b/app/src/main/res/menu/chapters.xml index 5beb7871e..b4108a001 100644 --- a/app/src/main/res/menu/chapters.xml +++ b/app/src/main/res/menu/chapters.xml @@ -3,12 +3,38 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5726b84cc..0e1d97fca 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -48,6 +48,7 @@ Open in browser Change display mode Cancel + Sort OK