mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
More updates to filtered library
Remove swipe to refresh on this screen Remove filter sheet and throw group library and display options into the toolbar
This commit is contained in:
parent
f9fcd8fab7
commit
1ad3034a3d
3 changed files with 77 additions and 42 deletions
|
@ -3,13 +3,15 @@ package eu.kanade.tachiyomi.ui.library
|
|||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||
import com.bluelinelabs.conductor.ControllerChangeType
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet
|
||||
import eu.kanade.tachiyomi.ui.more.stats.details.StatsDetailsController
|
||||
import eu.kanade.tachiyomi.util.view.collapse
|
||||
import eu.kanade.tachiyomi.util.view.hide
|
||||
import eu.kanade.tachiyomi.util.view.previousController
|
||||
|
||||
class FilteredLibraryController(bundle: Bundle? = null) : LibraryController(bundle) {
|
||||
|
@ -72,23 +74,46 @@ class FilteredLibraryController(bundle: Bundle? = null) : LibraryController(bund
|
|||
|
||||
override fun onViewCreated(view: View) {
|
||||
super.onViewCreated(view)
|
||||
binding.filterBottomSheet.root.sheetBehavior?.isHideable = false
|
||||
binding.filterBottomSheet.root.sheetBehavior?.collapse()
|
||||
binding.filterBottomSheet.filterScroll.isVisible = false
|
||||
binding.filterBottomSheet.secondLayout.isVisible = false
|
||||
binding.filterBottomSheet.viewOptions.isVisible = false
|
||||
binding.filterBottomSheet.pill.isVisible = false
|
||||
binding.filterBottomSheet.root.sheetBehavior?.hide()
|
||||
binding.swipeRefresh.isEnabled = false
|
||||
queryText?.let { search(it) }
|
||||
}
|
||||
|
||||
override fun showFloatingBar() = false
|
||||
|
||||
override fun handleBack(): Boolean {
|
||||
if (binding.recyclerCover.isClickable) {
|
||||
showCategories(false)
|
||||
return true
|
||||
override fun showCategories(show: Boolean, closeSearch: Boolean, category: Int) {
|
||||
super.showCategories(show, closeSearch, category)
|
||||
binding.swipeRefresh.isEnabled = false
|
||||
}
|
||||
|
||||
override fun onActionStateChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int) {
|
||||
super.onActionStateChanged(viewHolder, actionState)
|
||||
binding.swipeRefresh.isEnabled = false
|
||||
}
|
||||
|
||||
override fun onItemReleased(position: Int) {
|
||||
super.onItemReleased(position)
|
||||
binding.swipeRefresh.isEnabled = false
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
inflater.inflate(R.menu.filtered_library, menu)
|
||||
val groupItem = menu.findItem(R.id.action_group_by)
|
||||
groupItem?.setIcon(LibraryGroup.groupTypeDrawableRes(presenter.groupType))
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.action_group_by -> showGroupOptions()
|
||||
R.id.display_options -> showDisplayOptions()
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
}
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onNextLibraryUpdate(mangaMap: List<LibraryItem>, freshStart: Boolean) {
|
||||
super.onNextLibraryUpdate(mangaMap, freshStart)
|
||||
activity?.invalidateOptionsMenu()
|
||||
}
|
||||
|
||||
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
||||
|
@ -96,6 +121,7 @@ class FilteredLibraryController(bundle: Bundle? = null) : LibraryController(bund
|
|||
if (type == ControllerChangeType.POP_ENTER) {
|
||||
updateStatsPage()
|
||||
}
|
||||
binding.filterBottomSheet.root.sheetBehavior?.hide()
|
||||
}
|
||||
|
||||
override fun deleteMangasFromLibrary() {
|
||||
|
@ -107,8 +133,10 @@ class FilteredLibraryController(bundle: Bundle? = null) : LibraryController(bund
|
|||
(previousController as? StatsDetailsController)?.updateLibrary()
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {}
|
||||
override fun showSheet() { }
|
||||
override fun toggleSheet() {
|
||||
closeTip()
|
||||
}
|
||||
override fun toggleCategoryVisibility(position: Int) {}
|
||||
override fun hasActiveFiltersFromPref(): Boolean = false
|
||||
override fun manageCategory(position: Int) {}
|
||||
}
|
||||
|
|
|
@ -515,7 +515,7 @@ open class LibraryController(
|
|||
}
|
||||
}
|
||||
|
||||
private fun showGroupOptions() {
|
||||
internal fun showGroupOptions() {
|
||||
val groupItems = mutableListOf(BY_DEFAULT, BY_TAG, BY_SOURCE, BY_STATUS, BY_AUTHOR)
|
||||
if (presenter.isLoggedIntoTracking) {
|
||||
groupItems.add(BY_TRACK_STATUS)
|
||||
|
@ -547,14 +547,14 @@ open class LibraryController(
|
|||
}.show()
|
||||
}
|
||||
|
||||
private fun showDisplayOptions() {
|
||||
if (displaySheet == null && !isSubClass) {
|
||||
internal fun showDisplayOptions() {
|
||||
if (displaySheet == null) {
|
||||
displaySheet = TabbedLibraryDisplaySheet(this)
|
||||
displaySheet?.show()
|
||||
}
|
||||
}
|
||||
|
||||
private fun closeTip() {
|
||||
internal fun closeTip() {
|
||||
if (filterTooltip != null) {
|
||||
filterTooltip?.close()
|
||||
filterTooltip = null
|
||||
|
@ -753,10 +753,12 @@ open class LibraryController(
|
|||
3 -> showGroupOptions()
|
||||
2 -> showDisplayOptions()
|
||||
1 -> if (canCollapseOrExpandCategory() != null) presenter.toggleAllCategoryVisibility()
|
||||
else -> activityBinding?.searchToolbar?.menu?.performIdentifierAction(
|
||||
R.id.action_search,
|
||||
0,
|
||||
)
|
||||
else -> if (!isSubClass) {
|
||||
activityBinding?.searchToolbar?.menu?.performIdentifierAction(
|
||||
R.id.action_search,
|
||||
0,
|
||||
)
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
@ -832,14 +834,9 @@ open class LibraryController(
|
|||
(listOfYs.minOrNull() ?: binding.filterBottomSheet.filterBottomSheet.y) +
|
||||
hopperOffset +
|
||||
binding.libraryGridRecycler.recycler.translationY
|
||||
val bottom = if (isSubClass) {
|
||||
binding.filterBottomSheet.root.height + binding.jumperCategoryText.height + 12.dpToPx
|
||||
} else {
|
||||
insetBottom
|
||||
}
|
||||
if (view.height - bottom < binding.categoryHopperFrame.y) {
|
||||
if (view.height - insetBottom < binding.categoryHopperFrame.y) {
|
||||
binding.jumperCategoryText.translationY =
|
||||
-(binding.categoryHopperFrame.y - (view.height - bottom)) +
|
||||
-(binding.categoryHopperFrame.y - (view.height - insetBottom)) +
|
||||
binding.libraryGridRecycler.recycler.translationY
|
||||
} else {
|
||||
binding.jumperCategoryText.translationY = binding.libraryGridRecycler.recycler.translationY
|
||||
|
@ -1087,7 +1084,7 @@ open class LibraryController(
|
|||
super.onDestroyView(view)
|
||||
}
|
||||
|
||||
fun onNextLibraryUpdate(mangaMap: List<LibraryItem>, freshStart: Boolean = false) {
|
||||
open fun onNextLibraryUpdate(mangaMap: List<LibraryItem>, freshStart: Boolean = false) {
|
||||
view ?: return
|
||||
destroyActionModeIfNeeded()
|
||||
if (mangaMap.isNotEmpty()) {
|
||||
|
@ -1257,7 +1254,7 @@ open class LibraryController(
|
|||
.setDuration(duration)
|
||||
}
|
||||
|
||||
internal fun showCategories(show: Boolean, closeSearch: Boolean = false, category: Int = -1) {
|
||||
open fun showCategories(show: Boolean, closeSearch: Boolean = false, category: Int = -1) {
|
||||
binding.recyclerCover.isClickable = show
|
||||
binding.recyclerCover.isFocusable = show
|
||||
(activity as? MainActivity)?.apply {
|
||||
|
@ -1761,7 +1758,7 @@ open class LibraryController(
|
|||
* null = is in single category mode
|
||||
*/
|
||||
fun canCollapseOrExpandCategory(): Boolean? {
|
||||
if (singleCategory || !presenter.showAllCategories) {
|
||||
if (singleCategory || !presenter.showAllCategories || isSubClass) {
|
||||
return null
|
||||
}
|
||||
return presenter.allCategoriesExpanded()
|
||||
|
@ -2147,13 +2144,4 @@ open class LibraryController(
|
|||
destroyActionModeIfNeeded()
|
||||
}
|
||||
}
|
||||
|
||||
open fun hasActiveFiltersFromPref(): Boolean {
|
||||
return preferences.filterDownloaded().get() > 0 ||
|
||||
preferences.filterUnread().get() > 0 ||
|
||||
preferences.filterCompleted().get() > 0 ||
|
||||
preferences.filterTracked().get() > 0 ||
|
||||
preferences.filterMangaType().get() > 0 ||
|
||||
FilterBottomSheet.FILTER_TRACKER.isNotEmpty()
|
||||
}
|
||||
}
|
||||
|
|
19
app/src/main/res/menu/filtered_library.xml
Normal file
19
app/src/main/res/menu/filtered_library.xml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
app:tint="@android:color/black"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_group_by"
|
||||
android:icon="@drawable/ic_label_outline_24dp"
|
||||
android:title="@string/group_library_by"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/display_options"
|
||||
android:icon="@drawable/ic_tune_24dp"
|
||||
android:title="@string/display_options"
|
||||
app:showAsAction="ifRoom" />
|
||||
</menu>
|
Loading…
Add table
Add a link
Reference in a new issue