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 acfd78c4bb..fee9c6209f 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 76c747a515..a292b94a25 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 aec5abefe0..34b1703f03 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 b56700a8ec..fff20a791d 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 e1ec078a91..80aaf9c5dc 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 63eb857669..1d89808544 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 8f453d4d56..56b16a1b84 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 1b831eb5be..54bcb2893c 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 b02b0cf482..071551e532 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -287,6 +287,23 @@ + + + + + +