mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2025-01-11 12:49:09 +01:00
Removing logic for dragging chapter nav with chapter sheet
Swiping up still expands it but trying to expand with it was too hacky and wonky
This commit is contained in:
parent
004b596671
commit
f74fe7ecbf
@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.ui.reader
|
|||||||
|
|
||||||
import android.view.GestureDetector
|
import android.view.GestureDetector
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
|
||||||
import eu.kanade.tachiyomi.util.view.collapse
|
import eu.kanade.tachiyomi.util.view.collapse
|
||||||
import eu.kanade.tachiyomi.util.view.expand
|
import eu.kanade.tachiyomi.util.view.expand
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
@ -10,8 +9,6 @@ import kotlin.math.abs
|
|||||||
class ReaderNavGestureDetector(private val activity: ReaderActivity) : GestureDetector
|
class ReaderNavGestureDetector(private val activity: ReaderActivity) : GestureDetector
|
||||||
.SimpleOnGestureListener() {
|
.SimpleOnGestureListener() {
|
||||||
|
|
||||||
private val lastPixel = 0f
|
|
||||||
private var buttonY: Float = 20f.dpToPx
|
|
||||||
var hasScrollHorizontal = false
|
var hasScrollHorizontal = false
|
||||||
private set
|
private set
|
||||||
var lockVertical = false
|
var lockVertical = false
|
||||||
@ -20,10 +17,6 @@ class ReaderNavGestureDetector(private val activity: ReaderActivity) : GestureDe
|
|||||||
override fun onDown(e: MotionEvent): Boolean {
|
override fun onDown(e: MotionEvent): Boolean {
|
||||||
lockVertical = false
|
lockVertical = false
|
||||||
hasScrollHorizontal = false
|
hasScrollHorizontal = false
|
||||||
val modE = MotionEvent.obtain(e)
|
|
||||||
modE.setLocation(e.x, 56f.dpToPx)
|
|
||||||
activity.binding.chaptersSheet.root.dispatchTouchEvent(modE)
|
|
||||||
modE.recycle()
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,22 +30,10 @@ class ReaderNavGestureDetector(private val activity: ReaderActivity) : GestureDe
|
|||||||
val newDistanceY = (e1?.rawY ?: 0f) - (e2?.rawY ?: 0f)
|
val newDistanceY = (e1?.rawY ?: 0f) - (e2?.rawY ?: 0f)
|
||||||
if ((!hasScrollHorizontal || lockVertical) && e2 != null) {
|
if ((!hasScrollHorizontal || lockVertical) && e2 != null) {
|
||||||
hasScrollHorizontal = abs(newDistanceX) > abs(newDistanceY) && abs(newDistanceX) > 40
|
hasScrollHorizontal = abs(newDistanceX) > abs(newDistanceY) && abs(newDistanceX) > 40
|
||||||
|
|
||||||
val modE = MotionEvent.obtain(e2)
|
|
||||||
modE.setLocation(
|
|
||||||
e2.x,
|
|
||||||
buttonY + modE.y +
|
|
||||||
(if (activity.binding.readerNav.root.alpha == 0f) activity.binding.readerNav.root.height.toFloat() else 0f)
|
|
||||||
)
|
|
||||||
activity.binding.chaptersSheet.root.dispatchTouchEvent(modE)
|
|
||||||
modE.recycle()
|
|
||||||
if (!lockVertical) {
|
if (!lockVertical) {
|
||||||
lockVertical = abs(newDistanceX) < abs(newDistanceY) && abs(newDistanceY) > 150
|
lockVertical = abs(newDistanceX) < abs(newDistanceY) && abs(newDistanceY) > 150
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasScrollHorizontal) {
|
|
||||||
activity.binding.chaptersSheet.root.sheetBehavior?.collapse()
|
|
||||||
}
|
|
||||||
return !hasScrollHorizontal && lockVertical
|
return !hasScrollHorizontal && lockVertical
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,11 +56,6 @@ class ReaderNavGestureDetector(private val activity: ReaderActivity) : GestureDe
|
|||||||
result = true
|
result = true
|
||||||
}
|
}
|
||||||
|
|
||||||
val modE = MotionEvent.obtain(e2)
|
|
||||||
modE.setLocation(lastPixel, buttonY + modE.y)
|
|
||||||
modE.action = MotionEvent.ACTION_UP
|
|
||||||
activity.binding.chaptersSheet.root.dispatchTouchEvent(modE)
|
|
||||||
modE.recycle()
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
activity.binding.chaptersSheet.root.sheetBehavior?.collapse()
|
activity.binding.chaptersSheet.root.sheetBehavior?.collapse()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user