diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index 0a82278890..66150122e0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -271,6 +271,8 @@ class PreferencesHelper(val context: Context) { fun filterOrder() = flowPrefs.getString("filter_order", "rudcmt") + fun hideHopper() = flowPrefs.getBoolean("hide_hopper", false) + // Tutorial preferences fun shownFilterTutorial() = flowPrefs.getBoolean("shown_filter_tutorial", false) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/DisplayBottomSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/DisplayBottomSheet.kt index 5f7e34d4b8..3d95a6efe3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/DisplayBottomSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/DisplayBottomSheet.kt @@ -86,6 +86,9 @@ class DisplayBottomSheet(private val controller: LibraryController) : BottomShee show_all.bindToPreference(preferences.showAllCategories()) { controller.presenter.getLibrary() } + hide_hopper.bindToPreference(preferences.hideHopper()) { + controller.hideHopper(it) + } uniform_grid.bindToPreference(preferences.uniformGrid()) { controller.reattachAdapter() } @@ -122,11 +125,15 @@ class DisplayBottomSheet(private val controller: LibraryController) : BottomShee /** * Binds a checkbox or switch view with a boolean preference. */ - private fun CompoundButton.bindToPreference(pref: com.tfcporciuncula.flow.Preference, block: (() -> Unit)? = null) { + private fun CompoundButton.bindToPreference( + pref: com.tfcporciuncula.flow +.Preference, + block: ((Boolean) -> Unit)? = null + ) { isChecked = pref.get() setOnCheckedChangeListener { _, isChecked -> pref.set(isChecked) - block?.invoke() + block?.invoke(isChecked) } } 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 e1ad80f536..14214ba547 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 @@ -70,6 +70,7 @@ import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.hide import eu.kanade.tachiyomi.util.view.isExpanded import eu.kanade.tachiyomi.util.view.isHidden +import eu.kanade.tachiyomi.util.view.isVisible import eu.kanade.tachiyomi.util.view.scrollViewWith import eu.kanade.tachiyomi.util.view.setOnQueryTextChangeListener import eu.kanade.tachiyomi.util.view.setStyle @@ -347,6 +348,7 @@ class LibraryController( } else { preferences.hopperGravity().get() } + hideHopper(preferences.hideHopper().get()) category_hopper_frame.updateLayoutParams { anchorGravity = Gravity.TOP or when (gravityPref) { 0 -> Gravity.LEFT @@ -434,6 +436,11 @@ class LibraryController( } } + fun hideHopper(hide: Boolean) { + category_hopper_frame.visibleIf(!hide) + jumper_category_text.visibleIf(!hide) + } + private fun jumpToNextCategory(next: Boolean) { val category = getVisibleHeader() ?: return if (presenter.showAllCategories) { @@ -527,11 +534,19 @@ class LibraryController( return inflater.inflate(R.layout.library_list_controller, container, false) } + private fun anchorView(): View? { + return if (category_hopper_frame.isVisible()) { + category_hopper_frame + } else { + filter_bottom_sheet + } + } + private fun updateLibrary(category: Category? = null) { val view = view ?: return LibraryUpdateService.start(view.context, category) snack = view.snack(R.string.updating_library) { - anchorView = category_hopper_frame + anchorView = anchorView() view.elevation = 15f.dpToPx setAction(R.string.cancel) { LibraryUpdateService.stop(context) @@ -642,7 +657,7 @@ class LibraryController( if (justStarted && freshStart) { scrollToHeader(activeCategory) } - category_hopper_frame.visibleIf(!singleCategory) + category_hopper_frame.visibleIf(!singleCategory && !preferences.hideHopper().get()) filter_bottom_sheet.updateButtons( showHideCategories = presenter.allCategories.size > 1, showExpand = !singleCategory && presenter.showAllCategories @@ -1024,7 +1039,7 @@ class LibraryController( if (presenter.mangaIsInCategory(item.manga, newHeader?.category?.id)) { adapter.moveItem(position, lastItemPosition!!) snack = view?.snack(R.string.already_in_category) { - anchorView = category_hopper_frame + anchorView = anchorView() view.elevation = 15f.dpToPx } return @@ -1048,7 +1063,7 @@ class LibraryController( snack = view?.snack( resources!!.getString(R.string.moved_to_, category.name) ) { - anchorView = category_hopper_frame + anchorView = anchorView() view.elevation = 15f.dpToPx setAction(R.string.undo) { manga.category = category.id!! @@ -1070,7 +1085,7 @@ class LibraryController( }, category.name ), Snackbar.LENGTH_LONG ) { - anchorView = category_hopper_frame + anchorView = anchorView() view.elevation = 15f.dpToPx setAction(R.string.cancel) { LibraryUpdateService.stop(context) @@ -1246,7 +1261,7 @@ class LibraryController( snack = view?.snack( activity?.getString(R.string.removed_from_library) ?: "", Snackbar.LENGTH_INDEFINITE ) { - anchorView = category_hopper_frame + anchorView = anchorView() view.elevation = 15f.dpToPx var undoing = false setAction(R.string.undo) { diff --git a/app/src/main/res/layout/display_bottom_sheet.xml b/app/src/main/res/layout/display_bottom_sheet.xml index 03d884c6a5..df6057ba31 100644 --- a/app/src/main/res/layout/display_bottom_sheet.xml +++ b/app/src/main/res/layout/display_bottom_sheet.xml @@ -189,6 +189,14 @@ android:layout_marginEnd="12dp" android:text="@string/download_badge" /> + + Show count Tap the Library icon to show filters Display as + Hide category hopper More library settings