mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-25 03:01:52 +01:00
Added expand all/collapse all categories in filter sheet
This commit is contained in:
parent
d38bb54d83
commit
348795666d
@ -412,6 +412,7 @@ class LibraryController(
|
|||||||
FilterBottomSheet.ACTION_FILTER -> onFilterChanged()
|
FilterBottomSheet.ACTION_FILTER -> onFilterChanged()
|
||||||
FilterBottomSheet.ACTION_HIDE_FILTER_TIP -> showFilterTip()
|
FilterBottomSheet.ACTION_HIDE_FILTER_TIP -> showFilterTip()
|
||||||
FilterBottomSheet.ACTION_DISPLAY -> DisplayBottomSheet(this).show()
|
FilterBottomSheet.ACTION_DISPLAY -> DisplayBottomSheet(this).show()
|
||||||
|
FilterBottomSheet.ACTION_EXPAND_COLLAPSE_ALL -> presenter.toggleAllCategoryVisibility()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -638,6 +639,7 @@ class LibraryController(
|
|||||||
category_hopper_frame.visibleIf(!singleCategory)
|
category_hopper_frame.visibleIf(!singleCategory)
|
||||||
adapter.isLongPressDragEnabled = canDrag()
|
adapter.isLongPressDragEnabled = canDrag()
|
||||||
category_recycler.setCategories(presenter.categories)
|
category_recycler.setCategories(presenter.categories)
|
||||||
|
filter_bottom_sheet.setExpandText(preferences.collapsedCategories().getOrDefault().isNotEmpty())
|
||||||
setActiveCategory()
|
setActiveCategory()
|
||||||
if (onRoot) {
|
if (onRoot) {
|
||||||
activity?.toolbar?.setOnClickListener {
|
activity?.toolbar?.setOnClickListener {
|
||||||
|
@ -789,6 +789,15 @@ class LibraryPresenter(
|
|||||||
getLibrary()
|
getLibrary()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun toggleAllCategoryVisibility() {
|
||||||
|
if (preferences.collapsedCategories().getOrDefault().isEmpty()) {
|
||||||
|
preferences.collapsedCategories().set(categories.map { it.id.toString() }.toMutableSet())
|
||||||
|
} else {
|
||||||
|
preferences.collapsedCategories().set(mutableSetOf())
|
||||||
|
}
|
||||||
|
getLibrary()
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private var lastLibraryItems: List<LibraryItem>? = null
|
private var lastLibraryItems: List<LibraryItem>? = null
|
||||||
private var lastCategories: List<Category>? = null
|
private var lastCategories: List<Category>? = null
|
||||||
|
@ -98,11 +98,8 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
if (preferences.hideFiltersAtStart().getOrDefault()) {
|
if (preferences.hideFiltersAtStart().getOrDefault()) {
|
||||||
sheetBehavior?.hide()
|
sheetBehavior?.hide()
|
||||||
}
|
}
|
||||||
hide_filters.isChecked = preferences.hideFiltersAtStart().getOrDefault()
|
expand_categories.setOnClickListener {
|
||||||
hide_filters.setOnCheckedChangeListener { _, isChecked ->
|
onGroupClicked(ACTION_EXPAND_COLLAPSE_ALL)
|
||||||
preferences.hideFiltersAtStart().set(isChecked)
|
|
||||||
if (isChecked)
|
|
||||||
onGroupClicked(ACTION_HIDE_FILTER_TIP)
|
|
||||||
}
|
}
|
||||||
view_options.setOnClickListener {
|
view_options.setOnClickListener {
|
||||||
onGroupClicked(ACTION_DISPLAY)
|
onGroupClicked(ACTION_DISPLAY)
|
||||||
@ -127,6 +124,23 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
clearButton.setOnClickListener { clearFilters() }
|
clearButton.setOnClickListener { clearFilters() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setExpandText(expand: Boolean) {
|
||||||
|
expand_categories.setText(
|
||||||
|
if (expand) {
|
||||||
|
R.string.expand_all_categories
|
||||||
|
} else {
|
||||||
|
R.string.collapse_all_categories
|
||||||
|
}
|
||||||
|
)
|
||||||
|
expand_categories.setIconResource(
|
||||||
|
if (expand) {
|
||||||
|
R.drawable.ic_expand_less_24dp
|
||||||
|
} else {
|
||||||
|
R.drawable.ic_expand_more_24dp
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
private fun stateChanged(state: Int) {
|
private fun stateChanged(state: Int) {
|
||||||
val shadow = ((pager?.parent as? ViewGroup)?.findViewById(R.id.shadow) as? View)
|
val shadow = ((pager?.parent as? ViewGroup)?.findViewById(R.id.shadow) as? View)
|
||||||
if (state == BottomSheetBehavior.STATE_COLLAPSED) {
|
if (state == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||||
@ -379,6 +393,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
const val ACTION_FILTER = 1
|
const val ACTION_FILTER = 1
|
||||||
const val ACTION_HIDE_FILTER_TIP = 2
|
const val ACTION_HIDE_FILTER_TIP = 2
|
||||||
const val ACTION_DISPLAY = 3
|
const val ACTION_DISPLAY = 3
|
||||||
|
const val ACTION_EXPAND_COLLAPSE_ALL = 4
|
||||||
|
|
||||||
const val STATE_IGNORE = 0
|
const val STATE_IGNORE = 0
|
||||||
const val STATE_INCLUDE = 1
|
const val STATE_INCLUDE = 1
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/bottom_sheet_rounded_background"
|
android:background="@drawable/bottom_sheet_rounded_background"
|
||||||
|
android:elevation="12dp"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
app:behavior_peekHeight="60dp"
|
app:behavior_peekHeight="60dp"
|
||||||
android:elevation="12dp"
|
|
||||||
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
|
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
@ -76,24 +76,28 @@
|
|||||||
android:layout_marginEnd="20dp"
|
android:layout_marginEnd="20dp"
|
||||||
android:text="@string/hide_categories" />
|
android:text="@string/hide_categories" />
|
||||||
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/view_options"
|
android:id="@+id/expand_categories"
|
||||||
style="@style/Theme.Widget.Button.TextButton"
|
style="@style/Theme.Widget.Button.TextButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/display_options"
|
android:text="@string/expand_all_categories"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
app:icon="@drawable/ic_tune_white_24dp"
|
app:icon="@drawable/ic_expand_more_24dp"
|
||||||
app:iconTint="?android:attr/textColorPrimary" />
|
app:iconTint="?android:attr/textColorPrimary" />
|
||||||
|
|
||||||
<com.google.android.material.checkbox.MaterialCheckBox
|
|
||||||
android:id="@+id/hide_filters"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginEnd="20dp"
|
|
||||||
android:text="@string/start_with_filters_hidden"
|
|
||||||
android:visibility="gone" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/view_options"
|
||||||
|
style="@style/Theme.Widget.Button.TextButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:text="@string/display_options"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
app:icon="@drawable/ic_tune_white_24dp"
|
||||||
|
app:iconTint="?android:attr/textColorPrimary" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
@ -115,6 +115,8 @@
|
|||||||
library from the browse tab.</string>
|
library from the browse tab.</string>
|
||||||
<string name="no_matches_for_filters">No matches found for your current filters</string>
|
<string name="no_matches_for_filters">No matches found for your current filters</string>
|
||||||
<string name="show_all_categories">Show all categories</string>
|
<string name="show_all_categories">Show all categories</string>
|
||||||
|
<string name="expand_all_categories">Expand all categories</string>
|
||||||
|
<string name="collapse_all_categories">Collapse all categories</string>
|
||||||
|
|
||||||
<!-- Library Sort -->
|
<!-- Library Sort -->
|
||||||
<string name="sort_by_">Sort by: %1$s</string>
|
<string name="sort_by_">Sort by: %1$s</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user