diff --git a/app/src/main/java/org/oxycblt/auxio/songs/FastScrollView.kt b/app/src/main/java/org/oxycblt/auxio/songs/FastScrollView.kt
index 1ae93e5d2..3356eb438 100644
--- a/app/src/main/java/org/oxycblt/auxio/songs/FastScrollView.kt
+++ b/app/src/main/java/org/oxycblt/auxio/songs/FastScrollView.kt
@@ -59,6 +59,7 @@ class FastScrollView @JvmOverloads constructor(
// --- STATE ---
private var hasPostedItemUpdate = false
+ private var wasValidTouch = false
private var lastPos = -1
init {
@@ -147,6 +148,7 @@ class FastScrollView @JvmOverloads constructor(
@Suppress("ClickableViewAccessibility")
override fun onTouchEvent(event: MotionEvent): Boolean {
+ super.onTouchEvent(event)
performClick()
val success = handleTouch(event.action, event.x.roundToInt(), event.y.roundToInt())
@@ -160,15 +162,25 @@ class FastScrollView @JvmOverloads constructor(
}
private fun handleTouch(action: Int, touchX: Int, touchY: Int): Boolean {
- if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
- binding.scrollIndicatorText.setTextColor(inactiveColor)
- lastPos = -1
+ when (action) {
+ MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
+ binding.scrollIndicatorText.setTextColor(inactiveColor)
+ wasValidTouch = false
+ lastPos = -1
- return false
+ return false
+ }
+
+ // Since this view is unified between the thumb and the indicators, we have
+ // to check if the initial pointer position was in the indicators to prevent the
+ // scroll from being triggered outside its bounds.
+ MotionEvent.ACTION_DOWN -> {
+ wasValidTouch = binding.scrollIndicatorText.contains(touchX, touchY)
+ }
}
// Try to figure out which indicator the pointer has landed on
- if (binding.scrollIndicatorText.isBeingPressed(touchX, touchY)) {
+ if (binding.scrollIndicatorText.containsY(touchY) && wasValidTouch) {
// Get the touch position in regards to the TextView and the rough text height
val indicatorTouchY = touchY - binding.scrollIndicatorText.top
val textHeight = binding.scrollIndicatorText.height / indicators.size
@@ -214,10 +226,11 @@ class FastScrollView @JvmOverloads constructor(
}
}
- /**
- * Returns if the pointer is currently in the view
- */
- private fun View.isBeingPressed(x: Int, y: Int): Boolean {
+ private fun View.contains(x: Int, y: Int): Boolean {
+ return x in (left until right) && containsY(y)
+ }
+
+ private fun View.containsY(y: Int): Boolean {
return y in (top until bottom)
}
}
diff --git a/app/src/main/res/drawable/ui_circle.xml b/app/src/main/res/drawable/ui_circle.xml
new file mode 100644
index 000000000..a6f3dfaa6
--- /dev/null
+++ b/app/src/main/res/drawable/ui_circle.xml
@@ -0,0 +1,5 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ui_circular_button.xml b/app/src/main/res/drawable/ui_circle_ripple.xml
similarity index 100%
rename from app/src/main/res/drawable/ui_circular_button.xml
rename to app/src/main/res/drawable/ui_circle_ripple.xml
diff --git a/app/src/main/res/layout/item_accent.xml b/app/src/main/res/layout/item_accent.xml
index dfe49c589..2ee82364d 100644
--- a/app/src/main/res/layout/item_accent.xml
+++ b/app/src/main/res/layout/item_accent.xml
@@ -12,7 +12,7 @@
android:id="@+id/accent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:background="@drawable/ui_circular_button"
+ android:background="@drawable/ui_circle_ripple"
android:padding="@dimen/margin_medium"
android:scaleType="fitCenter"
android:src="@drawable/ic_check"
diff --git a/app/src/main/res/layout/view_fast_scroll.xml b/app/src/main/res/layout/view_fast_scroll.xml
index 30f2095ce..bd1a614a7 100644
--- a/app/src/main/res/layout/view_fast_scroll.xml
+++ b/app/src/main/res/layout/view_fast_scroll.xml
@@ -12,7 +12,7 @@
android:id="@+id/scroll_thumb"
android:layout_width="@dimen/size_scroll_thumb"
android:layout_height="@dimen/size_scroll_thumb"
- android:background="@drawable/ui_circular_button"
+ android:background="@drawable/ui_circle"
android:elevation="@dimen/elevation_small"
android:backgroundTint="?attr/colorPrimary"
android:stateListAnimator="@animator/animator_thumb"
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 080c65ba7..e88b269d1 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -213,7 +213,7 @@