From b363b9fc1a5f3cd574bf0829d90b50319b83aeee Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 10 Jul 2020 22:24:55 -0400 Subject: [PATCH] Make page transitions setting apply to webtoon viewer as well --- .../ui/reader/ReaderSettingsSheet.kt | 2 +- .../ui/reader/viewer/ViewerConfig.kt | 6 ++++- .../ui/reader/viewer/pager/PagerConfig.kt | 6 ----- .../ui/reader/viewer/webtoon/WebtoonViewer.kt | 12 ++++++++-- .../ui/setting/SettingsReaderController.kt | 10 ++++---- .../main/res/layout/reader_settings_sheet.xml | 23 +++++++++---------- 6 files changed, 32 insertions(+), 27 deletions(-) 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 a31df090d6..773ab36199 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 @@ -92,6 +92,7 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia long_tap.bindToPreference(preferences.readWithLongTap()) always_show_chapter_transition.bindToPreference(preferences.alwaysShowChapterTransition()) crop_borders.bindToPreference(preferences.cropBorders()) + page_transitions.bindToPreference(preferences.pageTransitions()) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { true_color.visible() @@ -108,7 +109,6 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia scale_type.bindToPreference(preferences.imageScaleType(), 1) zoom_start.bindToPreference(preferences.zoomStart(), 1) - page_transitions.bindToPreference(preferences.pageTransitions()) } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt index e65aa37247..8726b35ce8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt @@ -20,8 +20,9 @@ abstract class ViewerConfig(preferences: PreferencesHelper) { var imagePropertyChangedListener: (() -> Unit)? = null var tappingEnabled = true - var longTapEnabled = true var tappingInverted = TappingInvertMode.NONE + var longTapEnabled = true + var usePageTransitions = false var doubleTapAnimDuration = 500 var volumeKeysEnabled = false var volumeKeysInverted = false @@ -39,6 +40,9 @@ abstract class ViewerConfig(preferences: PreferencesHelper) { preferences.readWithLongTap() .register({ longTapEnabled = it }) + preferences.pageTransitions() + .register({ usePageTransitions = it }) + preferences.doubleTapAnimSpeed() .register({ doubleTapAnimDuration = it }) 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 9f09bc7281..7bbd233c9c 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 @@ -11,9 +11,6 @@ import uy.kohesive.injekt.api.get class PagerConfig(private val viewer: PagerViewer, preferences: PreferencesHelper = Injekt.get()) : ViewerConfig(preferences) { - var usePageTransitions = false - private set - var imageScaleType = 1 private set @@ -21,9 +18,6 @@ class PagerConfig(private val viewer: PagerViewer, preferences: PreferencesHelpe private set init { - preferences.pageTransitions() - .register({ usePageTransitions = it }) - preferences.imageScaleType() .register({ imageScaleType = it }, { imagePropertyChangedListener?.invoke() }) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt index b42d6594aa..ff11dd27d4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt @@ -236,14 +236,22 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr * Scrolls up by [scrollDistance]. */ private fun scrollUp() { - recycler.smoothScrollBy(0, -scrollDistance) + if (config.usePageTransitions) { + recycler.smoothScrollBy(0, -scrollDistance) + } else { + recycler.scrollBy(0, -scrollDistance) + } } /** * Scrolls down by [scrollDistance]. */ private fun scrollDown() { - recycler.smoothScrollBy(0, scrollDistance) + if (config.usePageTransitions) { + recycler.smoothScrollBy(0, scrollDistance) + } else { + recycler.scrollBy(0, scrollDistance) + } } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt index 2034ecff39..1e29c0d835 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt @@ -106,6 +106,11 @@ class SettingsReaderController : SettingsController() { titleRes = R.string.pref_crop_borders defaultValue = false } + switchPreference { + key = Keys.enableTransitions + titleRes = R.string.pref_page_transitions + defaultValue = true + } } preferenceCategory { @@ -154,11 +159,6 @@ class SettingsReaderController : SettingsController() { defaultValue = "1" summary = "%s" } - switchPreference { - key = Keys.enableTransitions - titleRes = R.string.pref_page_transitions - defaultValue = true - } } preferenceCategory { diff --git a/app/src/main/res/layout/reader_settings_sheet.xml b/app/src/main/res/layout/reader_settings_sheet.xml index ca623f691e..fd34dfc766 100644 --- a/app/src/main/res/layout/reader_settings_sheet.xml +++ b/app/src/main/res/layout/reader_settings_sheet.xml @@ -179,11 +179,19 @@ android:textColor="?android:attr/textColorSecondary" app:layout_constraintTop_toBottomOf="@id/always_show_chapter_transition" /> + + + app:layout_constraintBottom_toBottomOf="@id/page_transitions" /> @@ -236,20 +244,11 @@ app:layout_constraintStart_toEndOf="@id/verticalcenter" app:layout_constraintTop_toBottomOf="@id/scale_type" /> - -