@@ -4,8 +4,6 @@ import android.accessibilityservice.AccessibilityService
44import android.accessibilityservice.GestureDescription
55import android.accessibilityservice.GestureDescription.StrokeDescription
66import android.graphics.Path
7- import kotlin.math.max
8- import kotlin.math.min
97
108fun AccessibilityService.dispatchScrollUp (ratio : Float? = null) {
119 val displayMetrics = this .applicationContext.resources.displayMetrics
@@ -17,7 +15,7 @@ fun AccessibilityService.dispatchScrollUp(ratio: Float? = null) {
1715
1816 val path = Path ().apply {
1917 moveTo(centerX, centerY)
20- lineTo(centerX, centerY + (ratio?. let { min(it * height, centerY) } ? : distance) )
18+ lineTo(centerX, centerY + centerY)
2119 }
2220
2321 dispatchGesture(path)
@@ -33,9 +31,7 @@ fun AccessibilityService.dispatchScrollDown(ratio: Float? = null) {
3331
3432 val path = Path ().apply {
3533 moveTo(centerX, centerY)
36- lineTo(
37- centerX,
38- centerY + (ratio?.let { max(min(it * height, centerY), - centerY) } ? : - distance))
34+ lineTo(centerX, 0f )
3935 }
4036
4137 dispatchGesture(path)
@@ -51,7 +47,7 @@ fun AccessibilityService.dispatchScrollLeft(ratio: Float? = null) {
5147
5248 val path = Path ().apply {
5349 moveTo(centerX, centerY)
54- lineTo(centerX + (ratio?. let { min(it * width, centerX) } ? : distance) , centerY)
50+ lineTo(centerX + centerX, centerY)
5551 }
5652
5753 dispatchGesture(path)
@@ -67,8 +63,7 @@ fun AccessibilityService.dispatchScrollRight(ratio: Float? = null) {
6763
6864 val path = Path ().apply {
6965 moveTo(centerX, centerY)
70- lineTo(centerX + (ratio?.let { max(min(it * width, centerX), - centerX) } ? : - distance),
71- centerY)
66+ lineTo(centerX + - centerX, centerY)
7267 }
7368
7469 dispatchGesture(path)
0 commit comments