diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/LibraryCategoryView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/LibraryCategoryView.kt index c26544c690..5704c4cc5d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/LibraryCategoryView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/LibraryCategoryView.kt @@ -4,16 +4,9 @@ import android.content.Context import android.graphics.drawable.AnimatedVectorDrawable import android.util.AttributeSet import androidx.core.view.isVisible -import androidx.recyclerview.widget.LinearLayoutManager -import androidx.recyclerview.widget.RecyclerView -import com.afollestad.materialdialogs.MaterialDialog -import com.afollestad.materialdialogs.customview.customView -import eu.davidea.flexibleadapter.FlexibleAdapter import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.databinding.LibraryCategoryLayoutBinding import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet -import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet.Filters.Companion.DEFAULT_ORDER -import eu.kanade.tachiyomi.ui.library.filter.ManageFilterItem import eu.kanade.tachiyomi.util.bindToPreference import eu.kanade.tachiyomi.util.system.toInt import eu.kanade.tachiyomi.widget.BaseLibraryDisplayView @@ -53,32 +46,6 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att ?.onGroupClicked?.invoke(FilterBottomSheet.ACTION_EXPAND_COLLAPSE_ALL) } hopperLongPress.bindToPreference(preferences.hopperLongPressAction()) - - reorderFiltersButton.setOnClickListener { - val recycler = RecyclerView(context) - var filterOrder = preferences.filterOrder().get() - if (filterOrder.count() != 6) { - filterOrder = DEFAULT_ORDER - } - val adapter = FlexibleAdapter( - filterOrder.toCharArray().map(::ManageFilterItem), - this, - true - ) - recycler.layoutManager = LinearLayoutManager(context) - recycler.adapter = adapter - adapter.isHandleDragEnabled = true - adapter.isLongPressDragEnabled = true - MaterialDialog(context).title(R.string.reorder_filters) - .customView(view = recycler, scrollable = false) - .negativeButton(android.R.string.cancel) - .positiveButton(R.string.reorder) { - val order = adapter.currentItems.map { it.char }.joinToString("") - preferences.filterOrder().set(order) - recycler.adapter = null - } - .show() - } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/LibraryDisplayView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/LibraryDisplayView.kt index 7bb2668848..6453f035a4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/LibraryDisplayView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/LibraryDisplayView.kt @@ -7,8 +7,15 @@ import android.view.ViewTreeObserver import android.widget.SeekBar import androidx.core.animation.addListener import androidx.core.view.isVisible +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView +import com.afollestad.materialdialogs.MaterialDialog +import com.afollestad.materialdialogs.customview.customView +import eu.davidea.flexibleadapter.FlexibleAdapter import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.databinding.LibraryDisplayLayoutBinding +import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet +import eu.kanade.tachiyomi.ui.library.filter.ManageFilterItem import eu.kanade.tachiyomi.util.bindToPreference import eu.kanade.tachiyomi.util.lang.withSubtitle import eu.kanade.tachiyomi.util.system.dpToPx @@ -28,6 +35,33 @@ class LibraryDisplayView @JvmOverloads constructor(context: Context, attrs: Attr binding.resetGridSize.setOnClickListener { binding.gridSeekbar.progress = 3 } + + binding.reorderFiltersButton.setOnClickListener { + val recycler = RecyclerView(context) + var filterOrder = preferences.filterOrder().get() + if (filterOrder.count() != 6) { + filterOrder = FilterBottomSheet.Filters.DEFAULT_ORDER + } + val adapter = FlexibleAdapter( + filterOrder.toCharArray().map(::ManageFilterItem), + this, + true + ) + recycler.layoutManager = LinearLayoutManager(context) + recycler.adapter = adapter + adapter.isHandleDragEnabled = true + adapter.isLongPressDragEnabled = true + MaterialDialog(context).title(R.string.reorder_filters) + .customView(view = recycler, scrollable = false) + .negativeButton(android.R.string.cancel) + .positiveButton(R.string.reorder) { + val order = adapter.currentItems.map { it.char }.joinToString("") + preferences.filterOrder().set(order) + recycler.adapter = null + } + .show() + } + binding.root.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener { override fun onGlobalLayout() { if (binding.root.width > 0) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/TabbedLibraryDisplaySheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/TabbedLibraryDisplaySheet.kt index e39e3c23d9..603bbe2cda 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/TabbedLibraryDisplaySheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/TabbedLibraryDisplaySheet.kt @@ -73,6 +73,6 @@ open class TabbedLibraryDisplaySheet(val controller: Controller) : override fun getTabTitles(): List = listOf( R.string.display, R.string.badges, - R.string.more + R.string.categories ) } diff --git a/app/src/main/res/layout/library_category_layout.xml b/app/src/main/res/layout/library_category_layout.xml index a11e6e9572..4aea5a1a81 100644 --- a/app/src/main/res/layout/library_category_layout.xml +++ b/app/src/main/res/layout/library_category_layout.xml @@ -11,22 +11,12 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - + +