Dual page split allow to have different setting for Paged and Webtoon (#4527)

This commit is contained in:
Andreas 2021-02-28 22:17:37 +01:00 committed by GitHub
parent d4c9ab793f
commit 7a64bf55cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 68 additions and 31 deletions

View File

@ -23,9 +23,13 @@ object PreferenceKeys {
const val showPageNumber = "pref_show_page_number_key"
const val dualPageSplit = "pref_dual_page_split"
const val dualPageSplitPaged = "pref_dual_page_split"
const val dualPageInvert = "pref_dual_page_invert"
const val dualPageSplitWebtoon = "pref_dual_page_split_webtoon"
const val dualPageInvertPaged = "pref_dual_page_invert"
const val dualPageInvertWebtoon = "pref_dual_page_invert_webtoon"
const val showReadingMode = "pref_show_reading_mode"

View File

@ -89,9 +89,13 @@ class PreferencesHelper(val context: Context) {
fun showPageNumber() = flowPrefs.getBoolean(Keys.showPageNumber, true)
fun dualPageSplit() = flowPrefs.getBoolean(Keys.dualPageSplit, false)
fun dualPageSplitPaged() = flowPrefs.getBoolean(Keys.dualPageSplitPaged, false)
fun dualPageInvert() = flowPrefs.getBoolean(Keys.dualPageInvert, false)
fun dualPageSplitWebtoon() = flowPrefs.getBoolean(Keys.dualPageSplitWebtoon, false)
fun dualPageInvertPaged() = flowPrefs.getBoolean(Keys.dualPageInvertPaged, false)
fun dualPageInvertWebtoon() = flowPrefs.getBoolean(Keys.dualPageInvertWebtoon, false)
fun showReadingMode() = prefs.getBoolean(Keys.showReadingMode, true)

View File

@ -68,18 +68,11 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BaseBottomShee
binding.backgroundColor.bindToIntPreference(preferences.readerTheme(), R.array.reader_themes_values)
binding.showPageNumber.bindToPreference(preferences.showPageNumber())
binding.fullscreen.bindToPreference(preferences.fullscreen())
binding.dualPageSplit.bindToPreference(preferences.dualPageSplit())
binding.keepscreen.bindToPreference(preferences.keepScreenOn())
binding.longTap.bindToPreference(preferences.readWithLongTap())
binding.alwaysShowChapterTransition.bindToPreference(preferences.alwaysShowChapterTransition())
binding.pageTransitions.bindToPreference(preferences.pageTransitions())
// Makes so that dual page invert gets hidden away when turning of dual page split
preferences.dualPageSplit()
.asImmediateFlow { binding.dualPageInvert.isVisible = it }
.launchIn(activity.lifecycleScope)
binding.dualPageInvert.bindToPreference(preferences.dualPageInvert())
// If the preference is explicitly disabled, that means the setting was configured since there is a cutout
if (activity.hasCutout || !preferences.cutoutShort().get()) {
binding.cutoutShort.isVisible = true
@ -102,6 +95,13 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BaseBottomShee
binding.pagerPrefsGroup.scaleType.bindToPreference(preferences.imageScaleType(), 1)
binding.pagerPrefsGroup.zoomStart.bindToPreference(preferences.zoomStart(), 1)
binding.pagerPrefsGroup.cropBorders.bindToPreference(preferences.cropBorders())
// Makes so that dual page invert gets hidden away when turning of dual page split
binding.dualPageSplit.bindToPreference(preferences.dualPageSplitPaged())
preferences.dualPageSplitPaged()
.asImmediateFlow { binding.dualPageInvert.isVisible = it }
.launchIn(activity.lifecycleScope)
binding.dualPageInvert.bindToPreference(preferences.dualPageInvertPaged())
}
/**
@ -118,6 +118,13 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BaseBottomShee
binding.webtoonPrefsGroup.webtoonNav.bindToPreference(preferences.navigationModeWebtoon())
binding.webtoonPrefsGroup.cropBordersWebtoon.bindToPreference(preferences.cropBordersWebtoon())
binding.webtoonPrefsGroup.webtoonSidePadding.bindToIntPreference(preferences.webtoonSidePadding(), R.array.webtoon_side_padding_values)
// Makes so that dual page invert gets hidden away when turning of dual page split
binding.dualPageSplit.bindToPreference(preferences.dualPageSplitWebtoon())
preferences.dualPageSplitWebtoon()
.asImmediateFlow { binding.dualPageInvert.isVisible = it }
.launchIn(activity.lifecycleScope)
binding.dualPageInvert.bindToPreference(preferences.dualPageInvertWebtoon())
}
/**

View File

@ -24,11 +24,15 @@ abstract class ViewerConfig(preferences: PreferencesHelper, private val scope: C
var volumeKeysInverted = false
var trueColor = false
var alwaysShowChapterTransition = true
var dualPageSplit = false
var dualPageInvert = false
var navigationMode = 0
protected set
var dualPageSplit = false
protected set
var dualPageInvert = false
protected set
abstract var navigator: ViewerNavigation
protected set
@ -56,12 +60,6 @@ abstract class ViewerConfig(preferences: PreferencesHelper, private val scope: C
preferences.alwaysShowChapterTransition()
.register({ alwaysShowChapterTransition = it })
preferences.dualPageSplit()
.register({ dualPageSplit = it }, { imagePropertyChangedListener?.invoke() })
preferences.dualPageInvert()
.register({ dualPageInvert = it }, { imagePropertyChangedListener?.invoke() })
}
protected abstract fun defaultNavigation(): ViewerNavigation

View File

@ -44,6 +44,12 @@ class PagerConfig(
preferences.pagerNavInverted()
.register({ tappingInverted = it }, { navigator.invertMode = it })
preferences.dualPageSplitPaged()
.register({ dualPageSplit = it }, { imagePropertyChangedListener?.invoke() })
preferences.dualPageInvertPaged()
.register({ dualPageInvert = it }, { imagePropertyChangedListener?.invoke() })
}
private fun zoomTypeFromPreference(value: Int) {

View File

@ -37,6 +37,12 @@ class WebtoonConfig(
preferences.webtoonNavInverted()
.register({ tappingInverted = it }, { navigator.invertMode = it })
preferences.dualPageSplitWebtoon()
.register({ dualPageSplit = it }, { imagePropertyChangedListener?.invoke() })
preferences.dualPageInvertWebtoon()
.register({ dualPageInvert = it }, { imagePropertyChangedListener?.invoke() })
}
override var navigator: ViewerNavigation = defaultNavigation()

View File

@ -50,18 +50,6 @@ class SettingsReaderController : SettingsController() {
summaryRes = R.string.pref_show_reading_mode_summary
defaultValue = true
}
switchPreference {
key = Keys.dualPageSplit
titleRes = R.string.pref_dual_page_split
defaultValue = false
}
switchPreference {
key = Keys.dualPageInvert
titleRes = R.string.pref_dual_page_invert
summaryRes = R.string.pref_dual_page_invert_summary
defaultValue = false
preferences.dualPageSplit().asImmediateFlow { isVisible = it }.launchIn(viewScope)
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
switchPreference {
key = Keys.trueColor
@ -213,6 +201,18 @@ class SettingsReaderController : SettingsController() {
titleRes = R.string.pref_crop_borders
defaultValue = false
}
switchPreference {
key = Keys.dualPageSplitPaged
titleRes = R.string.pref_dual_page_split
defaultValue = false
}
switchPreference {
key = Keys.dualPageInvertPaged
titleRes = R.string.pref_dual_page_invert
summaryRes = R.string.pref_dual_page_invert_summary
defaultValue = false
preferences.dualPageSplitPaged().asImmediateFlow { isVisible = it }.launchIn(viewScope)
}
}
preferenceCategory {
@ -268,6 +268,18 @@ class SettingsReaderController : SettingsController() {
titleRes = R.string.pref_crop_borders
defaultValue = false
}
switchPreference {
key = Keys.dualPageSplitWebtoon
titleRes = R.string.pref_dual_page_split
defaultValue = false
}
switchPreference {
key = Keys.dualPageInvertWebtoon
titleRes = R.string.pref_dual_page_invert
summaryRes = R.string.pref_dual_page_invert_summary
defaultValue = false
preferences.dualPageSplitWebtoon().asImmediateFlow { isVisible = it }.launchIn(viewScope)
}
}
preferenceCategory {