mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-24 00:31:48 +01:00
Work on filters sheet
Auto hides now when scrolling, no longer hides with filters active Changed back download color, using purple (?) for total chapters
This commit is contained in:
parent
98749190c2
commit
b3ece8c9c9
@ -71,8 +71,6 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
|
||||
|
||||
var headerHeight = 0
|
||||
|
||||
var customTitle = ""
|
||||
|
||||
var showingExtenions = false
|
||||
|
||||
/**
|
||||
|
@ -23,7 +23,7 @@ class LibraryBadge @JvmOverloads constructor(context: Context, attrs: AttributeS
|
||||
context.getResourceColor(android.R.attr.colorAccent)
|
||||
else Color.WHITE)
|
||||
setBackgroundColor(
|
||||
if (showTotalChapters) ContextCompat.getColor(context, R.color.total_green)
|
||||
if (showTotalChapters) ContextCompat.getColor(context, R.color.material_deep_purple_500)
|
||||
else context.getResourceColor(android.R.attr.colorAccent))
|
||||
visibility = when {
|
||||
unread > 0 || unread == -1 || showTotalChapters -> View.VISIBLE
|
||||
@ -47,7 +47,7 @@ class LibraryBadge @JvmOverloads constructor(context: Context, attrs: AttributeS
|
||||
unread_angle.visibility = if (download_text.visibility == View.VISIBLE && unread_text
|
||||
.visibility != View.GONE) View.VISIBLE else View.GONE
|
||||
unread_angle.setColorFilter(
|
||||
if (showTotalChapters) ContextCompat.getColor(context, R.color.total_green)
|
||||
if (showTotalChapters) ContextCompat.getColor(context, R.color.material_deep_purple_500)
|
||||
else context.getResourceColor(android.R.attr.colorAccent))
|
||||
if (unread_angle.visibility == View.VISIBLE) {
|
||||
download_text.updatePaddingRelative(end = 8.dpToPx)
|
||||
|
@ -239,6 +239,7 @@ open class LibraryController(
|
||||
DownloadService.callListeners()
|
||||
LibraryUpdateService.setListener(this)
|
||||
}
|
||||
if (type == ControllerChangeType.POP_ENTER) bottom_sheet.hideIfPossible()
|
||||
}
|
||||
|
||||
override fun onActivityResumed(activity: Activity) {
|
||||
|
@ -39,11 +39,6 @@ import eu.kanade.tachiyomi.util.view.scrollViewWith
|
||||
import eu.kanade.tachiyomi.util.view.snack
|
||||
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
||||
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
|
||||
import kotlinx.android.synthetic.main.filter_bottom_sheet.*
|
||||
import kotlinx.android.synthetic.main.library_grid_recycler.*
|
||||
import kotlinx.android.synthetic.main.library_list_controller.*
|
||||
import kotlinx.android.synthetic.main.main_activity.*
|
||||
import kotlinx.coroutines.delay
|
||||
import java.util.Locale
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.max
|
||||
@ -51,6 +46,11 @@ import kotlin.math.min
|
||||
import kotlin.math.pow
|
||||
import kotlin.math.roundToInt
|
||||
import kotlin.math.sign
|
||||
import kotlinx.android.synthetic.main.filter_bottom_sheet.*
|
||||
import kotlinx.android.synthetic.main.library_grid_recycler.*
|
||||
import kotlinx.android.synthetic.main.library_list_controller.*
|
||||
import kotlinx.android.synthetic.main.main_activity.*
|
||||
import kotlinx.coroutines.delay
|
||||
|
||||
class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
||||
FlexibleAdapter.OnItemClickListener, FlexibleAdapter.OnItemLongClickListener,
|
||||
@ -67,6 +67,7 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
||||
private var lastItem: IFlexible<*>? = null
|
||||
|
||||
private var switchingCategories = false
|
||||
var scrollDistance = 0f
|
||||
|
||||
private var startPosX: Float? = null
|
||||
private var startPosY: Float? = null
|
||||
@ -79,6 +80,7 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
||||
private val swipeDistance = 300f
|
||||
private var flinging = false
|
||||
private var isDragging = false
|
||||
private val scrollDistanceTilHidden = 1000.dpToPx
|
||||
|
||||
override fun contentView(): View = recycler_layout
|
||||
|
||||
@ -93,6 +95,13 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
super.onScrolled(recyclerView, dx, dy)
|
||||
val order = getCategoryOrder()
|
||||
if (bottom_sheet.canHide()) {
|
||||
scrollDistance += abs(dy)
|
||||
if (scrollDistance > scrollDistanceTilHidden) {
|
||||
bottom_sheet.hideIfPossible()
|
||||
scrollDistance = 0f
|
||||
}
|
||||
} else scrollDistance = 0f
|
||||
if (order != null && order != activeCategory) {
|
||||
preferences.lastUsedCategory().set(order)
|
||||
activeCategory = order
|
||||
|
@ -335,7 +335,7 @@ class LibraryPresenter(
|
||||
} else compare
|
||||
}
|
||||
|
||||
val comparator = if (ascending)
|
||||
val comparator = if (ascending || useDnD)
|
||||
Comparator(sortFn)
|
||||
else
|
||||
Collections.reverseOrder(sortFn)
|
||||
|
@ -116,6 +116,12 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
if (isChecked)
|
||||
onGroupClicked(ACTION_HIDE_FILTER_TIP)
|
||||
}
|
||||
|
||||
val activeFilters = hasActiveFiltersFromPref()
|
||||
sheetBehavior?.isHideable = !activeFilters
|
||||
if (activeFilters && sheetBehavior?.state == BottomSheetBehavior.STATE_HIDDEN &&
|
||||
sheetBehavior?.skipCollapsed == false)
|
||||
sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
||||
createTags()
|
||||
clearButton.setOnClickListener { clearFilters() }
|
||||
}
|
||||
@ -169,6 +175,14 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
|
||||
fun hasActiveFilters() = filterItems.any { it.isActivated }
|
||||
|
||||
private fun hasActiveFiltersFromPref(): Boolean {
|
||||
return preferences.filterDownloaded().getOrDefault() > 0 || preferences.filterUnread()
|
||||
.getOrDefault() > 0 || preferences.filterCompleted()
|
||||
.getOrDefault() > 0 || preferences.filterTracked()
|
||||
.getOrDefault() > 0 || preferences.filterMangaType()
|
||||
.getOrDefault() > 0 || FILTER_TRACKER.isNotEmpty()
|
||||
}
|
||||
|
||||
private fun createTags() {
|
||||
hide_categories.isChecked = preferences.hideCategories().getOrDefault()
|
||||
hide_categories.setOnCheckedChangeListener { _, isChecked ->
|
||||
@ -286,12 +300,21 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
filterItems.remove(trackers!!)
|
||||
}
|
||||
val hasFilters = hasActiveFilters()
|
||||
sheetBehavior?.isHideable = !hasFilters
|
||||
if (hasFilters && clearButton.parent == null)
|
||||
filter_layout.addView(clearButton, 0)
|
||||
else if (!hasFilters && clearButton.parent != null)
|
||||
filter_layout.removeView(clearButton)
|
||||
}
|
||||
|
||||
fun hideIfPossible() {
|
||||
if (!hasActiveFilters() && sheetBehavior?.isHideable == true)
|
||||
sheetBehavior?.state = BottomSheetBehavior.STATE_HIDDEN
|
||||
}
|
||||
|
||||
fun canHide(): Boolean = sheetBehavior?.isHideable == true && sheetBehavior?.state !=
|
||||
BottomSheetBehavior.STATE_HIDDEN
|
||||
|
||||
private fun clearFilters() {
|
||||
preferences.filterDownloaded().set(0)
|
||||
preferences.filterUnread().set(0)
|
||||
|
@ -21,7 +21,7 @@
|
||||
style="@style/TextAppearance.Regular.Caption.Light"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/pale_red"
|
||||
android:background="@color/pale_green"
|
||||
android:gravity="center"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="5dp"
|
||||
|
@ -83,6 +83,5 @@
|
||||
|
||||
<color name="md_teal_500">#009688</color>
|
||||
|
||||
<color name="total_green">@color/material_green_800</color>
|
||||
<color name="pale_red">@color/material_red_300</color>
|
||||
<color name="pale_green">#99CC99</color>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user