mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 17:11:54 +01:00
Added config to hide transition page when not needed
This commit is contained in:
parent
75e32f6f47
commit
f6a3760dfa
@ -145,6 +145,8 @@ object PreferenceKeys {
|
||||
|
||||
const val keepCatSort = "keep_cat_sort"
|
||||
|
||||
const val alwaysShowChapterTransition = "always_show_chapter_transition"
|
||||
|
||||
@Deprecated("Use the preferences of the source")
|
||||
fun sourceUsername(sourceId: Long) = "pref_source_username_$sourceId"
|
||||
|
||||
@ -153,6 +155,7 @@ object PreferenceKeys {
|
||||
|
||||
fun sourceSharedPref(sourceId: Long) = "source_$sourceId"
|
||||
|
||||
|
||||
fun trackUsername(syncId: Int) = "pref_mangasync_username_$syncId"
|
||||
|
||||
fun trackPassword(syncId: Int) = "pref_mangasync_password_$syncId"
|
||||
|
@ -248,4 +248,6 @@ class PreferencesHelper(val context: Context) {
|
||||
fun keepCatSort() = rxPrefs.getInteger(Keys.keepCatSort, 0)
|
||||
|
||||
fun hideFiltersAtStart() = rxPrefs.getBoolean("hide_filters_at_start", false)
|
||||
|
||||
fun alwaysShowChapterTransition() = rxPrefs.getBoolean(Keys.alwaysShowChapterTransition, true)
|
||||
}
|
||||
|
@ -116,6 +116,7 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia
|
||||
fullscreen.bindToPreference(preferences.fullscreen())
|
||||
keepscreen.bindToPreference(preferences.keepScreenOn())
|
||||
long_tap.bindToPreference(preferences.readWithLongTap())
|
||||
always_show_chapter_transition.bindToPreference(preferences.alwaysShowChapterTransition())
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,6 +46,9 @@ class PagerConfig(private val viewer: PagerViewer, preferences: PreferencesHelpe
|
||||
var readerTheme = 0
|
||||
private set
|
||||
|
||||
var alwaysShowChapterTransition = true
|
||||
private set
|
||||
|
||||
init {
|
||||
preferences.readWithTapping()
|
||||
.register({ tappingEnabled = it })
|
||||
@ -76,6 +79,9 @@ class PagerConfig(private val viewer: PagerViewer, preferences: PreferencesHelpe
|
||||
|
||||
preferences.readerTheme()
|
||||
.register({ readerTheme = 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) {
|
||||
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.reader.viewer.pager
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
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
|
||||
@ -27,7 +28,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.
|
||||
@ -39,7 +40,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
|
||||
@ -49,7 +54,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.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.LinearLayout
|
||||
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) : androidx.recyclerview.widget.R
|
||||
* 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) : androidx.recyclerview.widget.R
|
||||
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
|
||||
@ -45,7 +50,10 @@ class WebtoonAdapter(val viewer: WebtoonViewer) : androidx.recyclerview.widget.R
|
||||
}
|
||||
|
||||
// Add next chapter transition and pages.
|
||||
newItems.add(ChapterTransition.Next(chapters.currChapter, chapters.nextChapter))
|
||||
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.
|
||||
|
@ -34,6 +34,9 @@ class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) {
|
||||
var doubleTapAnimDuration = 500
|
||||
private set
|
||||
|
||||
var alwaysShowChapterTransition = true
|
||||
private set
|
||||
|
||||
init {
|
||||
preferences.readWithTapping()
|
||||
.register({ tappingEnabled = it })
|
||||
@ -52,6 +55,9 @@ class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) {
|
||||
|
||||
preferences.readWithVolumeKeysInverted()
|
||||
.register({ volumeKeysInverted = it })
|
||||
|
||||
preferences.alwaysShowChapterTransition()
|
||||
.register({ alwaysShowChapterTransition = it })
|
||||
}
|
||||
|
||||
fun unsubscribe() {
|
||||
|
@ -172,7 +172,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")
|
||||
|
@ -87,6 +87,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
|
||||
|
||||
|
@ -16,7 +16,7 @@ import rx.schedulers.Schedulers
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
class SourceLoginDialog(bundle: Bundle? = null) : LoginDialogPreference(bundle) {
|
||||
class SourceLoginDialog(bundle: Bundle? = null) : LoginDialogPreference(bundle = bundle) {
|
||||
|
||||
private val source = Injekt.get<SourceManager>().get(args.getLong("key")) as LoginSource
|
||||
|
||||
|
@ -44,7 +44,7 @@
|
||||
<androidx.legacy.widget.Space
|
||||
android:id="@+id/spinner_end"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintStart_toEndOf="parent" />
|
||||
|
||||
<TextView
|
||||
@ -149,11 +149,19 @@
|
||||
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: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_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/long_tap" />
|
||||
app:layout_constraintBottom_toBottomOf="@id/always_show_chapter_transition" />
|
||||
|
||||
<!-- Pager preferences -->
|
||||
|
||||
|
@ -328,6 +328,7 @@
|
||||
<string name="color_filter_a_value">A</string>
|
||||
<string name="reader_theme_smart">Smart (based on page)</string>
|
||||
<string name="reader_theme_smart_theme">Smart (based on page and theme)</string>
|
||||
<string name="pref_always_show_chapter_transition">Always show chapter transition</string>
|
||||
|
||||
<!-- Downloads section -->
|
||||
<string name="pref_download_directory">Download location</string>
|
||||
@ -415,7 +416,7 @@
|
||||
|
||||
|
||||
<!-- Login dialog -->
|
||||
<string name="login_title">Login for %1$s</string>
|
||||
<string name="login_title">Log in to %1$s</string>
|
||||
<string name="username">Username</string>
|
||||
<string name="email">Email address</string>
|
||||
<string name="password">Password</string>
|
||||
@ -678,6 +679,7 @@
|
||||
</plurals>
|
||||
|
||||
<!--Content Description-->
|
||||
<string name="description_backdrop">Backdrop image of manga</string>
|
||||
<string name="description_cover">Cover of manga</string>
|
||||
|
||||
<!-- Information Text -->
|
||||
@ -688,6 +690,8 @@
|
||||
<string name="information_empty_library_filtered">No matches found for your current
|
||||
filters</string>
|
||||
<string name="information_empty_category">You have no categories. Hit the plus button to create one for organizing your library.</string>
|
||||
<string name="information_cloudflare_bypass_failure">Failed to bypass Cloudflare</string>
|
||||
<string name="information_webview_outdated">Please update the WebView app for better compatibility</string>
|
||||
|
||||
<!-- Download Notification -->
|
||||
<string name="download_notifier_downloader_title">Downloader</string>
|
||||
|
Loading…
Reference in New Issue
Block a user