mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 15:01:52 +01:00
Added chapter/page-contextual disabling / hiding of nav buttons and nav bar
Co-Authored-By: Hunter Nickel <25621728+datreesezcup@users.noreply.github.com>
This commit is contained in:
parent
0892a23f2a
commit
3d6d934708
@ -957,12 +957,21 @@ class ReaderActivity :
|
||||
)
|
||||
) % 2 != 0
|
||||
}
|
||||
val currentChapterPageCount = viewerChapters.currChapter.pages?.size ?: 1
|
||||
binding.readerNav.root.visibility = when {
|
||||
currentChapterPageCount == 1 -> View.GONE
|
||||
binding.chaptersSheet.root.sheetBehavior.isCollapsed() -> View.VISIBLE
|
||||
else -> View.INVISIBLE
|
||||
}
|
||||
lastShiftDoubleState = null
|
||||
viewer?.setChapters(viewerChapters)
|
||||
intentPageNumber?.let { moveToPageIndex(it) }
|
||||
intentPageNumber = null
|
||||
binding.toolbar.subtitle = viewerChapters.currChapter.chapter.name
|
||||
if (viewer is R2LPagerViewer) {
|
||||
if (viewerChapters.nextChapter == null && viewerChapters.prevChapter == null) {
|
||||
binding.readerNav.leftChapter.isVisible = false
|
||||
binding.readerNav.rightChapter.isVisible = false
|
||||
} else if (viewer is R2LPagerViewer) {
|
||||
binding.readerNav.leftChapter.alpha = if (viewerChapters.nextChapter != null) 1f else 0.5f
|
||||
binding.readerNav.rightChapter.alpha = if (viewerChapters.prevChapter != null) 1f else 0.5f
|
||||
} else {
|
||||
|
@ -7,6 +7,7 @@ import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
@ -67,7 +68,9 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr
|
||||
binding.chapterRecycler.alpha = if (sheetBehavior.isExpanded()) 1f else 0f
|
||||
binding.chapterRecycler.isClickable = sheetBehavior.isExpanded()
|
||||
binding.chapterRecycler.isFocusable = sheetBehavior.isExpanded()
|
||||
activity.binding.readerNav.root.isVisible = sheetBehavior.isCollapsed()
|
||||
if (!activity.binding.readerNav.root.isGone) {
|
||||
activity.binding.readerNav.root.isVisible = sheetBehavior.isCollapsed()
|
||||
}
|
||||
}
|
||||
|
||||
sheetBehavior?.addBottomSheetCallback(
|
||||
@ -92,21 +95,29 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr
|
||||
adapter?.getPosition(presenter.getCurrentChapter()?.chapter?.id ?: 0L) ?: 0,
|
||||
binding.chapterRecycler.height / 2 - 30.dpToPx
|
||||
)
|
||||
activity.binding.readerNav.root.isVisible = true
|
||||
if (!activity.binding.readerNav.root.isGone) {
|
||||
activity.binding.readerNav.root.isVisible = true
|
||||
}
|
||||
activity.binding.readerNav.root.alpha = 1f
|
||||
}
|
||||
if (state == BottomSheetBehavior.STATE_DRAGGING || state == BottomSheetBehavior.STATE_SETTLING) {
|
||||
activity.binding.readerNav.root.isVisible = true
|
||||
if (!activity.binding.readerNav.root.isGone) {
|
||||
activity.binding.readerNav.root.isVisible = true
|
||||
}
|
||||
}
|
||||
if (state == BottomSheetBehavior.STATE_EXPANDED) {
|
||||
activity.binding.readerNav.root.isInvisible = true
|
||||
if (!activity.binding.readerNav.root.isGone) {
|
||||
activity.binding.readerNav.root.isInvisible = true
|
||||
}
|
||||
activity.binding.readerNav.root.alpha = 0f
|
||||
binding.chapterRecycler.alpha = 1f
|
||||
if (activity.sheetManageNavColor) activity.window.navigationBarColor = primary
|
||||
}
|
||||
if (state == BottomSheetBehavior.STATE_HIDDEN) {
|
||||
activity.binding.readerNav.root.alpha = 0f
|
||||
activity.binding.readerNav.root.isInvisible = true
|
||||
if (!activity.binding.readerNav.root.isGone) {
|
||||
activity.binding.readerNav.root.isInvisible = true
|
||||
}
|
||||
}
|
||||
binding.chapterRecycler.isClickable = state == BottomSheetBehavior.STATE_EXPANDED
|
||||
binding.chapterRecycler.isFocusable = state == BottomSheetBehavior.STATE_EXPANDED
|
||||
|
Loading…
Reference in New Issue
Block a user