From fd4876be24a04e31274d034db74d4dd7833b5094 Mon Sep 17 00:00:00 2001 From: arkon Date: Wed, 18 Mar 2020 18:15:53 -0400 Subject: [PATCH] Tint chapter filter icon if filters are enabled --- .../ui/manga/chapter/ChaptersController.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersController.kt index a2db71aa0..3e02954a6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersController.kt @@ -12,6 +12,7 @@ import android.view.View import android.view.ViewGroup import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.view.ActionMode +import androidx.core.graphics.drawable.DrawableCompat import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager import com.google.android.material.snackbar.Snackbar @@ -27,6 +28,7 @@ import eu.kanade.tachiyomi.ui.base.controller.NucleusController import eu.kanade.tachiyomi.ui.base.controller.popControllerWithTag import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.ui.reader.ReaderActivity +import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.util.view.getCoordinates import eu.kanade.tachiyomi.util.view.snack @@ -141,6 +143,7 @@ class ChaptersController : NucleusController(), val menuFilterUnread = menu.findItem(R.id.action_filter_unread) val menuFilterDownloaded = menu.findItem(R.id.action_filter_downloaded) val menuFilterBookmarked = menu.findItem(R.id.action_filter_bookmarked) + val menuFilterEmpty = menu.findItem(R.id.action_filter_empty) // Set correct checkbox values. menuFilterRead.isChecked = presenter.onlyRead() @@ -148,6 +151,16 @@ class ChaptersController : NucleusController(), menuFilterDownloaded.isChecked = presenter.onlyDownloaded() menuFilterBookmarked.isChecked = presenter.onlyBookmarked() + val filterSet = presenter.onlyRead() || presenter.onlyUnread() || presenter.onlyDownloaded() || presenter.onlyBookmarked() + + if (filterSet) { + val filterColor = activity!!.getResourceColor(R.attr.colorFilterActive) + DrawableCompat.setTint(menu.findItem(R.id.action_filter).icon, filterColor) + } + + // Only show remove filter option if there's a filter set. + menuFilterEmpty.isVisible = filterSet + // Disable unread filter option if read filter is enabled. if (presenter.onlyRead()) menuFilterUnread.isEnabled = false @@ -207,10 +220,12 @@ class ChaptersController : NucleusController(), R.id.action_filter_downloaded -> { item.isChecked = !item.isChecked presenter.setDownloadedFilter(item.isChecked) + activity?.invalidateOptionsMenu() } R.id.action_filter_bookmarked -> { item.isChecked = !item.isChecked presenter.setBookmarkedFilter(item.isChecked) + activity?.invalidateOptionsMenu() } R.id.action_filter_empty -> { presenter.removeFilters()