diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index 89e12df125..b91f58ceaf 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -54,7 +54,6 @@ import eu.kanade.tachiyomi.util.storage.getUriCompat import eu.kanade.tachiyomi.util.system.GLUtil import eu.kanade.tachiyomi.util.system.ThemeUtil import eu.kanade.tachiyomi.util.system.dpToPx -import eu.kanade.tachiyomi.util.system.getBottomGestureInsets import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.hasSideNavBar import eu.kanade.tachiyomi.util.system.isBottomTappable @@ -222,9 +221,9 @@ class ReaderActivity : menuVisible = savedInstanceState.getBoolean(::menuVisible.name) } - binding.readerChaptersSheet.chaptersBottomSheet.setup(this) + binding.chaptersSheet.chaptersBottomSheet.setup(this) if (ThemeUtil.isBlueTheme(preferences.theme())) { - binding.readerChaptersSheet.chapterRecycler.setBackgroundColor(getResourceColor(android.R.attr.colorBackground)) + binding.chaptersSheet.chapterRecycler.setBackgroundColor(getResourceColor(android.R.attr.colorBackground)) } config = ReaderConfig() initializeMenu() @@ -236,7 +235,7 @@ class ReaderActivity : override fun onDestroy() { super.onDestroy() viewer?.destroy() - binding.readerChaptersSheet.chaptersBottomSheet.adapter = null + binding.chaptersSheet.chaptersBottomSheet.adapter = null viewer = null config = null bottomSheet?.dismiss() @@ -288,20 +287,15 @@ class ReaderActivity : override fun onOptionsItemSelected(item: MenuItem): Boolean { coroutine?.cancel() when (item.itemId) { - R.id.action_display_settings -> TabbedReaderSettingsSheet(this).show() R.id.action_share_page, R.id.action_set_page_as_cover, R.id.action_save_page -> { val currentChapter = presenter.getCurrentChapter() ?: return true - val page = currentChapter.pages?.getOrNull(binding.readerChaptersSheet.pageSeekBar.progress) ?: return true + val page = currentChapter.pages?.getOrNull(binding.readerNav.pageSeekbar.progress) ?: return true when (item.itemId) { R.id.action_share_page -> shareImage(page) R.id.action_set_page_as_cover -> showSetCoverPrompt(page) R.id.action_save_page -> saveImage(page) } } - R.id.action_reader_settings -> { - val intent = SearchActivity.openReaderSettings(this) - startActivity(intent) - } else -> return super.onOptionsItemSelected(item) } return true @@ -325,8 +319,8 @@ class ReaderActivity : * delegated to the presenter. */ override fun onBackPressed() { - if (binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior.isExpanded()) { - binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior?.collapse() + if (binding.chaptersSheet.chaptersBottomSheet.sheetBehavior.isExpanded()) { + binding.chaptersSheet.chaptersBottomSheet.sheetBehavior?.collapse() return } presenter.onBackPressed() @@ -386,7 +380,7 @@ class ReaderActivity : } // Init listeners on bottom menu - binding.readerChaptersSheet.pageSeekBar.setOnSeekBarChangeListener( + binding.readerNav.pageSeekbar.setOnSeekBarChangeListener( object : SimpleSeekBarListener() { override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) { if (viewer != null && fromUser) { @@ -398,9 +392,9 @@ class ReaderActivity : // Set initial visibility setMenuVisibility(menuVisible) - binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior?.isHideable = !menuVisible - if (!menuVisible) binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior?.hide() - val peek = binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior?.peekHeight ?: 30.dpToPx + binding.chaptersSheet.chaptersBottomSheet.sheetBehavior?.isHideable = !menuVisible + if (!menuVisible) binding.chaptersSheet.chaptersBottomSheet.sheetBehavior?.hide() + // val peek = binding.chaptersSheet.chaptersBottomSheet.sheetBehavior?.peekHeight ?: 30.dpToPx binding.readerLayout.doOnApplyWindowInsets { v, insets, _ -> sheetManageNavColor = when { insets.isBottomTappable() -> { @@ -424,13 +418,16 @@ class ReaderActivity : binding.toolbar.updateLayoutParams { topMargin = insets.systemWindowInsetTop } - binding.readerChaptersSheet.chaptersBottomSheet.updateLayoutParams { + binding.chaptersSheet.chaptersBottomSheet.updateLayoutParams { leftMargin = insets.systemWindowInsetLeft rightMargin = insets.systemWindowInsetRight height = 280.dpToPx + insets.systemWindowInsetBottom } - binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior?.peekHeight = peek + insets.getBottomGestureInsets() - binding.readerChaptersSheet.chapterRecycler.updatePaddingRelative(bottom = insets.systemWindowInsetBottom) + binding.navLayout.updateLayoutParams { + leftMargin = 6.dpToPx + insets.systemWindowInsetLeft + rightMargin = 6.dpToPx + insets.systemWindowInsetRight + } + binding.chaptersSheet.chapterRecycler.updatePaddingRelative(bottom = insets.systemWindowInsetBottom) binding.viewerContainer.requestLayout() } } @@ -448,10 +445,10 @@ class ReaderActivity : systemUi?.show() binding.readerMenu.visible() - if (binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior.isExpanded()) { - binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior?.isHideable = false + if (binding.chaptersSheet.chaptersBottomSheet.sheetBehavior.isExpanded()) { + binding.chaptersSheet.chaptersBottomSheet.sheetBehavior?.isHideable = false } - if (!binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior.isExpanded() && sheetManageNavColor) { + if (!binding.chaptersSheet.chaptersBottomSheet.sheetBehavior.isExpanded() && sheetManageNavColor) { window.navigationBarColor = Color.TRANSPARENT } if (animate) { @@ -466,7 +463,7 @@ class ReaderActivity : ) binding.appBar.startAnimation(toolbarAnimation) } - binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior?.collapse() + binding.chaptersSheet.chaptersBottomSheet.sheetBehavior?.collapse() } } else { systemUi?.hide() @@ -481,8 +478,8 @@ class ReaderActivity : } ) binding.appBar.startAnimation(toolbarAnimation) - BottomSheetBehavior.from(binding.readerChaptersSheet.chaptersBottomSheet).isHideable = true - binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior?.hide() + BottomSheetBehavior.from(binding.chaptersSheet.chaptersBottomSheet).isHideable = true + binding.chaptersSheet.chaptersBottomSheet.sheetBehavior?.hide() } else { binding.readerMenu.gone() } @@ -547,7 +544,7 @@ class ReaderActivity : binding.toolbar.title = manga.title - binding.readerChaptersSheet.pageSeekBar.isRTL = newViewer is R2LPagerViewer + binding.readerNav.pageSeekbar.isRTL = newViewer is R2LPagerViewer binding.pleaseWait.visible() binding.pleaseWait.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in_long)) @@ -608,7 +605,7 @@ class ReaderActivity : } fun refreshChapters() { - binding.readerChaptersSheet.chaptersBottomSheet.refreshList() + binding.chaptersSheet.chaptersBottomSheet.refreshList() } /** @@ -620,22 +617,30 @@ class ReaderActivity : val newChapter = presenter.onPageSelected(page) val pages = page.chapter.pages ?: return - // Set bottom page number - binding.pageNumber.text = "${page.number}/${pages.size}" - // Set seekbar page number - binding.readerChaptersSheet.pageText.text = "${page.number} / ${pages.size}" + val currentPage = page.number + val totalPages = pages.size - if (!newChapter && binding.readerChaptersSheet.chaptersBottomSheet.shouldCollapse && binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior.isExpanded()) { - binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior?.collapse() + // Set bottom page number + binding.pageNumber.text = "$currentPage/$totalPages" + + if (viewer is R2LPagerViewer) { + binding.readerNav.rightPageText.text = currentPage.toString() + binding.readerNav.leftPageText.text = totalPages.toString() + } else { + binding.readerNav.leftPageText.text = currentPage.toString() + binding.readerNav.rightPageText.text = totalPages.toString() } - if (binding.readerChaptersSheet.chaptersBottomSheet.selectedChapterId != page.chapter.chapter.id) { - binding.readerChaptersSheet.chaptersBottomSheet.refreshList() + if (!newChapter && binding.chaptersSheet.chaptersBottomSheet.shouldCollapse && binding.chaptersSheet.chaptersBottomSheet.sheetBehavior.isExpanded()) { + binding.chaptersSheet.chaptersBottomSheet.sheetBehavior?.collapse() } - binding.readerChaptersSheet.chaptersBottomSheet.shouldCollapse = true + if (binding.chaptersSheet.chaptersBottomSheet.selectedChapterId != page.chapter.chapter.id) { + binding.chaptersSheet.chaptersBottomSheet.refreshList() + } + binding.chaptersSheet.chaptersBottomSheet.shouldCollapse = true // Set seekbar progress - binding.readerChaptersSheet.pageSeekBar.max = pages.lastIndex - binding.readerChaptersSheet.pageSeekBar.progress = page.index + binding.readerNav.pageSeekbar.max = pages.lastIndex + binding.readerNav.pageSeekbar.progress = page.index } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ReaderChapterSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ReaderChapterSheet.kt index 4f27c53da8..3879e9f64e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ReaderChapterSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ReaderChapterSheet.kt @@ -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.isVisible import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.google.android.material.bottomsheet.BottomSheetBehavior @@ -15,16 +16,20 @@ import com.mikepenz.fastadapter.adapters.ItemAdapter import com.mikepenz.fastadapter.listeners.ClickEventHook import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.databinding.ReaderChaptersSheetBinding +import eu.kanade.tachiyomi.ui.main.SearchActivity import eu.kanade.tachiyomi.ui.reader.ReaderActivity import eu.kanade.tachiyomi.ui.reader.ReaderPresenter +import eu.kanade.tachiyomi.ui.reader.settings.TabbedReaderSettingsSheet import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.launchUI import eu.kanade.tachiyomi.util.view.collapse import eu.kanade.tachiyomi.util.view.expand +import eu.kanade.tachiyomi.util.view.gone +import eu.kanade.tachiyomi.util.view.isCollapsed import eu.kanade.tachiyomi.util.view.isExpanded -import eu.kanade.tachiyomi.util.view.visInvisIf -import eu.kanade.tachiyomi.util.view.visibleIf +import eu.kanade.tachiyomi.util.view.visible +import kotlin.math.abs import kotlin.math.max import kotlin.math.min import kotlin.math.roundToInt @@ -64,10 +69,20 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr activity.openMangaInBrowser() } + binding.displayOptions.setOnClickListener { + TabbedReaderSettingsSheet(activity).show() + } + + binding.fullSettings.setOnClickListener { + val intent = SearchActivity.openReaderSettings(activity) + activity.startActivity(intent) + } + post { 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() } sheetBehavior?.addBottomSheetCallback( @@ -75,10 +90,11 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr override fun onSlide(bottomSheet: View, progress: Float) { binding.pill.alpha = (1 - max(0f, progress)) * 0.25f val trueProgress = max(progress, 0f) - binding.chaptersButton.alpha = 1 - trueProgress - binding.webviewButton.alpha = trueProgress - binding.webviewButton.visibleIf(binding.webviewButton.alpha > 0) - binding.chaptersButton.visInvisIf(binding.chaptersButton.alpha > 0) + activity.binding.readerNav.root.alpha = (1 - abs(progress)).coerceIn(0f, 1f) +// binding.chaptersButton.alpha = 1 - trueProgress +// binding.webviewButton.alpha = trueProgress +// binding.webviewButton.visibleIf(binding.webviewButton.alpha > 0) +// binding.chaptersButton.visInvisIf(binding.chaptersButton.alpha > 0) backgroundTintList = ColorStateList.valueOf(lerpColor(primary, fullPrimary, trueProgress)) binding.chapterRecycler.alpha = trueProgress @@ -96,19 +112,32 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr adapter?.getPosition(presenter.getCurrentChapter()?.chapter?.id ?: 0L) ?: 0, binding.chapterRecycler.height / 2 - 30.dpToPx ) - binding.chaptersButton.alpha = 1f - binding.webviewButton.alpha = 0f + activity.binding.readerNav.root.visible() + activity.binding.readerNav.root.alpha = 1f +// binding.chaptersButton.alpha = 1f +// binding.webviewButton.alpha = 0f + } + if (state == BottomSheetBehavior.STATE_DRAGGING || state == BottomSheetBehavior.STATE_SETTLING) { + activity.binding.readerNav.root.visible() } if (state == BottomSheetBehavior.STATE_EXPANDED) { + activity.binding.readerNav.root.gone() + activity.binding.readerNav.root.alpha = 0f binding.chapterRecycler.alpha = 1f - binding.chaptersButton.alpha = 0f - binding.webviewButton.alpha = 1f +// binding.chaptersButton.alpha = 0f +// binding.webviewButton.alpha = 1f if (activity.sheetManageNavColor) activity.window.navigationBarColor = primary } + if (state == BottomSheetBehavior.STATE_HIDDEN) { + activity.binding.readerNav.root.alpha = 0f + activity.binding.readerNav.root.gone() + } binding.chapterRecycler.isClickable = state == BottomSheetBehavior.STATE_EXPANDED binding.chapterRecycler.isFocusable = state == BottomSheetBehavior.STATE_EXPANDED - binding.webviewButton.visibleIf(state != BottomSheetBehavior.STATE_COLLAPSED) - binding.chaptersButton.visInvisIf(state != BottomSheetBehavior.STATE_EXPANDED) + binding.chapterRecycler.isClickable = state == BottomSheetBehavior.STATE_COLLAPSED + binding.chapterRecycler.isFocusable = state == BottomSheetBehavior.STATE_COLLAPSED +// binding.webviewButton.visibleIf(state != BottomSheetBehavior.STATE_COLLAPSED) +// binding.chaptersButton.visInvisIf(state != BottomSheetBehavior.STATE_EXPANDED) } } ) diff --git a/app/src/main/res/color/secondary_alpha.xml b/app/src/main/res/color/secondary_alpha.xml new file mode 100644 index 0000000000..76ab945dd7 --- /dev/null +++ b/app/src/main/res/color/secondary_alpha.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/chapter_nav.xml b/app/src/main/res/drawable/chapter_nav.xml new file mode 100644 index 0000000000..05f82d7418 --- /dev/null +++ b/app/src/main/res/drawable/chapter_nav.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_skip_next_24.xml b/app/src/main/res/drawable/ic_skip_next_24.xml new file mode 100644 index 0000000000..757a516afe --- /dev/null +++ b/app/src/main/res/drawable/ic_skip_next_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_skip_previous_24.xml b/app/src/main/res/drawable/ic_skip_previous_24.xml new file mode 100644 index 0000000000..ab5a2f8b28 --- /dev/null +++ b/app/src/main/res/drawable/ic_skip_previous_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/reader_activity.xml b/app/src/main/res/layout/reader_activity.xml index 7ae06029e2..160665a12c 100644 --- a/app/src/main/res/layout/reader_activity.xml +++ b/app/src/main/res/layout/reader_activity.xml @@ -1,7 +1,9 @@ @@ -50,7 +52,7 @@ android:id="@+id/app_bar" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="?attr/colorSecondary"> + android:background="@color/secondary_alpha"> + + + + + + android:id="@+id/chapters_sheet"/> @@ -54,32 +56,45 @@ android:padding="@dimen/material_layout_keylines_screen_edge_margin" app:tint="?actionBarTintColor" android:tooltipText="@string/open_in_webview" + app:layout_constraintHorizontal_chainStyle="spread" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintStart_toStartOf="parent" + app:layout_constraintStart_toEndOf="@id/chapters_button" + app:layout_constraintEnd_toStartOf="@id/display_options" app:layout_constraintTop_toTopOf="parent" - android:alpha="0.0" app:srcCompat="@drawable/ic_open_in_webview_24dp" /> - - - + app:srcCompat="@drawable/ic_tune_24dp" /> + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/reader.xml b/app/src/main/res/menu/reader.xml index 510d9a1323..6c7312f79f 100644 --- a/app/src/main/res/menu/reader.xml +++ b/app/src/main/res/menu/reader.xml @@ -2,12 +2,6 @@ - - - - -