mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 20:51:47 +01:00
Move library display settings out of filter sidebar
This commit is contained in:
parent
8feb4365dd
commit
a0a077eaaa
@ -191,8 +191,6 @@ class LibraryController(
|
|||||||
when (group) {
|
when (group) {
|
||||||
is LibraryNavigationView.FilterGroup -> onFilterChanged()
|
is LibraryNavigationView.FilterGroup -> onFilterChanged()
|
||||||
is LibraryNavigationView.SortGroup -> onSortChanged()
|
is LibraryNavigationView.SortGroup -> onSortChanged()
|
||||||
is LibraryNavigationView.DisplayGroup -> reattachAdapter()
|
|
||||||
is LibraryNavigationView.BadgeGroup -> onDownloadBadgeChanged()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,6 +358,16 @@ class LibraryController(
|
|||||||
// Tint icon if there's a filter active
|
// Tint icon if there's a filter active
|
||||||
val filterColor = if (navView.hasActiveFilters()) Color.rgb(255, 238, 7) else Color.WHITE
|
val filterColor = if (navView.hasActiveFilters()) Color.rgb(255, 238, 7) else Color.WHITE
|
||||||
DrawableCompat.setTint(filterItem.icon, filterColor)
|
DrawableCompat.setTint(filterItem.icon, filterColor)
|
||||||
|
|
||||||
|
// Display submenu
|
||||||
|
if (preferences.libraryAsList().getOrDefault()) {
|
||||||
|
menu.findItem(R.id.action_display_list).isChecked = true
|
||||||
|
} else {
|
||||||
|
menu.findItem(R.id.action_display_grid).isChecked = true
|
||||||
|
}
|
||||||
|
if (preferences.downloadBadge().getOrDefault()) {
|
||||||
|
menu.findItem(R.id.action_display_download_badge).isChecked = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
@ -371,6 +379,24 @@ class LibraryController(
|
|||||||
R.id.action_update_library -> {
|
R.id.action_update_library -> {
|
||||||
activity?.let { LibraryUpdateService.start(it) }
|
activity?.let { LibraryUpdateService.start(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Display submenu
|
||||||
|
R.id.action_display_grid -> {
|
||||||
|
item.isChecked = true
|
||||||
|
preferences.libraryAsList().set(false)
|
||||||
|
reattachAdapter()
|
||||||
|
}
|
||||||
|
R.id.action_display_list -> {
|
||||||
|
item.isChecked = true
|
||||||
|
preferences.libraryAsList().set(true)
|
||||||
|
reattachAdapter()
|
||||||
|
}
|
||||||
|
R.id.action_display_download_badge -> {
|
||||||
|
item.isChecked = !item.isChecked
|
||||||
|
preferences.downloadBadge().set(item.isChecked)
|
||||||
|
onDownloadBadgeChanged()
|
||||||
|
}
|
||||||
|
|
||||||
R.id.action_source_migration -> {
|
R.id.action_source_migration -> {
|
||||||
router.pushController(MigrationController().withFadeTransaction())
|
router.pushController(MigrationController().withFadeTransaction())
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A
|
|||||||
/**
|
/**
|
||||||
* List of groups shown in the view.
|
* List of groups shown in the view.
|
||||||
*/
|
*/
|
||||||
private val groups = listOf(FilterGroup(), SortGroup(), DisplayGroup(), BadgeGroup())
|
private val groups = listOf(FilterGroup(), SortGroup())
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapter instance.
|
* Adapter instance.
|
||||||
@ -79,7 +79,7 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A
|
|||||||
|
|
||||||
override val header = Item.Header(R.string.action_filter)
|
override val header = Item.Header(R.string.action_filter)
|
||||||
|
|
||||||
override val footer = Item.Separator()
|
override val footer = null
|
||||||
|
|
||||||
override fun initModels() {
|
override fun initModels() {
|
||||||
downloaded.checked = preferences.filterDownloaded().getOrDefault()
|
downloaded.checked = preferences.filterDownloaded().getOrDefault()
|
||||||
@ -121,7 +121,7 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A
|
|||||||
|
|
||||||
override val header = Item.Header(R.string.action_sort)
|
override val header = Item.Header(R.string.action_sort)
|
||||||
|
|
||||||
override val footer = Item.Separator()
|
override val footer = null
|
||||||
|
|
||||||
override fun initModels() {
|
override fun initModels() {
|
||||||
val sorting = preferences.librarySortingMode().getOrDefault()
|
val sorting = preferences.librarySortingMode().getOrDefault()
|
||||||
@ -163,55 +163,4 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class BadgeGroup : Group {
|
|
||||||
private val downloadBadge = Item.CheckboxGroup(R.string.action_display_download_badge, this)
|
|
||||||
override val header = null
|
|
||||||
override val footer = null
|
|
||||||
override val items = listOf(downloadBadge)
|
|
||||||
override fun initModels() {
|
|
||||||
downloadBadge.checked = preferences.downloadBadge().getOrDefault()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onItemClicked(item: Item) {
|
|
||||||
item as Item.CheckboxGroup
|
|
||||||
item.checked = !item.checked
|
|
||||||
preferences.downloadBadge().set((item.checked))
|
|
||||||
adapter.notifyItemChanged(item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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)
|
|
||||||
|
|
||||||
private val list = Item.Radio(R.string.action_display_list, this)
|
|
||||||
|
|
||||||
override val items = listOf(grid, list)
|
|
||||||
|
|
||||||
override val header = Item.Header(R.string.action_display)
|
|
||||||
|
|
||||||
override val footer = null
|
|
||||||
|
|
||||||
override fun initModels() {
|
|
||||||
val asList = preferences.libraryAsList().getOrDefault()
|
|
||||||
grid.checked = !asList
|
|
||||||
list.checked = asList
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onItemClicked(item: Item) {
|
|
||||||
item as Item.Radio
|
|
||||||
if (item.checked) return
|
|
||||||
|
|
||||||
item.group.items.forEach { (it as Item.Radio).checked = false }
|
|
||||||
item.checked = true
|
|
||||||
|
|
||||||
preferences.libraryAsList().set(item == list)
|
|
||||||
|
|
||||||
item.group.items.forEach { adapter.notifyItemChanged(it) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,27 @@
|
|||||||
android:title="@string/action_update_library"
|
android:title="@string/action_update_library"
|
||||||
app:showAsAction="ifRoom" />
|
app:showAsAction="ifRoom" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:title="@string/action_display"
|
||||||
|
app:showAsAction="never">
|
||||||
|
<menu>
|
||||||
|
<group
|
||||||
|
android:checkableBehavior="single">
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_display_grid"
|
||||||
|
android:title="@string/action_display_grid" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_display_list"
|
||||||
|
android:title="@string/action_display_list" />
|
||||||
|
</group>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_display_download_badge"
|
||||||
|
android:checkable="true"
|
||||||
|
android:title="@string/action_display_download_badge" />
|
||||||
|
</menu>
|
||||||
|
</item>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_source_migration"
|
android:id="@+id/action_source_migration"
|
||||||
android:title="@string/label_migration"
|
android:title="@string/label_migration"
|
||||||
|
Loading…
Reference in New Issue
Block a user