mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-10 01:35:09 +01:00
More updates to move the chapter bar
This commit is contained in:
parent
363047a2a2
commit
a6a2ef6399
@ -376,7 +376,8 @@ class ReaderActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val gestureDetector = GestureDetectorCompat(this, ReaderNavGestureDetector(this))
|
val readerNavGestureDetector = ReaderNavGestureDetector(this)
|
||||||
|
val gestureDetector = GestureDetectorCompat(this, readerNavGestureDetector)
|
||||||
with(binding.readerNav) {
|
with(binding.readerNav) {
|
||||||
listOf(root, leftChapter, rightChapter, pageSeekbar).forEach {
|
listOf(root, leftChapter, rightChapter, pageSeekbar).forEach {
|
||||||
it.setOnTouchListener { _, event ->
|
it.setOnTouchListener { _, event ->
|
||||||
@ -384,16 +385,24 @@ class ReaderActivity :
|
|||||||
if (event?.action == MotionEvent.ACTION_UP) {
|
if (event?.action == MotionEvent.ACTION_UP) {
|
||||||
if (!result) {
|
if (!result) {
|
||||||
val sheetBehavior = binding.chaptersSheet.root.sheetBehavior
|
val sheetBehavior = binding.chaptersSheet.root.sheetBehavior
|
||||||
|
binding.chaptersSheet.root.dispatchTouchEvent(event)
|
||||||
if (sheetBehavior?.state != BottomSheetBehavior.STATE_SETTLING && !sheetBehavior.isCollapsed()) {
|
if (sheetBehavior?.state != BottomSheetBehavior.STATE_SETTLING && !sheetBehavior.isCollapsed()) {
|
||||||
binding.chaptersSheet.root.dispatchTouchEvent(event)
|
|
||||||
sheetBehavior?.collapse()
|
sheetBehavior?.collapse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (readerNavGestureDetector.lockVertical) {
|
||||||
|
// event.action = MotionEvent.ACTION_CANCEL
|
||||||
|
return@setOnTouchListener true
|
||||||
|
}
|
||||||
} else if ((event?.action != MotionEvent.ACTION_UP || event.action != MotionEvent.ACTION_DOWN) && result) {
|
} else if ((event?.action != MotionEvent.ACTION_UP || event.action != MotionEvent.ACTION_DOWN) && result) {
|
||||||
event.action = MotionEvent.ACTION_CANCEL
|
event.action = MotionEvent.ACTION_CANCEL
|
||||||
return@setOnTouchListener false
|
return@setOnTouchListener false
|
||||||
}
|
}
|
||||||
result
|
if (it == pageSeekbar) {
|
||||||
|
readerNavGestureDetector.lockVertical
|
||||||
|
} else {
|
||||||
|
result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -443,8 +452,8 @@ class ReaderActivity :
|
|||||||
height = 280.dpToPx + insets.systemWindowInsetBottom
|
height = 280.dpToPx + insets.systemWindowInsetBottom
|
||||||
}
|
}
|
||||||
binding.navLayout.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
binding.navLayout.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
leftMargin = 6.dpToPx + insets.systemWindowInsetLeft
|
leftMargin = 12.dpToPx + insets.systemWindowInsetLeft
|
||||||
rightMargin = 6.dpToPx + insets.systemWindowInsetRight
|
rightMargin = 12.dpToPx + insets.systemWindowInsetRight
|
||||||
}
|
}
|
||||||
binding.chaptersSheet.chapterRecycler.updatePaddingRelative(bottom = insets.systemWindowInsetBottom)
|
binding.chaptersSheet.chapterRecycler.updatePaddingRelative(bottom = insets.systemWindowInsetBottom)
|
||||||
binding.viewerContainer.requestLayout()
|
binding.viewerContainer.requestLayout()
|
||||||
|
@ -12,8 +12,10 @@ class ReaderNavGestureDetector(private val activity: ReaderActivity) : GestureDe
|
|||||||
|
|
||||||
private val lastPixel = 0f
|
private val lastPixel = 0f
|
||||||
private var buttonY: Float = 20f.dpToPx
|
private var buttonY: Float = 20f.dpToPx
|
||||||
private var hasScrollHorizontal = false
|
var hasScrollHorizontal = false
|
||||||
private var lockVertical = false
|
private set
|
||||||
|
var lockVertical = false
|
||||||
|
private set
|
||||||
|
|
||||||
override fun onDown(e: MotionEvent): Boolean {
|
override fun onDown(e: MotionEvent): Boolean {
|
||||||
lockVertical = false
|
lockVertical = false
|
||||||
@ -51,7 +53,7 @@ class ReaderNavGestureDetector(private val activity: ReaderActivity) : GestureDe
|
|||||||
if (hasScrollHorizontal) {
|
if (hasScrollHorizontal) {
|
||||||
activity.binding.chaptersSheet.root.sheetBehavior?.collapse()
|
activity.binding.chaptersSheet.root.sheetBehavior?.collapse()
|
||||||
}
|
}
|
||||||
return lockVertical
|
return !hasScrollHorizontal && lockVertical
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFling(
|
override fun onFling(
|
||||||
@ -61,13 +63,14 @@ class ReaderNavGestureDetector(private val activity: ReaderActivity) : GestureDe
|
|||||||
velocityY: Float
|
velocityY: Float
|
||||||
): Boolean {
|
): Boolean {
|
||||||
var result = false
|
var result = false
|
||||||
val diffY = e2.rawY - e1.rawY
|
val diffY = e2.y - e1.y
|
||||||
val diffX = e2.rawX - e1.rawX
|
val diffX = e2.x - e1.x
|
||||||
val sheetBehavior = activity.binding.chaptersSheet.root.sheetBehavior
|
val sheetBehavior = activity.binding.chaptersSheet.root.sheetBehavior
|
||||||
if (!hasScrollHorizontal && abs(diffX) < abs(diffY)
|
if (!hasScrollHorizontal && abs(diffX) < abs(diffY) &&
|
||||||
&& (abs(diffY) > SWIPE_THRESHOLD || abs(velocityY) > SWIPE_VELOCITY_THRESHOLD)
|
(abs(diffY) > SWIPE_THRESHOLD || abs(velocityY) > SWIPE_VELOCITY_THRESHOLD) &&
|
||||||
&& diffY <= 0
|
diffY <= 0
|
||||||
) {
|
) {
|
||||||
|
lockVertical = true
|
||||||
sheetBehavior?.expand()
|
sheetBehavior?.expand()
|
||||||
result = true
|
result = true
|
||||||
}
|
}
|
||||||
@ -84,7 +87,7 @@ class ReaderNavGestureDetector(private val activity: ReaderActivity) : GestureDe
|
|||||||
}
|
}
|
||||||
|
|
||||||
private companion object {
|
private companion object {
|
||||||
const val SWIPE_THRESHOLD = 500
|
const val SWIPE_THRESHOLD = 50
|
||||||
const val SWIPE_VELOCITY_THRESHOLD = 600
|
const val SWIPE_VELOCITY_THRESHOLD = 200
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
android:layout_width="40dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_marginStart="50dp"
|
android:layout_marginStart="60dp"
|
||||||
android:background="?selectableItemBackgroundBorderless"
|
android:background="?selectableItemBackgroundBorderless"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:contentDescription="@string/previous_chapter"
|
android:contentDescription="@string/previous_chapter"
|
||||||
@ -70,7 +70,7 @@
|
|||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginEnd="50dp"
|
android:layout_marginEnd="60dp"
|
||||||
android:background="?selectableItemBackgroundBorderless"
|
android:background="?selectableItemBackgroundBorderless"
|
||||||
android:contentDescription="@string/next_chapter"
|
android:contentDescription="@string/next_chapter"
|
||||||
android:padding="@dimen/material_layout_keylines_screen_edge_margin"
|
android:padding="@dimen/material_layout_keylines_screen_edge_margin"
|
||||||
|
Loading…
Reference in New Issue
Block a user