mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 11:17:25 +01:00
MaterialFastScroll updates
This commit is contained in:
parent
3b45fcdb21
commit
d86d861e4b
@ -5,7 +5,7 @@ import android.util.AttributeSet
|
|||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import eu.davidea.fastscroller.FastScroller
|
import eu.davidea.fastscroller.FastScroller
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
import eu.kanade.tachiyomi.util.system.dpToPxEnd
|
||||||
|
|
||||||
class MaterialFastScroll @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
class MaterialFastScroll @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||||
FastScroller(context, attrs) {
|
FastScroller(context, attrs) {
|
||||||
@ -14,6 +14,8 @@ class MaterialFastScroll @JvmOverloads constructor(context: Context, attrs: Attr
|
|||||||
setViewsToUse(
|
setViewsToUse(
|
||||||
R.layout.material_fastscroll, R.id.fast_scroller_bubble, R.id.fast_scroller_handle
|
R.layout.material_fastscroll, R.id.fast_scroller_bubble, R.id.fast_scroller_handle
|
||||||
)
|
)
|
||||||
|
autoHideEnabled = true
|
||||||
|
ignoreTouchesOutsideHandle = true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||||
@ -23,7 +25,9 @@ class MaterialFastScroll @JvmOverloads constructor(context: Context, attrs: Attr
|
|||||||
|
|
||||||
override fun setBubbleAndHandlePosition(y: Float) {
|
override fun setBubbleAndHandlePosition(y: Float) {
|
||||||
super.setBubbleAndHandlePosition(y)
|
super.setBubbleAndHandlePosition(y)
|
||||||
bubble.y = handle.y - bubble.height / 2f + handle.height / 2f
|
if (bubbleEnabled) {
|
||||||
bubble.translationX = (-45).dpToPx.toFloat()
|
bubble.y = handle.y - bubble.height / 2f + handle.height / 2f
|
||||||
|
bubble.translationX = (-45f).dpToPxEnd
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import android.graphics.Color
|
|||||||
import android.net.ConnectivityManager
|
import android.net.ConnectivityManager
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
|
import android.view.View
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.annotation.AttrRes
|
import androidx.annotation.AttrRes
|
||||||
import androidx.annotation.ColorInt
|
import androidx.annotation.ColorInt
|
||||||
@ -129,6 +130,18 @@ val Int.pxToDp: Int
|
|||||||
val Int.dpToPx: Int
|
val Int.dpToPx: Int
|
||||||
get() = (this * Resources.getSystem().displayMetrics.density).toInt()
|
get() = (this * Resources.getSystem().displayMetrics.density).toInt()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts to px and takes into account LTR/RTL layout.
|
||||||
|
*/
|
||||||
|
val Float.dpToPxEnd: Float
|
||||||
|
get() = (
|
||||||
|
this * Resources.getSystem().displayMetrics.density *
|
||||||
|
if (Resources.getSystem().isLTR) 1 else -1
|
||||||
|
)
|
||||||
|
|
||||||
|
val Resources.isLTR
|
||||||
|
get() = configuration.layoutDirection == View.LAYOUT_DIRECTION_LTR
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property to get the notification manager from the context.
|
* Property to get the notification manager from the context.
|
||||||
*/
|
*/
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:shape="rectangle">
|
android:shape="rectangle">
|
||||||
<corners android:radius="38dp" />
|
<corners android:radius="38dp" />
|
||||||
<solid android:color="?colorPrimaryVariant" />
|
<solid android:color="?attr/colorPrimaryVariant" />
|
||||||
<size
|
<size
|
||||||
android:width="30dp"
|
android:width="30dp"
|
||||||
android:height="30dp" />
|
android:height="30dp" />
|
||||||
|
@ -39,8 +39,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_gravity="right"
|
android:layout_gravity="end"
|
||||||
android:layoutDirection="ltr"
|
|
||||||
app:fastScrollerBubbleEnabled="false"
|
app:fastScrollerBubbleEnabled="false"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
@ -22,8 +22,7 @@
|
|||||||
android:id="@+id/fast_scroller"
|
android:id="@+id/fast_scroller"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="right"
|
android:layout_gravity="end"
|
||||||
android:layoutDirection="ltr"
|
|
||||||
app:fastScrollerBubbleEnabled="false"
|
app:fastScrollerBubbleEnabled="false"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
@ -15,8 +15,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_gravity="right"
|
android:layout_gravity="end"
|
||||||
android:layoutDirection="ltr"
|
|
||||||
app:fastScrollerBubbleEnabled="false"
|
app:fastScrollerBubbleEnabled="false"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
android:layout_width="7dp"
|
android:layout_width="7dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="end"
|
android:layout_gravity="end"
|
||||||
android:background="@android:color/transparent" />
|
android:background="@null" />
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -19,19 +19,10 @@
|
|||||||
<!-- No margin, use padding at the handle -->
|
<!-- No margin, use padding at the handle -->
|
||||||
<com.google.android.material.textview.MaterialTextView
|
<com.google.android.material.textview.MaterialTextView
|
||||||
android:id="@+id/fast_scroller_bubble"
|
android:id="@+id/fast_scroller_bubble"
|
||||||
android:layout_width="wrap_content"
|
style="@style/FloatingTextView"
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="end|center_vertical"
|
android:layout_gravity="end|center_vertical"
|
||||||
android:layout_toStartOf="@+id/fast_scroller_handle"
|
android:layout_toStartOf="@+id/fast_scroller_handle"
|
||||||
android:background="@drawable/material_bubble_drawable"
|
|
||||||
android:elevation="10dp"
|
|
||||||
android:gravity="center"
|
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"
|
android:visibility="gone"
|
||||||
tools:text="A"
|
tools:text="A"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
@ -15,8 +15,7 @@
|
|||||||
android:id="@+id/fast_scroller"
|
android:id="@+id/fast_scroller"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="right"
|
android:layout_gravity="end"
|
||||||
android:layoutDirection="ltr"
|
|
||||||
app:fastScrollerBubbleEnabled="false"
|
app:fastScrollerBubbleEnabled="false"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
@ -287,6 +287,23 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
<!--============-->
|
||||||
|
<!--FastScroller-->
|
||||||
|
<!--============-->
|
||||||
|
<style name="FloatingTextView" parent="TextAppearance.AppCompat">
|
||||||
|
<item name="android:layout_height">wrap_content</item>
|
||||||
|
<item name="android:layout_width">wrap_content</item>
|
||||||
|
<item name="android:background">@drawable/material_bubble_drawable</item>
|
||||||
|
<item name="android:elevation">5dp</item>
|
||||||
|
<item name="android:paddingStart">12dp</item>
|
||||||
|
<item name="android:paddingEnd">12dp</item>
|
||||||
|
<item name="android:paddingTop">8dp</item>
|
||||||
|
<item name="android:paddingBottom">8dp</item>
|
||||||
|
<item name="android:textColor">?attr/colorOnPrimary</item>
|
||||||
|
<item name="android:textSize">15sp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
<!--===-->
|
<!--===-->
|
||||||
<!--OLD-->
|
<!--OLD-->
|
||||||
<!--===-->
|
<!--===-->
|
||||||
|
Loading…
Reference in New Issue
Block a user