mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
fix: Fix source filter buttom sheet unable to be fully scrolled to the bottom
This bug has been annoying me for a long time, classic RecyclerView moment
This commit is contained in:
parent
4faa641739
commit
7a08ca294a
4 changed files with 45 additions and 20 deletions
|
@ -21,6 +21,7 @@ The format is simplified version of [Keep a Changelog](https://keepachangelog.co
|
||||||
- Fix Recents page shows "No recent chapters" instead of a loading screen
|
- Fix Recents page shows "No recent chapters" instead of a loading screen
|
||||||
- Fix not fully loaded entries can't be selected on Library page
|
- Fix not fully loaded entries can't be selected on Library page
|
||||||
- Fix certain Infinix devices being unable to use any "Open link in browser" actions, including tracker setup (@MajorTanya)
|
- Fix certain Infinix devices being unable to use any "Open link in browser" actions, including tracker setup (@MajorTanya)
|
||||||
|
- Fix source filter bottom sheet unable to be fully scrolled to the bottom
|
||||||
|
|
||||||
### Translation
|
### Translation
|
||||||
- Update translations from Weblate
|
- Update translations from Weblate
|
||||||
|
|
|
@ -6,6 +6,7 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener
|
import android.view.ViewTreeObserver.OnGlobalLayoutListener
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
import androidx.core.content.withStyledAttributes
|
||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import androidx.core.view.WindowInsetsCompat.Type.systemBars
|
import androidx.core.view.WindowInsetsCompat.Type.systemBars
|
||||||
import androidx.core.view.updateLayoutParams
|
import androidx.core.view.updateLayoutParams
|
||||||
|
@ -21,6 +22,7 @@ import eu.kanade.tachiyomi.util.view.checkHeightThen
|
||||||
import eu.kanade.tachiyomi.util.view.collapse
|
import eu.kanade.tachiyomi.util.view.collapse
|
||||||
import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsetsCompat
|
import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsetsCompat
|
||||||
import eu.kanade.tachiyomi.widget.E2EBottomSheetDialog
|
import eu.kanade.tachiyomi.widget.E2EBottomSheetDialog
|
||||||
|
import yokai.presentation.component.recyclerview.VertPaddingDecoration
|
||||||
import android.R as AR
|
import android.R as AR
|
||||||
|
|
||||||
class SourceFilterSheet(val activity: Activity) :
|
class SourceFilterSheet(val activity: Activity) :
|
||||||
|
@ -92,6 +94,7 @@ class SourceFilterSheet(val activity: Activity) :
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.filtersRecycler.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(context)
|
binding.filtersRecycler.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(context)
|
||||||
|
binding.filtersRecycler.addItemDecoration(VertPaddingDecoration(12.dpToPx))
|
||||||
binding.filtersRecycler.clipToPadding = false
|
binding.filtersRecycler.clipToPadding = false
|
||||||
binding.filtersRecycler.adapter = adapter
|
binding.filtersRecycler.adapter = adapter
|
||||||
binding.filtersRecycler.setHasFixedSize(false)
|
binding.filtersRecycler.setHasFixedSize(false)
|
||||||
|
@ -132,17 +135,17 @@ class SourceFilterSheet(val activity: Activity) :
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
val attrsArray = intArrayOf(AR.attr.actionBarSize)
|
val attrsArray = intArrayOf(AR.attr.actionBarSize)
|
||||||
val array = context.obtainStyledAttributes(attrsArray)
|
context.withStyledAttributes(null, attrsArray) {
|
||||||
val headerHeight = array.getDimensionPixelSize(0, 0)
|
val headerHeight = getDimensionPixelSize(0, 0)
|
||||||
binding.titleLayout.updatePaddingRelative(
|
binding.titleLayout.updatePaddingRelative(
|
||||||
bottom = activity.window.decorView.rootWindowInsetsCompat
|
bottom = activity.window.decorView.rootWindowInsetsCompat
|
||||||
?.getInsets(systemBars())?.bottom ?: 0,
|
?.getInsets(systemBars())?.bottom ?: 0,
|
||||||
)
|
)
|
||||||
|
|
||||||
binding.titleLayout.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
binding.titleLayout.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||||
height = headerHeight + binding.titleLayout.paddingBottom
|
height = headerHeight + binding.titleLayout.paddingBottom
|
||||||
|
}
|
||||||
}
|
}
|
||||||
array.recycle()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateBottomButtons() {
|
private fun updateBottomButtons() {
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package yokai.presentation.component.recyclerview
|
||||||
|
|
||||||
|
import android.graphics.Rect
|
||||||
|
import android.view.View
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add (vertical) padding to RecyclerView first and last item. Because `clipToPadding = "false"` bugged out for Bottom Sheets.
|
||||||
|
*/
|
||||||
|
class VertPaddingDecoration(private val padding: Int) : RecyclerView.ItemDecoration() {
|
||||||
|
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
|
||||||
|
super.getItemOffsets(outRect, view, parent, state)
|
||||||
|
|
||||||
|
val itemPosition = parent.getChildAdapterPosition(view)
|
||||||
|
|
||||||
|
if (itemPosition == RecyclerView.NO_POSITION) return;
|
||||||
|
|
||||||
|
when {
|
||||||
|
itemPosition == 0 ->
|
||||||
|
outRect.top = padding
|
||||||
|
itemPosition > 0 && itemPosition == state.itemCount - 1 ->
|
||||||
|
outRect.bottom = padding
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +1,12 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
android:id="@+id/source_filter_sheet"
|
||||||
android:id="@+id/source_filter_sheet"
|
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"
|
app:layout_constraintVertical_chainStyle="packed"
|
||||||
app:layout_constraintVertical_chainStyle="packed"
|
android:backgroundTint="?attr/background">
|
||||||
android:backgroundTint="?attr/background">
|
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:id="@+id/card_view"
|
android:id="@+id/card_view"
|
||||||
|
@ -24,15 +23,12 @@
|
||||||
android:id="@+id/filters_recycler"
|
android:id="@+id/filters_recycler"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="12dp"
|
|
||||||
android:paddingBottom="12dp"
|
|
||||||
android:layout_marginBottom="12dp"
|
android:layout_marginBottom="12dp"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:background="@drawable/bottom_sheet_rounded_background"
|
android:background="@drawable/bottom_sheet_rounded_background"
|
||||||
android:backgroundTint="?attr/colorSurface"
|
android:backgroundTint="?attr/colorSurface"
|
||||||
app:layout_constraintBottom_toTopOf="@id/title_layout"
|
app:layout_constraintBottom_toTopOf="@id/title_layout"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintHorizontal_bias="0.0"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue