diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index d6061f65c7..98325967a7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -172,7 +172,7 @@ class LibraryController( preferences.lastUsedCategory().set(order) activeCategory = order setActiveCategory() - if (presenter.categories.size > 1 && dy != 0) { + if (presenter.categories.size > 1 && dy != 0 && recyclerView.translationY == 0f) { val headerItem = getHeader() ?: return val view = fast_scroller ?: return @@ -334,7 +334,7 @@ class LibraryController( } category_recycler.onCategoryClicked = { scrollToHeader(it) - showCategories(false) + showCategories(show = false, scroll = false) } category_recycler.onShowAllClicked = { isChecked -> preferences.showAllCategories().set(isChecked) @@ -601,15 +601,29 @@ class LibraryController( } } - private fun showCategories(show: Boolean) { + private fun showCategories(show: Boolean, scroll: Boolean = true) { recycler_cover.isClickable = show recycler_cover.isFocusable = show - val translateY = if (show) { - category_layout.height.toFloat() + recycler.paddingTop - } else { - 0f - } + val full = category_layout.height.toFloat() + recycler.paddingTop + val translateY = if (show) full else 0f recycler.animate().translationY(translateY).start() + if (scroll) { + // Smooth scroll the recycler to hide the hidden content blocked by the app bar + ValueAnimator.ofInt(recycler.translationY.roundToInt(), translateY.roundToInt()).apply { + var start = 0f + var last = recycler.translationY.roundToInt() + val distance = abs(recycler.translationY.roundToInt() - translateY.roundToInt()) + addUpdateListener { + val diff = abs(it.animatedValue as Int - last) + last = it.animatedValue as Int + start += diff.toFloat() / distance * recycler.paddingTop.toFloat() + if (start > 1) { + recycler.scrollBy(0, start.toInt() * if (show) 1 else -1) + start %= 1 + } + } + }.start() + } recycler_cover.animate().translationY(translateY).start() recycler_cover.animate().alpha(if (show) 0.75f else 0f).start() if (show) { diff --git a/app/src/main/res/drawable/material_list_item_selector.xml b/app/src/main/res/drawable/material_list_item_selector.xml new file mode 100644 index 0000000000..e864b9758d --- /dev/null +++ b/app/src/main/res/drawable/material_list_item_selector.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/square_ripple.xml b/app/src/main/res/drawable/square_ripple.xml index 3d0357453f..7af6d90521 100644 --- a/app/src/main/res/drawable/square_ripple.xml +++ b/app/src/main/res/drawable/square_ripple.xml @@ -1,6 +1,6 @@ + android:color="@color/fullRippleColor"> diff --git a/app/src/main/res/layout/catergory_text_view.xml b/app/src/main/res/layout/catergory_text_view.xml index 8e8ac44bdf..c74eca0102 100644 --- a/app/src/main/res/layout/catergory_text_view.xml +++ b/app/src/main/res/layout/catergory_text_view.xml @@ -1,20 +1,16 @@ - - - - + android:layout_marginTop="2dp" + android:layout_marginBottom="2dp" + android:background="@drawable/material_list_item_selector" + android:paddingStart="24dp" + android:paddingTop="8dp" + android:paddingEnd="0dp" + android:paddingBottom="8dp" + android:textAppearance="@style/TextAppearance.MaterialComponents.Headline6" + android:textSize="16sp" + tools:text="@string/categories" /> diff --git a/app/src/main/res/layout/library_list_controller.xml b/app/src/main/res/layout/library_list_controller.xml index f091ab494a..bb2048c4b7 100644 --- a/app/src/main/res/layout/library_list_controller.xml +++ b/app/src/main/res/layout/library_list_controller.xml @@ -33,6 +33,7 @@ android:id="@+id/category_recycler" android:layout_width="0dp" android:layout_height="wrap_content" + android:paddingBottom="4dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"