mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 15:21:51 +01:00
Move reorder filters to display tab of library display options
Also renamed the last tab back to categories
This commit is contained in:
parent
cf18b148cc
commit
4b516e2a77
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -73,6 +73,6 @@ open class TabbedLibraryDisplaySheet(val controller: Controller) :
|
||||
override fun getTabTitles(): List<Int> = listOf(
|
||||
R.string.display,
|
||||
R.string.badges,
|
||||
R.string.more
|
||||
R.string.categories
|
||||
)
|
||||
}
|
||||
|
@ -11,22 +11,12 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/reorder_filters_button"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:icon="@drawable/ic_swap_vert_24dp"
|
||||
style="@style/Theme.Widget.Button.TextButton"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:iconTint="?android:attr/textColorPrimary"
|
||||
android:text="@string/reorder_filters" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/expand_collapse_categories"
|
||||
style="@style/Theme.Widget.Button.TextButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="textStart"
|
||||
app:icon="@drawable/ic_expand_more_24dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
|
@ -98,6 +98,18 @@
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:text="@string/uniform_grid_covers" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/reorder_filters_button"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="textStart"
|
||||
app:icon="@drawable/ic_swap_vert_24dp"
|
||||
style="@style/Theme.Widget.Button.TextButton"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:iconTint="?android:attr/textColorPrimary"
|
||||
android:text="@string/reorder_filters" />
|
||||
</LinearLayout>
|
||||
|
||||
<include
|
||||
|
Loading…
Reference in New Issue
Block a user