Update click boundaries in story viewer.

fork-5.53.8
Alex Hart 2022-03-09 13:25:01 -04:00 zatwierdzone przez Cody Henthorne
rodzic ff8d7fa6c2
commit 78214fb39b
1 zmienionych plików z 23 dodań i 2 usunięć

Wyświetl plik

@ -641,6 +641,11 @@ class StoryViewerPageFragment :
private val onReplyToPost: () -> Unit
) : GestureDetector.SimpleOnGestureListener() {
companion object {
private const val BOUNDARY_NEXT = 0.80f
private const val BOUNDARY_PREV = 1f - BOUNDARY_NEXT
}
override fun onDown(e: MotionEvent?): Boolean {
return true
}
@ -658,11 +663,27 @@ class StoryViewerPageFragment :
return true
}
private fun getLeftBoundary(): Float {
return if (container.layoutDirection == View.LAYOUT_DIRECTION_LTR) {
BOUNDARY_PREV
} else {
BOUNDARY_NEXT
}
}
private fun getRightBoundary(): Float {
return if (container.layoutDirection == View.LAYOUT_DIRECTION_LTR) {
BOUNDARY_NEXT
} else {
BOUNDARY_PREV
}
}
override fun onSingleTapUp(e: MotionEvent): Boolean {
if (e.x < container.measuredWidth * 0.25) {
if (e.x < container.measuredWidth * getLeftBoundary()) {
performLeftAction()
return true
} else if (e.x > container.measuredWidth - (container.measuredWidth * 0.25)) {
} else if (e.x > container.measuredWidth - (container.measuredWidth * getRightBoundary())) {
performRightAction()
return true
}