diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt index 219bb847e2..b1a7a16794 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt @@ -133,6 +133,8 @@ object PreferenceKeys { const val downloadBadge = "display_download_badge" + const val alwaysShowChapterTransition = "always_show_chapter_transition" + fun trackUsername(syncId: Int) = "pref_mangasync_username_$syncId" fun trackPassword(syncId: Int) = "pref_mangasync_password_$syncId" diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index 467052129d..17f66d08d8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -203,4 +203,6 @@ class PreferencesHelper(val context: Context) { fun migrateFlags() = rxPrefs.getInteger("migrate_flags", Int.MAX_VALUE) fun trustedSignatures() = rxPrefs.getStringSet("trusted_signatures", emptySet()) + + fun alwaysShowChapterTransition() = rxPrefs.getBoolean(Keys.alwaysShowChapterTransition, true) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt index 43d53c2dee..669dd56078 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt @@ -15,6 +15,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerViewer import eu.kanade.tachiyomi.ui.reader.viewer.webtoon.WebtoonViewer import eu.kanade.tachiyomi.util.view.visible import eu.kanade.tachiyomi.widget.IgnoreFirstSpinnerListener +import kotlinx.android.synthetic.main.reader_settings_sheet.always_show_chapter_transition import kotlinx.android.synthetic.main.reader_settings_sheet.background_color import kotlinx.android.synthetic.main.reader_settings_sheet.crop_borders import kotlinx.android.synthetic.main.reader_settings_sheet.crop_borders_webtoon @@ -84,6 +85,7 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia } keepscreen.bindToPreference(preferences.keepScreenOn()) long_tap.bindToPreference(preferences.readWithLongTap()) + always_show_chapter_transition.bindToPreference(preferences.alwaysShowChapterTransition()) } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerConfig.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerConfig.kt index 89d69b29e2..2ac6eab10e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerConfig.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerConfig.kt @@ -43,6 +43,9 @@ class PagerConfig(private val viewer: PagerViewer, preferences: PreferencesHelpe var doubleTapAnimDuration = 500 private set + var alwaysShowChapterTransition = true + private set + init { preferences.readWithTapping() .register({ tappingEnabled = it }) @@ -70,6 +73,9 @@ class PagerConfig(private val viewer: PagerViewer, preferences: PreferencesHelpe preferences.readWithVolumeKeysInverted() .register({ volumeKeysInverted = it }) + + preferences.alwaysShowChapterTransition() + .register({ alwaysShowChapterTransition = it }) } fun unsubscribe() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt index 67b1368f9a..43af3a54e4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt @@ -185,7 +185,8 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer { */ private fun setChaptersInternal(chapters: ViewerChapters) { Timber.d("setChaptersInternal") - adapter.setChapters(chapters) + var forceTransition = config.alwaysShowChapterTransition || adapter.items.getOrNull(pager.currentItem) is ChapterTransition + adapter.setChapters(chapters, forceTransition) // Layout the pager once a chapter is being set if (pager.visibility == View.GONE) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewerAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewerAdapter.kt index 4162eaf85d..980674333d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewerAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewerAdapter.kt @@ -4,6 +4,7 @@ import android.view.View import android.view.ViewGroup import androidx.viewpager.widget.PagerAdapter import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition +import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter import eu.kanade.tachiyomi.ui.reader.model.ReaderPage import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters import eu.kanade.tachiyomi.widget.ViewPagerAdapter @@ -28,7 +29,7 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() { * next/previous chapter to allow seamless transitions and inverting the pages if the viewer * has R2L direction. */ - fun setChapters(chapters: ViewerChapters) { + fun setChapters(chapters: ViewerChapters, forceTransition: Boolean) { val newItems = mutableListOf() // Add previous chapter pages and transition. @@ -40,7 +41,11 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() { newItems.addAll(prevPages.takeLast(2)) } } - newItems.add(ChapterTransition.Prev(chapters.currChapter, chapters.prevChapter)) + + // Skip transition page if the chapter is loaded & current page is not a transition page + if (forceTransition || chapters.prevChapter?.state !is ReaderChapter.State.Loaded) { + newItems.add(ChapterTransition.Prev(chapters.currChapter, chapters.prevChapter)) + } // Add current chapter. val currPages = chapters.currChapter.pages @@ -50,7 +55,13 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() { // Add next chapter transition and pages. nextTransition = ChapterTransition.Next(chapters.currChapter, chapters.nextChapter) - .also { newItems.add(it) } + .also { + if (forceTransition || + chapters.nextChapter?.state !is ReaderChapter.State.Loaded) { + newItems.add(it) + } + } + if (chapters.nextChapter != null) { // Add at most two pages, because this chapter will be selected before the user can // swap more pages. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt index 3a27815deb..e65a73b8ff 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt @@ -6,6 +6,7 @@ import android.widget.LinearLayout import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition +import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter import eu.kanade.tachiyomi.ui.reader.model.ReaderPage import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters @@ -24,7 +25,7 @@ class WebtoonAdapter(val viewer: WebtoonViewer) : RecyclerView.Adapter() // Add previous chapter pages and transition. @@ -36,7 +37,11 @@ class WebtoonAdapter(val viewer: WebtoonViewer) : RecyclerView.Adapter + + + app:layout_constraintBottom_toBottomOf="@id/always_show_chapter_transition" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 36d57a977d..d2ed26f3bf 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -264,6 +264,7 @@ G B A + Always show chapter transition Download location