diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index bb8da54a1..3350a4454 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -166,10 +166,10 @@ class LibraryController( settingsSheet = LibrarySettingsSheet(activity!!) { group -> when (group) { - is LibrarySettingsSheet.FilterSettings.FilterGroup -> onFilterChanged() - is LibrarySettingsSheet.SortSettings.SortGroup -> onSortChanged() - is LibrarySettingsSheet.DisplaySettings.DisplayGroup -> reattachAdapter() - is LibrarySettingsSheet.DisplaySettings.BadgeGroup -> onDownloadBadgeChanged() + is LibrarySettingsSheet.Filter.FilterGroup -> onFilterChanged() + is LibrarySettingsSheet.Sort.SortGroup -> onSortChanged() + is LibrarySettingsSheet.Display.DisplayGroup -> reattachAdapter() + is LibrarySettingsSheet.Display.BadgeGroup -> onDownloadBadgeChanged() } } } @@ -359,7 +359,7 @@ class LibraryController( val filterItem = menu.findItem(R.id.action_filter) // Tint icon if there's a filter active - if (settingsSheet.hasActiveFilters()) { + if (settingsSheet.filters.hasActiveFilters()) { val filterColor = activity!!.getResourceColor(R.attr.colorFilterActive) DrawableCompat.setTint(filterItem.icon, filterColor) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsSheet.kt index a033d355c..a8778bfc0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsSheet.kt @@ -18,11 +18,12 @@ class LibrarySettingsSheet( private val onGroupClickListener: (ExtendedNavigationView.Group) -> Unit ) : BottomSheetDialog(activity) { - private val filterSettings = FilterSettings(activity) + val filters = Filter(activity) + private val tabItems = listOf( - Pair(R.string.action_filter, filterSettings), - Pair(R.string.action_sort, SortSettings(activity)), - Pair(R.string.action_display, DisplaySettings(activity)) + Pair(R.string.action_filter, filters), + Pair(R.string.action_sort, Sort(activity)), + Pair(R.string.action_display, Display(activity)) ) init { @@ -35,10 +36,6 @@ class LibrarySettingsSheet( setContentView(binding.root) } - fun hasActiveFilters(): Boolean { - return filterSettings.hasActiveFilters() - } - private inner class LibrarySettingsSheetAdapter : ViewPagerAdapter() { override fun createView(container: ViewGroup, position: Int): View { @@ -56,7 +53,10 @@ class LibrarySettingsSheet( } } - inner class FilterSettings @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : + /** + * Filters group (unread, downloaded, ...). + */ + inner class Filter @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : Settings(context, attrs) { private val filterGroup = FilterGroup() @@ -72,9 +72,6 @@ class LibrarySettingsSheet( return filterGroup.items.any { it.checked } } - /** - * Filters group (unread, downloaded, ...). - */ inner class FilterGroup : Group { private val downloaded = Item.CheckboxGroup(R.string.action_filter_downloaded, this) @@ -106,16 +103,16 @@ class LibrarySettingsSheet( } } - inner class SortSettings @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : + /** + * Sorting group (alphabetically, by last read, ...) and ascending or descending. + */ + inner class Sort @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : Settings(context, attrs) { init { addGroups(listOf(SortGroup())) } - /** - * Sorting group (alphabetically, by last read, ...) and ascending or descending. - */ inner class SortGroup : Group { private val alphabetically = Item.MultiSort(R.string.action_sort_alpha, this) @@ -181,16 +178,16 @@ class LibrarySettingsSheet( } } - inner class DisplaySettings @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : + /** + * Display group, to show the library as a list or a grid. + */ + inner class Display @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : Settings(context, attrs) { init { addGroups(listOf(DisplayGroup(), BadgeGroup())) } - /** - * Display group, to show the library as a list or a grid. - */ inner class DisplayGroup : Group { private val grid = Item.Radio(R.string.action_display_grid, this)