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 index acfd78c4b..fee9c6209 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/MaterialFastScroll.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/MaterialFastScroll.kt @@ -5,7 +5,7 @@ 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 +import eu.kanade.tachiyomi.util.system.dpToPxEnd class MaterialFastScroll @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : FastScroller(context, attrs) { @@ -14,6 +14,8 @@ class MaterialFastScroll @JvmOverloads constructor(context: Context, attrs: Attr setViewsToUse( R.layout.material_fastscroll, R.id.fast_scroller_bubble, R.id.fast_scroller_handle ) + autoHideEnabled = true + ignoreTouchesOutsideHandle = true } override fun onTouchEvent(event: MotionEvent): Boolean { @@ -23,7 +25,9 @@ class MaterialFastScroll @JvmOverloads constructor(context: Context, attrs: Attr override fun setBubbleAndHandlePosition(y: Float) { super.setBubbleAndHandlePosition(y) - bubble.y = handle.y - bubble.height / 2f + handle.height / 2f - bubble.translationX = (-45).dpToPx.toFloat() + if (bubbleEnabled) { + bubble.y = handle.y - bubble.height / 2f + handle.height / 2f + bubble.translationX = (-45f).dpToPxEnd + } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt index 76c747a51..a292b94a2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt @@ -13,6 +13,7 @@ import android.graphics.Color import android.net.ConnectivityManager import android.net.Uri import android.os.PowerManager +import android.view.View import android.widget.Toast import androidx.annotation.AttrRes import androidx.annotation.ColorInt @@ -129,6 +130,18 @@ val Int.pxToDp: Int val Int.dpToPx: Int 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. */ diff --git a/app/src/main/res/drawable/material_bubble_drawable.xml b/app/src/main/res/drawable/material_bubble_drawable.xml index aec5abefe..34b1703f0 100644 --- a/app/src/main/res/drawable/material_bubble_drawable.xml +++ b/app/src/main/res/drawable/material_bubble_drawable.xml @@ -2,7 +2,7 @@ - + diff --git a/app/src/main/res/layout/chapters_controller.xml b/app/src/main/res/layout/chapters_controller.xml index b56700a8e..fff20a791 100644 --- a/app/src/main/res/layout/chapters_controller.xml +++ b/app/src/main/res/layout/chapters_controller.xml @@ -39,8 +39,7 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_centerHorizontal="true" - android:layout_gravity="right" - android:layoutDirection="ltr" + android:layout_gravity="end" app:fastScrollerBubbleEnabled="false" tools:visibility="visible" /> diff --git a/app/src/main/res/layout/extension_controller.xml b/app/src/main/res/layout/extension_controller.xml index e1ec078a9..80aaf9c5d 100644 --- a/app/src/main/res/layout/extension_controller.xml +++ b/app/src/main/res/layout/extension_controller.xml @@ -22,8 +22,7 @@ android:id="@+id/fast_scroller" android:layout_width="wrap_content" android:layout_height="match_parent" - android:layout_gravity="right" - android:layoutDirection="ltr" + android:layout_gravity="end" app:fastScrollerBubbleEnabled="false" tools:visibility="visible" /> diff --git a/app/src/main/res/layout/library_category.xml b/app/src/main/res/layout/library_category.xml index 63eb85766..1d8980854 100644 --- a/app/src/main/res/layout/library_category.xml +++ b/app/src/main/res/layout/library_category.xml @@ -15,8 +15,7 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_centerHorizontal="true" - android:layout_gravity="right" - android:layoutDirection="ltr" + android:layout_gravity="end" app:fastScrollerBubbleEnabled="false" tools:visibility="visible" /> diff --git a/app/src/main/res/layout/material_fastscroll.xml b/app/src/main/res/layout/material_fastscroll.xml index 8f453d4d5..56b16a1b8 100644 --- a/app/src/main/res/layout/material_fastscroll.xml +++ b/app/src/main/res/layout/material_fastscroll.xml @@ -9,7 +9,7 @@ android:layout_width="7dp" android:layout_height="match_parent" android:layout_gravity="end" - android:background="@android:color/transparent" /> + android:background="@null" /> diff --git a/app/src/main/res/layout/source_main_controller.xml b/app/src/main/res/layout/source_main_controller.xml index 1b831eb5b..54bcb2893 100644 --- a/app/src/main/res/layout/source_main_controller.xml +++ b/app/src/main/res/layout/source_main_controller.xml @@ -15,8 +15,7 @@ android:id="@+id/fast_scroller" android:layout_width="wrap_content" android:layout_height="match_parent" - android:layout_gravity="right" - android:layoutDirection="ltr" + android:layout_gravity="end" app:fastScrollerBubbleEnabled="false" tools:visibility="visible" /> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index b02b0cf48..071551e53 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -287,6 +287,23 @@ + + + + + +