mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 04:11:48 +01:00
parent
8383f4fb7b
commit
694de99a3f
@ -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()
|
||||
}
|
||||
}
|
9
app/src/main/res/drawable/material_bubble_drawable.xml
Normal file
9
app/src/main/res/drawable/material_bubble_drawable.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners android:radius="38dp" />
|
||||
<solid android:color="?colorPrimaryVariant" />
|
||||
<size
|
||||
android:width="30dp"
|
||||
android:height="30dp" />
|
||||
</shape>
|
17
app/src/main/res/drawable/material_thumb_drawable.xml
Normal file
17
app/src/main/res/drawable/material_thumb_drawable.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_selected="true">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="8dp" />
|
||||
<solid android:color="?attr/colorAccent" />
|
||||
<size android:width="6dp" android:height="54dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="8dp" />
|
||||
<solid android:color="@color/fast_scroller_handle_idle" />
|
||||
<size android:width="6dp" android:height="54dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
@ -34,7 +34,7 @@
|
||||
|
||||
</eu.kanade.tachiyomi.widget.ThemedSwipeRefreshLayout>
|
||||
|
||||
<eu.davidea.fastscroller.FastScroller
|
||||
<eu.kanade.tachiyomi.ui.library.MaterialFastScroll
|
||||
android:id="@+id/fast_scroller"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
</eu.kanade.tachiyomi.widget.ThemedSwipeRefreshLayout>
|
||||
|
||||
<eu.davidea.fastscroller.FastScroller
|
||||
<eu.kanade.tachiyomi.ui.library.MaterialFastScroll
|
||||
android:id="@+id/fast_scroller"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -10,7 +10,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<eu.davidea.fastscroller.FastScroller
|
||||
<eu.kanade.tachiyomi.ui.library.MaterialFastScroll
|
||||
android:id="@+id/fast_scroller"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
|
52
app/src/main/res/layout/material_fastscroll.xml
Normal file
52
app/src/main/res/layout/material_fastscroll.xml
Normal file
@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<View
|
||||
android:id="@+id/fast_scroller_bar"
|
||||
android:layout_width="7dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="end"
|
||||
android:background="@android:color/transparent" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end">
|
||||
|
||||
<!-- No margin, use padding at the handle -->
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/fast_scroller_bubble"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|center_vertical"
|
||||
android:layout_toStartOf="@+id/fast_scroller_handle"
|
||||
android:background="@drawable/material_bubble_drawable"
|
||||
android:elevation="10dp"
|
||||
android:gravity="center"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:textColor="?attr/colorOnPrimary"
|
||||
android:textSize="15sp"
|
||||
android:visibility="gone"
|
||||
tools:text="A"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<!-- Padding is here to have better grab -->
|
||||
<ImageView
|
||||
android:id="@+id/fast_scroller_handle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:contentDescription="@null"
|
||||
android:paddingStart="6dp"
|
||||
android:paddingEnd="4dp"
|
||||
android:src="@drawable/material_thumb_drawable" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</merge>
|
@ -11,7 +11,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
tools:listitem="@layout/source_main_controller_card_header" />
|
||||
|
||||
<eu.davidea.fastscroller.FastScroller
|
||||
<eu.kanade.tachiyomi.ui.library.MaterialFastScroll
|
||||
android:id="@+id/fast_scroller"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
|
Loading…
Reference in New Issue
Block a user