mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 06:39:20 +01:00
Move PageLayout to enum and new file
This commit is contained in:
parent
a99b9b7fcc
commit
1fba86886c
@ -12,9 +12,9 @@ import com.tfcporciuncula.flow.FlowSharedPreferences
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.track.TrackService
|
||||
import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet
|
||||
import eu.kanade.tachiyomi.ui.reader.settings.PageLayout
|
||||
import eu.kanade.tachiyomi.ui.reader.settings.ReaderBottomButton
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.PageLayout
|
||||
import eu.kanade.tachiyomi.ui.recents.RecentMangaAdapter
|
||||
import eu.kanade.tachiyomi.util.system.Themes
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@ -173,7 +173,7 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
fun webtoonNavInverted() = flowPrefs.getEnum(Keys.webtoonNavInverted, ViewerNavigation.TappingInvertMode.NONE)
|
||||
|
||||
fun pageLayout() = flowPrefs.getInt(Keys.pageLayout, PageLayout.AUTOMATIC)
|
||||
fun pageLayout() = flowPrefs.getInt(Keys.pageLayout, PageLayout.AUTOMATIC.value)
|
||||
|
||||
fun invertDoublePages() = flowPrefs.getBoolean(Keys.invertDoublePages, false)
|
||||
|
||||
|
@ -52,12 +52,12 @@ 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.ui.reader.settings.OrientationType
|
||||
import eu.kanade.tachiyomi.ui.reader.settings.PageLayout
|
||||
import eu.kanade.tachiyomi.ui.reader.settings.ReaderBottomButton
|
||||
import eu.kanade.tachiyomi.ui.reader.settings.ReadingModeType
|
||||
import eu.kanade.tachiyomi.ui.reader.settings.TabbedReaderSettingsSheet
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.L2RPagerViewer
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.PageLayout
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerViewer
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.R2LPagerViewer
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.VerticalPagerViewer
|
||||
@ -356,8 +356,8 @@ class ReaderActivity :
|
||||
}
|
||||
|
||||
fun setBottomNavButtons(pageLayout: Int) {
|
||||
val isDoublePage = pageLayout == PageLayout.DOUBLE_PAGES ||
|
||||
(pageLayout == PageLayout.AUTOMATIC && (viewer as? PagerViewer)?.config?.doublePages ?: false)
|
||||
val isDoublePage = pageLayout == PageLayout.DOUBLE_PAGES.value ||
|
||||
(pageLayout == PageLayout.AUTOMATIC.value && (viewer as? PagerViewer)?.config?.doublePages ?: false)
|
||||
binding.chaptersSheet.doublePage.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
this,
|
||||
@ -574,7 +574,7 @@ class ReaderActivity :
|
||||
|
||||
with(binding.chaptersSheet) {
|
||||
doublePage.setOnClickListener {
|
||||
if (preferences.pageLayout().get() == PageLayout.AUTOMATIC) {
|
||||
if (preferences.pageLayout().get() == PageLayout.AUTOMATIC.value) {
|
||||
(viewer as? PagerViewer)?.config?.let { config ->
|
||||
config.doublePages = !config.doublePages
|
||||
reloadChapters(config.doublePages, true)
|
||||
@ -893,7 +893,7 @@ class ReaderActivity :
|
||||
}
|
||||
|
||||
if (newViewer is PagerViewer) {
|
||||
if (preferences.pageLayout().get() == PageLayout.AUTOMATIC) {
|
||||
if (preferences.pageLayout().get() == PageLayout.AUTOMATIC.value) {
|
||||
setDoublePageMode(newViewer)
|
||||
}
|
||||
lastShiftDoubleState?.let { newViewer.config.shiftDoublePage = it }
|
||||
|
@ -0,0 +1,18 @@
|
||||
package eu.kanade.tachiyomi.ui.reader.settings
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import eu.kanade.tachiyomi.R
|
||||
|
||||
enum class PageLayout(val value: Int, @StringRes val stringRes: Int, @StringRes private val _fullStringRes: Int? = null) {
|
||||
SINGLE_PAGE(0, R.string.single_page),
|
||||
DOUBLE_PAGES(1, R.string.double_pages),
|
||||
AUTOMATIC(2, R.string.automatic, R.string.automatic_orientation),
|
||||
;
|
||||
|
||||
@StringRes val fullStringRes = _fullStringRes ?: stringRes
|
||||
|
||||
companion object {
|
||||
fun fromPreference(preference: Int): PageLayout =
|
||||
values().find { it.value == preference } ?: SINGLE_PAGE
|
||||
}
|
||||
}
|
@ -8,7 +8,6 @@ import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.databinding.ReaderPagedLayoutBinding
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.PageLayout
|
||||
import eu.kanade.tachiyomi.util.bindToPreference
|
||||
import eu.kanade.tachiyomi.util.lang.addBetaTag
|
||||
import eu.kanade.tachiyomi.widget.BaseReaderSettingsView
|
||||
@ -96,6 +95,6 @@ class ReaderPagedView @JvmOverloads constructor(context: Context, attrs: Attribu
|
||||
false
|
||||
}
|
||||
binding.extendPastCutout.isVisible = show && isFullFit && hasCutout
|
||||
binding.invertDoublePages.isVisible = show && preferences.pageLayout().get() != PageLayout.SINGLE_PAGE
|
||||
binding.invertDoublePages.isVisible = show && preferences.pageLayout().get() != PageLayout.SINGLE_PAGE.value
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.reader.viewer.pager
|
||||
|
||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.ui.reader.settings.PageLayout
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerConfig
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.navigation.EdgeNavigation
|
||||
@ -45,7 +46,7 @@ class PagerConfig(
|
||||
|
||||
var shiftDoublePage = false
|
||||
|
||||
var doublePages = preferences.pageLayout().get() == PageLayout.DOUBLE_PAGES
|
||||
var doublePages = preferences.pageLayout().get() == PageLayout.DOUBLE_PAGES.value
|
||||
set(value) {
|
||||
field = value
|
||||
if (!value) {
|
||||
@ -55,7 +56,7 @@ class PagerConfig(
|
||||
|
||||
var invertDoublePages = false
|
||||
|
||||
var autoDoublePages = preferences.pageLayout().get() == PageLayout.AUTOMATIC
|
||||
var autoDoublePages = preferences.pageLayout().get() == PageLayout.AUTOMATIC.value
|
||||
|
||||
init {
|
||||
preferences.pageTransitions()
|
||||
@ -101,18 +102,18 @@ class PagerConfig(
|
||||
.asFlow()
|
||||
.drop(1)
|
||||
.onEach {
|
||||
autoDoublePages = it == PageLayout.AUTOMATIC
|
||||
autoDoublePages = it == PageLayout.AUTOMATIC.value
|
||||
if (!autoDoublePages) {
|
||||
doublePages = it == PageLayout.DOUBLE_PAGES
|
||||
doublePages = it == PageLayout.DOUBLE_PAGES.value
|
||||
}
|
||||
reloadChapterListener?.invoke(doublePages)
|
||||
}
|
||||
.launchIn(scope)
|
||||
preferences.pageLayout()
|
||||
.register({
|
||||
autoDoublePages = it == PageLayout.AUTOMATIC
|
||||
autoDoublePages = it == PageLayout.AUTOMATIC.value
|
||||
if (!autoDoublePages) {
|
||||
doublePages = it == PageLayout.DOUBLE_PAGES
|
||||
doublePages = it == PageLayout.DOUBLE_PAGES.value
|
||||
}
|
||||
})
|
||||
|
||||
@ -182,9 +183,3 @@ class PagerConfig(
|
||||
const val CUTOUT_IGNORE = 2
|
||||
}
|
||||
}
|
||||
|
||||
object PageLayout {
|
||||
const val SINGLE_PAGE = 0
|
||||
const val DOUBLE_PAGES = 1
|
||||
const val AUTOMATIC = 2
|
||||
}
|
||||
|
@ -7,8 +7,8 @@ import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn
|
||||
import eu.kanade.tachiyomi.ui.reader.settings.ReaderBottomButton
|
||||
import eu.kanade.tachiyomi.ui.reader.settings.OrientationType
|
||||
import eu.kanade.tachiyomi.ui.reader.settings.PageLayout
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.PageLayout
|
||||
import eu.kanade.tachiyomi.util.lang.addBetaTag
|
||||
import eu.kanade.tachiyomi.util.system.isTablet
|
||||
import eu.kanade.tachiyomi.util.view.activityBinding
|
||||
@ -249,22 +249,19 @@ class SettingsReaderController : SettingsController() {
|
||||
key = Keys.pageLayout
|
||||
title = context.getString(R.string.page_layout).addBetaTag(context)
|
||||
dialogTitleRes = R.string.page_layout
|
||||
entriesRes = arrayOf(
|
||||
R.string.single_page,
|
||||
R.string.double_pages,
|
||||
R.string.automatic_orientation
|
||||
)
|
||||
entryRange = 0..2
|
||||
defaultValue = 2
|
||||
val enumConstants = PageLayout.values()
|
||||
entriesRes = enumConstants.map { it.fullStringRes }.toTypedArray()
|
||||
entryValues = enumConstants.map { it.value }
|
||||
defaultValue = PageLayout.AUTOMATIC.value
|
||||
}
|
||||
infoPreference(R.string.automatic_can_still_switch).apply {
|
||||
preferences.pageLayout().asImmediateFlowIn(viewScope) { isVisible = it == PageLayout.AUTOMATIC }
|
||||
preferences.pageLayout().asImmediateFlowIn(viewScope) { isVisible = it == PageLayout.AUTOMATIC.value }
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.invertDoublePages
|
||||
titleRes = R.string.invert_double_pages
|
||||
defaultValue = false
|
||||
preferences.pageLayout().asImmediateFlowIn(viewScope) { isVisible = it != PageLayout.SINGLE_PAGE }
|
||||
preferences.pageLayout().asImmediateFlowIn(viewScope) { isVisible = it != PageLayout.SINGLE_PAGE.value }
|
||||
}
|
||||
}
|
||||
preferenceCategory {
|
||||
|
Loading…
Reference in New Issue
Block a user