mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 22:41:48 +01:00
Added config to hide transition page when not needed (#2682)
* Added config to hide transition page when not needed * Moved always_show_chapter_transition setting to General group
This commit is contained in:
parent
bd2dfaad2e
commit
9936b402a6
@ -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"
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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())
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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() {
|
||||
|
@ -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) {
|
||||
|
@ -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<Any>()
|
||||
|
||||
// Add previous chapter pages and transition.
|
||||
@ -40,7 +41,11 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() {
|
||||
newItems.addAll(prevPages.takeLast(2))
|
||||
}
|
||||
}
|
||||
|
||||
// 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.
|
||||
|
@ -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<RecyclerV
|
||||
* Updates this adapter with the given [chapters]. It handles setting a few pages of the
|
||||
* next/previous chapter to allow seamless transitions.
|
||||
*/
|
||||
fun setChapters(chapters: ViewerChapters) {
|
||||
fun setChapters(chapters: ViewerChapters, forceTransition: Boolean) {
|
||||
val newItems = mutableListOf<Any>()
|
||||
|
||||
// Add previous chapter pages and transition.
|
||||
@ -36,7 +37,11 @@ class WebtoonAdapter(val viewer: WebtoonViewer) : RecyclerView.Adapter<RecyclerV
|
||||
newItems.addAll(prevPages.takeLast(2))
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
@ -45,7 +50,10 @@ class WebtoonAdapter(val viewer: WebtoonViewer) : RecyclerView.Adapter<RecyclerV
|
||||
}
|
||||
|
||||
// Add next chapter transition and pages.
|
||||
if (forceTransition || chapters.nextChapter?.state !is ReaderChapter.State.Loaded) {
|
||||
newItems.add(ChapterTransition.Next(chapters.currChapter, chapters.nextChapter))
|
||||
}
|
||||
|
||||
if (chapters.nextChapter != null) {
|
||||
// Add at most two pages, because this chapter will be selected before the user can
|
||||
// swap more pages.
|
||||
|
@ -37,6 +37,9 @@ class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) {
|
||||
var doubleTapAnimDuration = 500
|
||||
private set
|
||||
|
||||
var alwaysShowChapterTransition = true
|
||||
private set
|
||||
|
||||
init {
|
||||
preferences.readWithTapping()
|
||||
.register({ tappingEnabled = it })
|
||||
@ -58,6 +61,9 @@ class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) {
|
||||
|
||||
preferences.readWithVolumeKeysInverted()
|
||||
.register({ volumeKeysInverted = it })
|
||||
|
||||
preferences.alwaysShowChapterTransition()
|
||||
.register({ alwaysShowChapterTransition = it })
|
||||
}
|
||||
|
||||
fun unsubscribe() {
|
||||
|
@ -175,7 +175,8 @@ class WebtoonViewer(val activity: ReaderActivity) : BaseViewer {
|
||||
*/
|
||||
override fun setChapters(chapters: ViewerChapters) {
|
||||
Timber.d("setChapters")
|
||||
adapter.setChapters(chapters)
|
||||
var forceTransition = config.alwaysShowChapterTransition || currentPage is ChapterTransition
|
||||
adapter.setChapters(chapters, forceTransition)
|
||||
|
||||
if (recycler.visibility == View.GONE) {
|
||||
Timber.d("Recycler first layout")
|
||||
|
@ -103,6 +103,12 @@ class SettingsReaderController : SettingsController() {
|
||||
defaultValue = false
|
||||
}
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.alwaysShowChapterTransition
|
||||
titleRes = R.string.pref_always_show_chapter_transition
|
||||
defaultValue = true
|
||||
}
|
||||
|
||||
preferenceCategory {
|
||||
titleRes = R.string.pager_viewer
|
||||
|
||||
|
@ -152,11 +152,20 @@
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
app:layout_constraintTop_toBottomOf="@id/keepscreen" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/always_show_chapter_transition"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="@string/pref_always_show_chapter_transition"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
app:layout_constraintTop_toBottomOf="@id/long_tap" />
|
||||
|
||||
<androidx.legacy.widget.Space
|
||||
android:id="@+id/end_general_preferences"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/long_tap" />
|
||||
app:layout_constraintBottom_toBottomOf="@id/always_show_chapter_transition" />
|
||||
|
||||
<!-- Pager preferences -->
|
||||
|
||||
|
@ -264,6 +264,7 @@
|
||||
<string name="color_filter_g_value">G</string>
|
||||
<string name="color_filter_b_value">B</string>
|
||||
<string name="color_filter_a_value">A</string>
|
||||
<string name="pref_always_show_chapter_transition">Always show chapter transition</string>
|
||||
|
||||
<!-- Downloads section -->
|
||||
<string name="pref_download_directory">Download location</string>
|
||||
|
Loading…
Reference in New Issue
Block a user