mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-09 05:25:08 +01:00
Moving collapse/expand categories button back to filter sheet
I just can't decide
This commit is contained in:
parent
4bb6dbf528
commit
17809d0493
@ -913,12 +913,12 @@ class LibraryController(
|
||||
}
|
||||
|
||||
binding.categoryHopperFrame.visibleIf(!singleCategory && !preferences.hideHopper().get())
|
||||
binding.filterBottomSheet.filterBottomSheet.updateButtons(
|
||||
groupType = presenter.groupType
|
||||
)
|
||||
adapter.isLongPressDragEnabled = canDrag()
|
||||
binding.categoryRecycler.setCategories(presenter.categories)
|
||||
displaySheet?.setExpandText(canCollapseOrExpandCategory())
|
||||
with(binding.filterBottomSheet.root) {
|
||||
updateGroupTypeButton(presenter.groupType)
|
||||
setExpandText(canCollapseOrExpandCategory())
|
||||
}
|
||||
if (shouldScrollToTop) {
|
||||
binding.libraryGridRecycler.recycler.scrollToPosition(0)
|
||||
shouldScrollToTop = false
|
||||
|
@ -1,12 +1,8 @@
|
||||
package eu.kanade.tachiyomi.ui.library.display
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.AnimatedVectorDrawable
|
||||
import android.util.AttributeSet
|
||||
import androidx.core.view.isVisible
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.databinding.LibraryCategoryLayoutBinding
|
||||
import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet
|
||||
import eu.kanade.tachiyomi.util.bindToPreference
|
||||
import eu.kanade.tachiyomi.util.system.toInt
|
||||
import eu.kanade.tachiyomi.widget.BaseLibraryDisplayView
|
||||
@ -41,41 +37,7 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
|
||||
addCategoriesButton.setOnClickListener {
|
||||
controller?.showCategoriesController()
|
||||
}
|
||||
expandCollapseCategories.setOnClickListener {
|
||||
controller?.binding?.filterBottomSheet?.root
|
||||
?.onGroupClicked?.invoke(FilterBottomSheet.ACTION_EXPAND_COLLAPSE_ALL)
|
||||
}
|
||||
hopperLongPress.bindToPreference(preferences.hopperLongPressAction())
|
||||
}
|
||||
}
|
||||
|
||||
fun setExpandText(allExpanded: Boolean?, animated: Boolean = true) {
|
||||
binding.expandCollapseCategories.isVisible = allExpanded != null
|
||||
allExpanded ?: return
|
||||
binding.expandCollapseCategories.setText(
|
||||
if (!allExpanded) {
|
||||
R.string.expand_all_categories
|
||||
} else {
|
||||
R.string.collapse_all_categories
|
||||
}
|
||||
)
|
||||
if (animated) {
|
||||
binding.expandCollapseCategories.setIconResource(
|
||||
if (!allExpanded) {
|
||||
R.drawable.anim_expand_less_to_more
|
||||
} else {
|
||||
R.drawable.anim_expand_more_to_less
|
||||
}
|
||||
)
|
||||
(binding.expandCollapseCategories.icon as? AnimatedVectorDrawable)?.start()
|
||||
} else {
|
||||
binding.expandCollapseCategories.setIconResource(
|
||||
if (!allExpanded) {
|
||||
R.drawable.ic_expand_more_24dp
|
||||
} else {
|
||||
R.drawable.ic_expand_less_24dp
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,18 +37,9 @@ open class TabbedLibraryDisplaySheet(val controller: Controller) :
|
||||
controller.router.pushController(SettingsLibraryController().withFadeTransaction())
|
||||
dismiss()
|
||||
}
|
||||
|
||||
if (controller is LibraryController) {
|
||||
setExpandText(controller.canCollapseOrExpandCategory(), false)
|
||||
} else {
|
||||
setExpandText(null)
|
||||
categoryView.binding.addCategoriesButton.isVisible = false
|
||||
}
|
||||
categoryView.binding.addCategoriesButton.isVisible = controller is LibraryController
|
||||
}
|
||||
|
||||
fun setExpandText(allExpanded: Boolean?, animated: Boolean = true) =
|
||||
categoryView.setExpandText(allExpanded, animated)
|
||||
|
||||
override fun dismiss() {
|
||||
super.dismiss()
|
||||
(controller as? LibraryController)?.displaySheet = null
|
||||
|
@ -1,12 +1,14 @@
|
||||
package eu.kanade.tachiyomi.ui.library.filter
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.AnimatedVectorDrawable
|
||||
import android.os.Parcelable
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.core.view.isVisible
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
@ -129,7 +131,22 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
}
|
||||
)
|
||||
|
||||
post {
|
||||
if (binding.secondLayout.width + binding.firstLayout.width + 20.dpToPx < width) {
|
||||
binding.secondLayout.removeView(binding.viewOptions)
|
||||
binding.firstLayout.addView(binding.viewOptions)
|
||||
binding.secondLayout.isVisible = false
|
||||
} else if (binding.viewOptions.parent == binding.firstLayout) {
|
||||
binding.firstLayout.removeView(binding.viewOptions)
|
||||
binding.secondLayout.addView(binding.viewOptions)
|
||||
binding.secondLayout.isVisible = true
|
||||
}
|
||||
}
|
||||
|
||||
sheetBehavior?.hide()
|
||||
binding.expandCategories.setOnClickListener {
|
||||
onGroupClicked(ACTION_EXPAND_COLLAPSE_ALL)
|
||||
}
|
||||
binding.groupBy.setOnClickListener {
|
||||
onGroupClicked(ACTION_GROUP_BY)
|
||||
}
|
||||
@ -157,6 +174,8 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
createTags()
|
||||
clearButton.setOnClickListener { clearFilters() }
|
||||
|
||||
setExpandText(controller.canCollapseOrExpandCategory(), false)
|
||||
|
||||
clearButton.compatToolTipText = context.getString(R.string.clear_filters)
|
||||
preferences.filterOrder().asFlow()
|
||||
.drop(1)
|
||||
@ -205,6 +224,36 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
}
|
||||
}
|
||||
|
||||
fun setExpandText(allExpanded: Boolean?, animated: Boolean = true) {
|
||||
binding.expandCategories.isVisible = allExpanded != null
|
||||
allExpanded ?: return
|
||||
binding.expandCategories.setText(
|
||||
if (!allExpanded) {
|
||||
R.string.expand_all_categories
|
||||
} else {
|
||||
R.string.collapse_all_categories
|
||||
}
|
||||
)
|
||||
if (animated) {
|
||||
binding.expandCategories.setIconResource(
|
||||
if (!allExpanded) {
|
||||
R.drawable.anim_expand_less_to_more
|
||||
} else {
|
||||
R.drawable.anim_expand_more_to_less
|
||||
}
|
||||
)
|
||||
(binding.expandCategories.icon as? AnimatedVectorDrawable)?.start()
|
||||
} else {
|
||||
binding.expandCategories.setIconResource(
|
||||
if (!allExpanded) {
|
||||
R.drawable.ic_expand_more_24dp
|
||||
} else {
|
||||
R.drawable.ic_expand_less_24dp
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun hasActiveFilters() = filterItems.any { it.isActivated }
|
||||
|
||||
private fun hasActiveFiltersFromPref(): Boolean {
|
||||
@ -400,7 +449,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
}
|
||||
}
|
||||
|
||||
fun updateButtons(groupType: Int) {
|
||||
fun updateGroupTypeButton(groupType: Int) {
|
||||
binding.groupBy.setIconResource(LibraryGroup.groupTypeDrawableRes(groupType))
|
||||
}
|
||||
|
||||
|
@ -93,6 +93,24 @@
|
||||
app:icon="@drawable/ic_label_outline_24dp"
|
||||
app:iconTint="?android:attr/textColorPrimary" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/expand_categories"
|
||||
style="@style/Theme.Widget.Button.TextButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="2"
|
||||
android:text="@string/expand_all_categories"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:icon="@drawable/ic_expand_more_24dp"
|
||||
app:iconTint="?android:attr/textColorPrimary" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/second_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/view_options"
|
||||
style="@style/Theme.Widget.Button.TextButton"
|
||||
@ -104,6 +122,7 @@
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:icon="@drawable/ic_tune_24dp"
|
||||
app:iconTint="?android:attr/textColorPrimary" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -11,18 +11,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/expand_collapse_categories"
|
||||
style="@style/Theme.Widget.Button.TextButton"
|
||||
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"
|
||||
app:iconTint="?android:attr/textColorPrimary"
|
||||
android:text="@string/expand_all_categories" />
|
||||
|
||||
<com.google.android.material.checkbox.MaterialCheckBox
|
||||
android:id="@+id/category_show"
|
||||
android:layout_width="match_parent"
|
||||
|
Loading…
Reference in New Issue
Block a user