Add option to hide library category tabs
This commit is contained in:
parent
73dc51b3f6
commit
8c2b2f99bc
@ -147,6 +147,8 @@ object PreferenceKeys {
|
||||
|
||||
const val unreadBadge = "display_unread_badge"
|
||||
|
||||
const val categoryTabs = "display_category_tabs"
|
||||
|
||||
const val alwaysShowChapterTransition = "always_show_chapter_transition"
|
||||
|
||||
const val searchPinnedSourcesOnly = "search_pinned_sources_only"
|
||||
|
@ -193,6 +193,8 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
fun unreadBadge() = flowPrefs.getBoolean(Keys.unreadBadge, true)
|
||||
|
||||
fun categoryTabs() = flowPrefs.getBoolean(Keys.categoryTabs, true)
|
||||
|
||||
fun filterDownloaded() = flowPrefs.getBoolean(Keys.filterDownloaded, false)
|
||||
|
||||
fun filterUnread() = flowPrefs.getBoolean(Keys.filterUnread, false)
|
||||
|
@ -135,8 +135,26 @@ class LibraryController(
|
||||
retainViewMode = RetainViewMode.RETAIN_DETACH
|
||||
}
|
||||
|
||||
private var title: String? = null
|
||||
set(value) {
|
||||
if (field != value) {
|
||||
field = value
|
||||
setTitle()
|
||||
}
|
||||
}
|
||||
|
||||
override fun getTitle(): String? {
|
||||
return resources?.getString(R.string.label_library)
|
||||
return title ?: resources?.getString(R.string.label_library)
|
||||
}
|
||||
|
||||
private fun updateTitle() {
|
||||
if (preferences.categoryTabs().get()) {
|
||||
title = resources?.getString(R.string.label_library)
|
||||
} else {
|
||||
adapter?.categories?.get(binding.libraryPager.currentItem)?.let {
|
||||
title = it.name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun createPresenter(): LibraryPresenter {
|
||||
@ -157,6 +175,7 @@ class LibraryController(
|
||||
.onEach {
|
||||
preferences.lastUsedCategory().set(it)
|
||||
activeCategory = it
|
||||
updateTitle()
|
||||
}
|
||||
.launchIn(scope)
|
||||
|
||||
@ -175,7 +194,8 @@ class LibraryController(
|
||||
is LibrarySettingsSheet.Filter.FilterGroup -> onFilterChanged()
|
||||
is LibrarySettingsSheet.Sort.SortGroup -> onSortChanged()
|
||||
is LibrarySettingsSheet.Display.DisplayGroup -> reattachAdapter()
|
||||
is LibrarySettingsSheet.Display.BadgeGroup -> onBadgeChanged()
|
||||
is LibrarySettingsSheet.Display.BadgeGroup -> onBadgeSettingChanged()
|
||||
is LibrarySettingsSheet.Display.TabsGroup -> onTabsSettingsChanged()
|
||||
}
|
||||
}
|
||||
|
||||
@ -254,7 +274,8 @@ class LibraryController(
|
||||
// Restore active category.
|
||||
binding.libraryPager.setCurrentItem(activeCat, false)
|
||||
|
||||
tabsVisibilityRelay.call(categories.size > 1)
|
||||
// Trigger display of tabs
|
||||
onTabsSettingsChanged()
|
||||
|
||||
// Delay the scroll position to allow the view to be properly measured.
|
||||
view.post {
|
||||
@ -280,18 +301,20 @@ class LibraryController(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a filter is changed.
|
||||
*/
|
||||
private fun onFilterChanged() {
|
||||
presenter.requestFilterUpdate()
|
||||
activity?.invalidateOptionsMenu()
|
||||
}
|
||||
|
||||
private fun onBadgeChanged() {
|
||||
private fun onBadgeSettingChanged() {
|
||||
presenter.requestBadgesUpdate()
|
||||
}
|
||||
|
||||
private fun onTabsSettingsChanged() {
|
||||
tabsVisibilityRelay.call(preferences.categoryTabs().get() && adapter?.categories?.size ?: 0 > 1)
|
||||
updateTitle()
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the sorting mode is changed.
|
||||
*/
|
||||
|
@ -12,7 +12,7 @@ import eu.kanade.tachiyomi.widget.TabbedBottomSheetDialog
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class LibrarySettingsSheet(
|
||||
private val activity: Activity,
|
||||
activity: Activity,
|
||||
onGroupClickListener: (ExtendedNavigationView.Group) -> Unit
|
||||
) : TabbedBottomSheetDialog(activity) {
|
||||
|
||||
@ -178,7 +178,7 @@ class LibrarySettingsSheet(
|
||||
Settings(context, attrs) {
|
||||
|
||||
init {
|
||||
setGroups(listOf(DisplayGroup(), BadgeGroup()))
|
||||
setGroups(listOf(DisplayGroup(), BadgeGroup(), TabsGroup()))
|
||||
}
|
||||
|
||||
inner class DisplayGroup : Group {
|
||||
@ -187,7 +187,7 @@ class LibrarySettingsSheet(
|
||||
private val comfortableGrid = Item.Radio(R.string.action_display_comfortable_grid, this)
|
||||
private val list = Item.Radio(R.string.action_display_list, this)
|
||||
|
||||
override val header = null
|
||||
override val header = Item.Header(R.string.action_display_mode)
|
||||
override val items = listOf(compactGrid, comfortableGrid, list)
|
||||
override val footer = null
|
||||
|
||||
@ -222,7 +222,7 @@ class LibrarySettingsSheet(
|
||||
private val downloadBadge = Item.CheckboxGroup(R.string.action_display_download_badge, this)
|
||||
private val unreadBadge = Item.CheckboxGroup(R.string.action_display_unread_badge, this)
|
||||
|
||||
override val header = null
|
||||
override val header = Item.Header(R.string.badges_header)
|
||||
override val items = listOf(downloadBadge, unreadBadge)
|
||||
override val footer = null
|
||||
|
||||
@ -241,6 +241,27 @@ class LibrarySettingsSheet(
|
||||
adapter.notifyItemChanged(item)
|
||||
}
|
||||
}
|
||||
|
||||
inner class TabsGroup : Group {
|
||||
private val showTabs = Item.CheckboxGroup(R.string.action_display_show_tabs, this)
|
||||
|
||||
override val header = Item.Header(R.string.tabs_header)
|
||||
override val items = listOf(showTabs)
|
||||
override val footer = null
|
||||
|
||||
override fun initModels() {
|
||||
showTabs.checked = preferences.categoryTabs().get()
|
||||
}
|
||||
|
||||
override fun onItemClicked(item: Item) {
|
||||
item as Item.CheckboxGroup
|
||||
item.checked = !item.checked
|
||||
when (item) {
|
||||
showTabs -> preferences.categoryTabs().set((item.checked))
|
||||
}
|
||||
adapter.notifyItemChanged(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open inner class Settings(context: Context, attrs: AttributeSet?) :
|
||||
|
@ -12,6 +12,7 @@ abstract class TabbedBottomSheetDialog(private val activity: Activity) : BottomS
|
||||
val binding: CommonTabbedSheetBinding = CommonTabbedSheetBinding.inflate(activity.layoutInflater)
|
||||
|
||||
val adapter = LibrarySettingsSheetAdapter()
|
||||
binding.pager.offscreenPageLimit = 2
|
||||
binding.pager.adapter = adapter
|
||||
binding.tabs.setupWithViewPager(binding.pager)
|
||||
|
||||
|
@ -86,6 +86,7 @@
|
||||
<string name="action_display_comfortable_grid">Comfortable grid</string>
|
||||
<string name="action_display_download_badge">Download badges</string>
|
||||
<string name="action_display_unread_badge">Unread badges</string>
|
||||
<string name="action_display_show_tabs">Show category tabs</string>
|
||||
<string name="action_hide">Hide</string>
|
||||
<string name="action_pin">Pin</string>
|
||||
<string name="action_unpin">Unpin</string>
|
||||
@ -418,6 +419,8 @@
|
||||
<string name="local_source_badge">Local</string>
|
||||
<string name="confirm_delete_manga">Are you sure you want to remove selected manga?</string>
|
||||
<string name="also_delete_chapters">Also delete downloaded chapters</string>
|
||||
<string name="badges_header">Badges</string>
|
||||
<string name="tabs_header">Tabs</string>
|
||||
|
||||
<!-- Catalogue fragment -->
|
||||
<string name="source_requires_login">This source requires you to log in</string>
|
||||
|
Loading…
Reference in New Issue
Block a user