From 694de99a3f6aaf918c9807d88b32bba8cc2f2f73 Mon Sep 17 00:00:00 2001 From: arkon Date: Wed, 6 May 2020 23:16:02 -0400 Subject: [PATCH] Adopt MaterialFastScroll from J2K fork https://github.com/Jays2Kings/tachiyomiJ2K/commit/de8cb8c1b06db0862d85811dfefd8c26ee93e587 --- .../ui/library/MaterialFastScroll.kt | 29 +++++++++++ .../res/drawable/material_bubble_drawable.xml | 9 ++++ .../res/drawable/material_thumb_drawable.xml | 17 ++++++ .../main/res/layout/chapters_controller.xml | 2 +- .../main/res/layout/extension_controller.xml | 2 +- app/src/main/res/layout/library_category.xml | 2 +- .../main/res/layout/material_fastscroll.xml | 52 +++++++++++++++++++ .../res/layout/source_main_controller.xml | 2 +- 8 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/eu/kanade/tachiyomi/ui/library/MaterialFastScroll.kt create mode 100644 app/src/main/res/drawable/material_bubble_drawable.xml create mode 100644 app/src/main/res/drawable/material_thumb_drawable.xml create mode 100644 app/src/main/res/layout/material_fastscroll.xml diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/MaterialFastScroll.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/MaterialFastScroll.kt new file mode 100644 index 0000000000..acfd78c4bb --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/MaterialFastScroll.kt @@ -0,0 +1,29 @@ +package eu.kanade.tachiyomi.ui.library + +import android.content.Context +import android.util.AttributeSet +import android.view.MotionEvent +import eu.davidea.fastscroller.FastScroller +import eu.kanade.tachiyomi.R +import eu.kanade.tachiyomi.util.system.dpToPx + +class MaterialFastScroll @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : + FastScroller(context, attrs) { + + init { + setViewsToUse( + R.layout.material_fastscroll, R.id.fast_scroller_bubble, R.id.fast_scroller_handle + ) + } + + override fun onTouchEvent(event: MotionEvent): Boolean { + if (isHidden) return false + return super.onTouchEvent(event) + } + + override fun setBubbleAndHandlePosition(y: Float) { + super.setBubbleAndHandlePosition(y) + bubble.y = handle.y - bubble.height / 2f + handle.height / 2f + bubble.translationX = (-45).dpToPx.toFloat() + } +} diff --git a/app/src/main/res/drawable/material_bubble_drawable.xml b/app/src/main/res/drawable/material_bubble_drawable.xml new file mode 100644 index 0000000000..aec5abefe0 --- /dev/null +++ b/app/src/main/res/drawable/material_bubble_drawable.xml @@ -0,0 +1,9 @@ + + + + + + diff --git a/app/src/main/res/drawable/material_thumb_drawable.xml b/app/src/main/res/drawable/material_thumb_drawable.xml new file mode 100644 index 0000000000..2e550c0dff --- /dev/null +++ b/app/src/main/res/drawable/material_thumb_drawable.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/chapters_controller.xml b/app/src/main/res/layout/chapters_controller.xml index 318f119c12..b56700a8ec 100644 --- a/app/src/main/res/layout/chapters_controller.xml +++ b/app/src/main/res/layout/chapters_controller.xml @@ -34,7 +34,7 @@ - - - + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/source_main_controller.xml b/app/src/main/res/layout/source_main_controller.xml index accfafcfe4..1b831eb5be 100644 --- a/app/src/main/res/layout/source_main_controller.xml +++ b/app/src/main/res/layout/source_main_controller.xml @@ -11,7 +11,7 @@ android:layout_height="wrap_content" tools:listitem="@layout/source_main_controller_card_header" /> -