mirror of
https://git.mihon.tech/mihonapp/mihon
synced 2024-11-23 13:45:43 +03:00
Split reader preferences from PreferencesHelper (#8042)
This commit is contained in:
parent
2b089648a3
commit
e275897bf9
16 changed files with 309 additions and 268 deletions
|
@ -29,6 +29,7 @@ import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||||
import eu.kanade.tachiyomi.network.NetworkPreferences
|
import eu.kanade.tachiyomi.network.NetworkPreferences
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||||
import eu.kanade.tachiyomi.util.system.isDevFlavor
|
import eu.kanade.tachiyomi.util.system.isDevFlavor
|
||||||
import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory
|
import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
@ -151,6 +152,9 @@ class PreferenceModule(val application: Application) : InjektModule {
|
||||||
addSingletonFactory {
|
addSingletonFactory {
|
||||||
LibraryPreferences(get())
|
LibraryPreferences(get())
|
||||||
}
|
}
|
||||||
|
addSingletonFactory {
|
||||||
|
ReaderPreferences(get())
|
||||||
|
}
|
||||||
addSingletonFactory {
|
addSingletonFactory {
|
||||||
PreferencesHelper(
|
PreferencesHelper(
|
||||||
context = application,
|
context = application,
|
||||||
|
|
|
@ -18,6 +18,7 @@ import eu.kanade.tachiyomi.extension.ExtensionUpdateJob
|
||||||
import eu.kanade.tachiyomi.network.NetworkPreferences
|
import eu.kanade.tachiyomi.network.NetworkPreferences
|
||||||
import eu.kanade.tachiyomi.network.PREF_DOH_CLOUDFLARE
|
import eu.kanade.tachiyomi.network.PREF_DOH_CLOUDFLARE
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
||||||
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||||
import eu.kanade.tachiyomi.util.preference.minusAssign
|
import eu.kanade.tachiyomi.util.preference.minusAssign
|
||||||
import eu.kanade.tachiyomi.util.preference.plusAssign
|
import eu.kanade.tachiyomi.util.preference.plusAssign
|
||||||
import eu.kanade.tachiyomi.util.system.DeviceUtil
|
import eu.kanade.tachiyomi.util.system.DeviceUtil
|
||||||
|
@ -42,6 +43,7 @@ object Migrations {
|
||||||
sourcePreferences: SourcePreferences,
|
sourcePreferences: SourcePreferences,
|
||||||
securityPreferences: SecurityPreferences,
|
securityPreferences: SecurityPreferences,
|
||||||
libraryPreferences: LibraryPreferences,
|
libraryPreferences: LibraryPreferences,
|
||||||
|
readerPreferences: ReaderPreferences,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val oldVersion = preferences.lastVersionCode().get()
|
val oldVersion = preferences.lastVersionCode().get()
|
||||||
if (oldVersion < BuildConfig.VERSION_CODE) {
|
if (oldVersion < BuildConfig.VERSION_CODE) {
|
||||||
|
@ -269,8 +271,8 @@ object Migrations {
|
||||||
if (oldVersion < 77) {
|
if (oldVersion < 77) {
|
||||||
val oldReaderTap = prefs.getBoolean("reader_tap", false)
|
val oldReaderTap = prefs.getBoolean("reader_tap", false)
|
||||||
if (!oldReaderTap) {
|
if (!oldReaderTap) {
|
||||||
preferences.navigationModePager().set(5)
|
readerPreferences.navigationModePager().set(5)
|
||||||
preferences.navigationModeWebtoon().set(5)
|
readerPreferences.navigationModeWebtoon().set(5)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (oldVersion < 81) {
|
if (oldVersion < 81) {
|
||||||
|
|
|
@ -10,8 +10,6 @@ import eu.kanade.tachiyomi.core.preference.getEnum
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.track.TrackService
|
import eu.kanade.tachiyomi.data.track.TrackService
|
||||||
import eu.kanade.tachiyomi.data.track.anilist.Anilist
|
import eu.kanade.tachiyomi.data.track.anilist.Anilist
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
|
||||||
import eu.kanade.tachiyomi.util.system.DeviceUtil
|
import eu.kanade.tachiyomi.util.system.DeviceUtil
|
||||||
import eu.kanade.tachiyomi.util.system.isDynamicColorAvailable
|
import eu.kanade.tachiyomi.util.system.isDynamicColorAvailable
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
@ -59,90 +57,6 @@ class PreferencesHelper(
|
||||||
|
|
||||||
fun themeDarkAmoled() = preferenceStore.getBoolean("pref_theme_dark_amoled_key", false)
|
fun themeDarkAmoled() = preferenceStore.getBoolean("pref_theme_dark_amoled_key", false)
|
||||||
|
|
||||||
fun pageTransitions() = preferenceStore.getBoolean("pref_enable_transitions_key", true)
|
|
||||||
|
|
||||||
fun doubleTapAnimSpeed() = preferenceStore.getInt("pref_double_tap_anim_speed", 500)
|
|
||||||
|
|
||||||
fun showPageNumber() = preferenceStore.getBoolean("pref_show_page_number_key", true)
|
|
||||||
|
|
||||||
fun dualPageSplitPaged() = preferenceStore.getBoolean("pref_dual_page_split", false)
|
|
||||||
|
|
||||||
fun dualPageInvertPaged() = preferenceStore.getBoolean("pref_dual_page_invert", false)
|
|
||||||
|
|
||||||
fun dualPageSplitWebtoon() = preferenceStore.getBoolean("pref_dual_page_split_webtoon", false)
|
|
||||||
|
|
||||||
fun dualPageInvertWebtoon() = preferenceStore.getBoolean("pref_dual_page_invert_webtoon", false)
|
|
||||||
|
|
||||||
fun longStripSplitWebtoon() = preferenceStore.getBoolean("pref_long_strip_split_webtoon", true)
|
|
||||||
|
|
||||||
fun showReadingMode() = preferenceStore.getBoolean("pref_show_reading_mode", true)
|
|
||||||
|
|
||||||
fun trueColor() = preferenceStore.getBoolean("pref_true_color_key", false)
|
|
||||||
|
|
||||||
fun fullscreen() = preferenceStore.getBoolean("fullscreen", true)
|
|
||||||
|
|
||||||
fun cutoutShort() = preferenceStore.getBoolean("cutout_short", true)
|
|
||||||
|
|
||||||
fun keepScreenOn() = preferenceStore.getBoolean("pref_keep_screen_on_key", true)
|
|
||||||
|
|
||||||
fun customBrightness() = preferenceStore.getBoolean("pref_custom_brightness_key", false)
|
|
||||||
|
|
||||||
fun customBrightnessValue() = preferenceStore.getInt("custom_brightness_value", 0)
|
|
||||||
|
|
||||||
fun colorFilter() = preferenceStore.getBoolean("pref_color_filter_key", false)
|
|
||||||
|
|
||||||
fun colorFilterValue() = preferenceStore.getInt("color_filter_value", 0)
|
|
||||||
|
|
||||||
fun colorFilterMode() = preferenceStore.getInt("color_filter_mode", 0)
|
|
||||||
|
|
||||||
fun grayscale() = preferenceStore.getBoolean("pref_grayscale", false)
|
|
||||||
|
|
||||||
fun invertedColors() = preferenceStore.getBoolean("pref_inverted_colors", false)
|
|
||||||
|
|
||||||
fun defaultReadingMode() = preferenceStore.getInt("pref_default_reading_mode_key", ReadingModeType.RIGHT_TO_LEFT.flagValue)
|
|
||||||
|
|
||||||
fun defaultOrientationType() = preferenceStore.getInt("pref_default_orientation_type_key", OrientationType.FREE.flagValue)
|
|
||||||
|
|
||||||
fun imageScaleType() = preferenceStore.getInt("pref_image_scale_type_key", 1)
|
|
||||||
|
|
||||||
fun zoomStart() = preferenceStore.getInt("pref_zoom_start_key", 1)
|
|
||||||
|
|
||||||
fun readerTheme() = preferenceStore.getInt("pref_reader_theme_key", 1)
|
|
||||||
|
|
||||||
fun alwaysShowChapterTransition() = preferenceStore.getBoolean("always_show_chapter_transition", true)
|
|
||||||
|
|
||||||
fun cropBorders() = preferenceStore.getBoolean("crop_borders", false)
|
|
||||||
|
|
||||||
fun navigateToPan() = preferenceStore.getBoolean("navigate_pan", true)
|
|
||||||
|
|
||||||
fun landscapeZoom() = preferenceStore.getBoolean("landscape_zoom", true)
|
|
||||||
|
|
||||||
fun cropBordersWebtoon() = preferenceStore.getBoolean("crop_borders_webtoon", false)
|
|
||||||
|
|
||||||
fun webtoonSidePadding() = preferenceStore.getInt("webtoon_side_padding", 0)
|
|
||||||
|
|
||||||
fun pagerNavInverted() = preferenceStore.getEnum("reader_tapping_inverted", Values.TappingInvertMode.NONE)
|
|
||||||
|
|
||||||
fun webtoonNavInverted() = preferenceStore.getEnum("reader_tapping_inverted_webtoon", Values.TappingInvertMode.NONE)
|
|
||||||
|
|
||||||
fun readWithLongTap() = preferenceStore.getBoolean("reader_long_tap", true)
|
|
||||||
|
|
||||||
fun readWithVolumeKeys() = preferenceStore.getBoolean("reader_volume_keys", false)
|
|
||||||
|
|
||||||
fun readWithVolumeKeysInverted() = preferenceStore.getBoolean("reader_volume_keys_inverted", false)
|
|
||||||
|
|
||||||
fun navigationModePager() = preferenceStore.getInt("reader_navigation_mode_pager", 0)
|
|
||||||
|
|
||||||
fun navigationModeWebtoon() = preferenceStore.getInt("reader_navigation_mode_webtoon", 0)
|
|
||||||
|
|
||||||
fun showNavigationOverlayNewUser() = preferenceStore.getBoolean("reader_navigation_overlay_new_user", true)
|
|
||||||
|
|
||||||
fun showNavigationOverlayOnStart() = preferenceStore.getBoolean("reader_navigation_overlay_on_start", false)
|
|
||||||
|
|
||||||
fun readerHideThreshold() = preferenceStore.getEnum("reader_hide_threshold", Values.ReaderHideThreshold.LOW)
|
|
||||||
|
|
||||||
fun autoUpdateTrack() = preferenceStore.getBoolean("pref_auto_update_manga_sync_key", true)
|
|
||||||
|
|
||||||
fun lastVersionCode() = preferenceStore.getInt("last_version_code", 0)
|
fun lastVersionCode() = preferenceStore.getInt("last_version_code", 0)
|
||||||
|
|
||||||
fun trackUsername(sync: TrackService) = preferenceStore.getString(Keys.trackUsername(sync.id), "")
|
fun trackUsername(sync: TrackService) = preferenceStore.getString(Keys.trackUsername(sync.id), "")
|
||||||
|
@ -175,8 +89,6 @@ class PreferencesHelper(
|
||||||
|
|
||||||
fun splitTallImages() = preferenceStore.getBoolean("split_tall_images", false)
|
fun splitTallImages() = preferenceStore.getBoolean("split_tall_images", false)
|
||||||
|
|
||||||
fun folderPerManga() = preferenceStore.getBoolean("create_folder_per_manga", false)
|
|
||||||
|
|
||||||
fun numberOfBackups() = preferenceStore.getInt("backup_slots", 2)
|
fun numberOfBackups() = preferenceStore.getInt("backup_slots", 2)
|
||||||
|
|
||||||
fun backupInterval() = preferenceStore.getInt("backup_interval", 12)
|
fun backupInterval() = preferenceStore.getInt("backup_interval", 12)
|
||||||
|
@ -203,9 +115,7 @@ class PreferencesHelper(
|
||||||
|
|
||||||
fun autoDownloadWhileReading() = preferenceStore.getInt("auto_download_while_reading", 0)
|
fun autoDownloadWhileReading() = preferenceStore.getInt("auto_download_while_reading", 0)
|
||||||
|
|
||||||
fun skipRead() = preferenceStore.getBoolean("skip_read", false)
|
fun autoUpdateTrack() = preferenceStore.getBoolean("pref_auto_update_manga_sync_key", true)
|
||||||
|
|
||||||
fun skipFiltered() = preferenceStore.getBoolean("skip_filtered", true)
|
|
||||||
|
|
||||||
fun migrateFlags() = preferenceStore.getInt("migrate_flags", Int.MAX_VALUE)
|
fun migrateFlags() = preferenceStore.getInt("migrate_flags", Int.MAX_VALUE)
|
||||||
|
|
||||||
|
|
|
@ -120,6 +120,7 @@ class MainActivity : BaseActivity() {
|
||||||
sourcePreferences = sourcePreferences,
|
sourcePreferences = sourcePreferences,
|
||||||
securityPreferences = Injekt.get(),
|
securityPreferences = Injekt.get(),
|
||||||
libraryPreferences = libraryPreferences,
|
libraryPreferences = libraryPreferences,
|
||||||
|
readerPreferences = Injekt.get(),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
|
|
@ -60,6 +60,7 @@ import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
||||||
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderSettingsSheet
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderSettingsSheet
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer
|
import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer
|
||||||
|
@ -85,6 +86,7 @@ import kotlinx.coroutines.flow.onEach
|
||||||
import kotlinx.coroutines.flow.sample
|
import kotlinx.coroutines.flow.sample
|
||||||
import logcat.LogPriority
|
import logcat.LogPriority
|
||||||
import nucleus.factory.RequiresPresenter
|
import nucleus.factory.RequiresPresenter
|
||||||
|
import uy.kohesive.injekt.injectLazy
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
|
|
||||||
|
@ -112,6 +114,8 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||||
const val SHARED_ELEMENT_NAME = "reader_shared_element_root"
|
const val SHARED_ELEMENT_NAME = "reader_shared_element_root"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val readerPreferences: ReaderPreferences by injectLazy()
|
||||||
|
|
||||||
lateinit var binding: ReaderActivityBinding
|
lateinit var binding: ReaderActivityBinding
|
||||||
|
|
||||||
val hasCutout by lazy { hasDisplayCutout() }
|
val hasCutout by lazy { hasDisplayCutout() }
|
||||||
|
@ -446,7 +450,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||||
presenter.setMangaReadingMode(newReadingMode.flagValue)
|
presenter.setMangaReadingMode(newReadingMode.flagValue)
|
||||||
|
|
||||||
menuToggleToast?.cancel()
|
menuToggleToast?.cancel()
|
||||||
if (!preferences.showReadingMode().get()) {
|
if (!readerPreferences.showReadingMode().get()) {
|
||||||
menuToggleToast = toast(newReadingMode.stringRes)
|
menuToggleToast = toast(newReadingMode.stringRes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,9 +466,9 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
val isPagerType = ReadingModeType.isPagerType(presenter.getMangaReadingMode())
|
val isPagerType = ReadingModeType.isPagerType(presenter.getMangaReadingMode())
|
||||||
val enabled = if (isPagerType) {
|
val enabled = if (isPagerType) {
|
||||||
preferences.cropBorders().toggle()
|
readerPreferences.cropBorders().toggle()
|
||||||
} else {
|
} else {
|
||||||
preferences.cropBordersWebtoon().toggle()
|
readerPreferences.cropBordersWebtoon().toggle()
|
||||||
}
|
}
|
||||||
|
|
||||||
menuToggleToast?.cancel()
|
menuToggleToast?.cancel()
|
||||||
|
@ -478,7 +482,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateCropBordersShortcut()
|
updateCropBordersShortcut()
|
||||||
listOf(preferences.cropBorders(), preferences.cropBordersWebtoon())
|
listOf(readerPreferences.cropBorders(), readerPreferences.cropBordersWebtoon())
|
||||||
.forEach { pref ->
|
.forEach { pref ->
|
||||||
pref.changes()
|
pref.changes()
|
||||||
.onEach { updateCropBordersShortcut() }
|
.onEach { updateCropBordersShortcut() }
|
||||||
|
@ -493,7 +497,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||||
popupMenu(
|
popupMenu(
|
||||||
items = OrientationType.values().map { it.flagValue to it.stringRes },
|
items = OrientationType.values().map { it.flagValue to it.stringRes },
|
||||||
selectedItemId = presenter.manga?.orientationType
|
selectedItemId = presenter.manga?.orientationType
|
||||||
?: preferences.defaultOrientationType().get(),
|
?: readerPreferences.defaultOrientationType().get(),
|
||||||
) {
|
) {
|
||||||
val newOrientation = OrientationType.fromPreference(itemId)
|
val newOrientation = OrientationType.fromPreference(itemId)
|
||||||
|
|
||||||
|
@ -530,9 +534,9 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||||
private fun updateCropBordersShortcut() {
|
private fun updateCropBordersShortcut() {
|
||||||
val isPagerType = ReadingModeType.isPagerType(presenter.getMangaReadingMode())
|
val isPagerType = ReadingModeType.isPagerType(presenter.getMangaReadingMode())
|
||||||
val enabled = if (isPagerType) {
|
val enabled = if (isPagerType) {
|
||||||
preferences.cropBorders().get()
|
readerPreferences.cropBorders().get()
|
||||||
} else {
|
} else {
|
||||||
preferences.cropBordersWebtoon().get()
|
readerPreferences.cropBordersWebtoon().get()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.actionCropBorders.setImageResource(
|
binding.actionCropBorders.setImageResource(
|
||||||
|
@ -572,11 +576,11 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||||
binding.readerMenuBottom.startAnimation(bottomAnimation)
|
binding.readerMenuBottom.startAnimation(bottomAnimation)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preferences.showPageNumber().get()) {
|
if (readerPreferences.showPageNumber().get()) {
|
||||||
config?.setPageNumberVisibility(false)
|
config?.setPageNumberVisibility(false)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (preferences.fullscreen().get()) {
|
if (readerPreferences.fullscreen().get()) {
|
||||||
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
|
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
|
||||||
windowInsetsController.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
windowInsetsController.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||||
}
|
}
|
||||||
|
@ -598,7 +602,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||||
binding.readerMenuBottom.startAnimation(bottomAnimation)
|
binding.readerMenuBottom.startAnimation(bottomAnimation)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preferences.showPageNumber().get()) {
|
if (readerPreferences.showPageNumber().get()) {
|
||||||
config?.setPageNumberVisibility(true)
|
config?.setPageNumberVisibility(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -632,10 +636,10 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||||
binding.viewerContainer.removeAllViews()
|
binding.viewerContainer.removeAllViews()
|
||||||
}
|
}
|
||||||
viewer = newViewer
|
viewer = newViewer
|
||||||
updateViewerInset(preferences.fullscreen().get())
|
updateViewerInset(readerPreferences.fullscreen().get())
|
||||||
binding.viewerContainer.addView(newViewer.getView())
|
binding.viewerContainer.addView(newViewer.getView())
|
||||||
|
|
||||||
if (preferences.showReadingMode().get()) {
|
if (readerPreferences.showReadingMode().get()) {
|
||||||
showReadingModeToast(presenter.getMangaReadingMode())
|
showReadingModeToast(presenter.getMangaReadingMode())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -949,10 +953,10 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||||
* Initializes the reader subscriptions.
|
* Initializes the reader subscriptions.
|
||||||
*/
|
*/
|
||||||
init {
|
init {
|
||||||
preferences.readerTheme().changes()
|
readerPreferences.readerTheme().changes()
|
||||||
.onEach {
|
.onEach { theme ->
|
||||||
binding.readerContainer.setBackgroundResource(
|
binding.readerContainer.setBackgroundResource(
|
||||||
when (preferences.readerTheme().get()) {
|
when (theme) {
|
||||||
0 -> android.R.color.white
|
0 -> android.R.color.white
|
||||||
2 -> R.color.reader_background_dark
|
2 -> R.color.reader_background_dark
|
||||||
3 -> automaticBackgroundColor()
|
3 -> automaticBackgroundColor()
|
||||||
|
@ -962,41 +966,41 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||||
}
|
}
|
||||||
.launchIn(lifecycleScope)
|
.launchIn(lifecycleScope)
|
||||||
|
|
||||||
preferences.showPageNumber().changes()
|
readerPreferences.showPageNumber().changes()
|
||||||
.onEach { setPageNumberVisibility(it) }
|
.onEach { setPageNumberVisibility(it) }
|
||||||
.launchIn(lifecycleScope)
|
.launchIn(lifecycleScope)
|
||||||
|
|
||||||
preferences.trueColor().changes()
|
readerPreferences.trueColor().changes()
|
||||||
.onEach { setTrueColor(it) }
|
.onEach { setTrueColor(it) }
|
||||||
.launchIn(lifecycleScope)
|
.launchIn(lifecycleScope)
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
preferences.cutoutShort().changes()
|
readerPreferences.cutoutShort().changes()
|
||||||
.onEach { setCutoutShort(it) }
|
.onEach { setCutoutShort(it) }
|
||||||
.launchIn(lifecycleScope)
|
.launchIn(lifecycleScope)
|
||||||
}
|
}
|
||||||
|
|
||||||
preferences.keepScreenOn().changes()
|
readerPreferences.keepScreenOn().changes()
|
||||||
.onEach { setKeepScreenOn(it) }
|
.onEach { setKeepScreenOn(it) }
|
||||||
.launchIn(lifecycleScope)
|
.launchIn(lifecycleScope)
|
||||||
|
|
||||||
preferences.customBrightness().changes()
|
readerPreferences.customBrightness().changes()
|
||||||
.onEach { setCustomBrightness(it) }
|
.onEach { setCustomBrightness(it) }
|
||||||
.launchIn(lifecycleScope)
|
.launchIn(lifecycleScope)
|
||||||
|
|
||||||
preferences.colorFilter().changes()
|
readerPreferences.colorFilter().changes()
|
||||||
.onEach { setColorFilter(it) }
|
.onEach { setColorFilter(it) }
|
||||||
.launchIn(lifecycleScope)
|
.launchIn(lifecycleScope)
|
||||||
|
|
||||||
preferences.colorFilterMode().changes()
|
readerPreferences.colorFilterMode().changes()
|
||||||
.onEach { setColorFilter(preferences.colorFilter().get()) }
|
.onEach { setColorFilter(readerPreferences.colorFilter().get()) }
|
||||||
.launchIn(lifecycleScope)
|
.launchIn(lifecycleScope)
|
||||||
|
|
||||||
merge(preferences.grayscale().changes(), preferences.invertedColors().changes())
|
merge(readerPreferences.grayscale().changes(), readerPreferences.invertedColors().changes())
|
||||||
.onEach { setLayerPaint(preferences.grayscale().get(), preferences.invertedColors().get()) }
|
.onEach { setLayerPaint(readerPreferences.grayscale().get(), readerPreferences.invertedColors().get()) }
|
||||||
.launchIn(lifecycleScope)
|
.launchIn(lifecycleScope)
|
||||||
|
|
||||||
preferences.fullscreen().changes()
|
readerPreferences.fullscreen().changes()
|
||||||
.onEach {
|
.onEach {
|
||||||
WindowCompat.setDecorFitsSystemWindows(window, !it)
|
WindowCompat.setDecorFitsSystemWindows(window, !it)
|
||||||
updateViewerInset(it)
|
updateViewerInset(it)
|
||||||
|
@ -1060,7 +1064,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||||
*/
|
*/
|
||||||
private fun setCustomBrightness(enabled: Boolean) {
|
private fun setCustomBrightness(enabled: Boolean) {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
preferences.customBrightnessValue().changes()
|
readerPreferences.customBrightnessValue().changes()
|
||||||
.sample(100)
|
.sample(100)
|
||||||
.onEach { setCustomBrightnessValue(it) }
|
.onEach { setCustomBrightnessValue(it) }
|
||||||
.launchIn(lifecycleScope)
|
.launchIn(lifecycleScope)
|
||||||
|
@ -1074,7 +1078,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||||
*/
|
*/
|
||||||
private fun setColorFilter(enabled: Boolean) {
|
private fun setColorFilter(enabled: Boolean) {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
preferences.colorFilterValue().changes()
|
readerPreferences.colorFilterValue().changes()
|
||||||
.sample(100)
|
.sample(100)
|
||||||
.onEach { setColorFilterValue(it) }
|
.onEach { setColorFilterValue(it) }
|
||||||
.launchIn(lifecycleScope)
|
.launchIn(lifecycleScope)
|
||||||
|
@ -1118,7 +1122,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||||
*/
|
*/
|
||||||
private fun setColorFilterValue(value: Int) {
|
private fun setColorFilterValue(value: Int) {
|
||||||
binding.colorOverlay.isVisible = true
|
binding.colorOverlay.isVisible = true
|
||||||
binding.colorOverlay.setFilterColor(value, preferences.colorFilterMode().get())
|
binding.colorOverlay.setFilterColor(value, readerPreferences.colorFilterMode().get())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setLayerPaint(grayscale: Boolean, invertedColors: Boolean) {
|
private fun setLayerPaint(grayscale: Boolean, invertedColors: Boolean) {
|
||||||
|
|
|
@ -42,6 +42,7 @@ import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.StencilPage
|
import eu.kanade.tachiyomi.ui.reader.model.StencilPage
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
||||||
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
||||||
import eu.kanade.tachiyomi.util.chapter.getChapterSort
|
import eu.kanade.tachiyomi.util.chapter.getChapterSort
|
||||||
import eu.kanade.tachiyomi.util.editCover
|
import eu.kanade.tachiyomi.util.editCover
|
||||||
|
@ -78,6 +79,7 @@ class ReaderPresenter(
|
||||||
private val sourceManager: SourceManager = Injekt.get(),
|
private val sourceManager: SourceManager = Injekt.get(),
|
||||||
private val downloadManager: DownloadManager = Injekt.get(),
|
private val downloadManager: DownloadManager = Injekt.get(),
|
||||||
private val preferences: PreferencesHelper = Injekt.get(),
|
private val preferences: PreferencesHelper = Injekt.get(),
|
||||||
|
private val readerPreferences: ReaderPreferences = Injekt.get(),
|
||||||
private val delayedTrackingStore: DelayedTrackingStore = Injekt.get(),
|
private val delayedTrackingStore: DelayedTrackingStore = Injekt.get(),
|
||||||
private val getManga: GetManga = Injekt.get(),
|
private val getManga: GetManga = Injekt.get(),
|
||||||
private val getChapterByMangaId: GetChapterByMangaId = Injekt.get(),
|
private val getChapterByMangaId: GetChapterByMangaId = Injekt.get(),
|
||||||
|
@ -140,11 +142,11 @@ class ReaderPresenter(
|
||||||
?: error("Requested chapter of id $chapterId not found in chapter list")
|
?: error("Requested chapter of id $chapterId not found in chapter list")
|
||||||
|
|
||||||
val chaptersForReader = when {
|
val chaptersForReader = when {
|
||||||
(preferences.skipRead().get() || preferences.skipFiltered().get()) -> {
|
(readerPreferences.skipRead().get() || readerPreferences.skipFiltered().get()) -> {
|
||||||
val filteredChapters = chapters.filterNot {
|
val filteredChapters = chapters.filterNot {
|
||||||
when {
|
when {
|
||||||
preferences.skipRead().get() && it.read -> true
|
readerPreferences.skipRead().get() && it.read -> true
|
||||||
preferences.skipFiltered().get() -> {
|
readerPreferences.skipFiltered().get() -> {
|
||||||
(manga.readFilter == DomainManga.CHAPTER_SHOW_READ.toInt() && !it.read) ||
|
(manga.readFilter == DomainManga.CHAPTER_SHOW_READ.toInt() && !it.read) ||
|
||||||
(manga.readFilter == DomainManga.CHAPTER_SHOW_UNREAD.toInt() && it.read) ||
|
(manga.readFilter == DomainManga.CHAPTER_SHOW_UNREAD.toInt() && it.read) ||
|
||||||
(manga.downloadedFilter == DomainManga.CHAPTER_SHOW_DOWNLOADED.toInt() && !downloadManager.isChapterDownloaded(it.name, it.scanlator, manga.title, manga.source)) ||
|
(manga.downloadedFilter == DomainManga.CHAPTER_SHOW_DOWNLOADED.toInt() && !downloadManager.isChapterDownloaded(it.name, it.scanlator, manga.title, manga.source)) ||
|
||||||
|
@ -619,7 +621,7 @@ class ReaderPresenter(
|
||||||
* Returns the viewer position used by this manga or the default one.
|
* Returns the viewer position used by this manga or the default one.
|
||||||
*/
|
*/
|
||||||
fun getMangaReadingMode(resolveDefault: Boolean = true): Int {
|
fun getMangaReadingMode(resolveDefault: Boolean = true): Int {
|
||||||
val default = preferences.defaultReadingMode().get()
|
val default = readerPreferences.defaultReadingMode().get()
|
||||||
val readingMode = ReadingModeType.fromPreference(manga?.readingModeType)
|
val readingMode = ReadingModeType.fromPreference(manga?.readingModeType)
|
||||||
return when {
|
return when {
|
||||||
resolveDefault && readingMode == ReadingModeType.DEFAULT -> default
|
resolveDefault && readingMode == ReadingModeType.DEFAULT -> default
|
||||||
|
@ -656,7 +658,7 @@ class ReaderPresenter(
|
||||||
* Returns the orientation type used by this manga or the default one.
|
* Returns the orientation type used by this manga or the default one.
|
||||||
*/
|
*/
|
||||||
fun getMangaOrientationType(resolveDefault: Boolean = true): Int {
|
fun getMangaOrientationType(resolveDefault: Boolean = true): Int {
|
||||||
val default = preferences.defaultOrientationType().get()
|
val default = readerPreferences.defaultOrientationType().get()
|
||||||
val orientation = OrientationType.fromPreference(manga?.orientationType)
|
val orientation = OrientationType.fromPreference(manga?.orientationType)
|
||||||
return when {
|
return when {
|
||||||
resolveDefault && orientation == OrientationType.DEFAULT -> default
|
resolveDefault && orientation == OrientationType.DEFAULT -> default
|
||||||
|
@ -714,7 +716,7 @@ class ReaderPresenter(
|
||||||
val filename = generateFilename(manga, page)
|
val filename = generateFilename(manga, page)
|
||||||
|
|
||||||
// Pictures directory.
|
// Pictures directory.
|
||||||
val relativePath = if (preferences.folderPerManga().get()) DiskUtil.buildValidFilename(manga.title) else ""
|
val relativePath = if (readerPreferences.folderPerManga().get()) DiskUtil.buildValidFilename(manga.title) else ""
|
||||||
|
|
||||||
// Copy file in background.
|
// Copy file in background.
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import androidx.core.graphics.green
|
||||||
import androidx.core.graphics.red
|
import androidx.core.graphics.red
|
||||||
import androidx.core.widget.NestedScrollView
|
import androidx.core.widget.NestedScrollView
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.core.preference.getAndSet
|
||||||
import eu.kanade.tachiyomi.databinding.ReaderColorFilterSettingsBinding
|
import eu.kanade.tachiyomi.databinding.ReaderColorFilterSettingsBinding
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||||
import eu.kanade.tachiyomi.util.preference.bindToPreference
|
import eu.kanade.tachiyomi.util.preference.bindToPreference
|
||||||
|
@ -25,28 +25,28 @@ import uy.kohesive.injekt.injectLazy
|
||||||
class ReaderColorFilterSettings @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
class ReaderColorFilterSettings @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||||
NestedScrollView(context, attrs) {
|
NestedScrollView(context, attrs) {
|
||||||
|
|
||||||
private val preferences: PreferencesHelper by injectLazy()
|
private val readerPreferences: ReaderPreferences by injectLazy()
|
||||||
|
|
||||||
private val binding = ReaderColorFilterSettingsBinding.inflate(LayoutInflater.from(context), this, false)
|
private val binding = ReaderColorFilterSettingsBinding.inflate(LayoutInflater.from(context), this, false)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
addView(binding.root)
|
addView(binding.root)
|
||||||
|
|
||||||
preferences.colorFilter().changes()
|
readerPreferences.colorFilter().changes()
|
||||||
.onEach { setColorFilter(it) }
|
.onEach { setColorFilter(it) }
|
||||||
.launchIn((context as ReaderActivity).lifecycleScope)
|
.launchIn((context as ReaderActivity).lifecycleScope)
|
||||||
|
|
||||||
preferences.colorFilterMode().changes()
|
readerPreferences.colorFilterMode().changes()
|
||||||
.onEach { setColorFilter(preferences.colorFilter().get()) }
|
.onEach { setColorFilter(readerPreferences.colorFilter().get()) }
|
||||||
.launchIn(context.lifecycleScope)
|
.launchIn(context.lifecycleScope)
|
||||||
|
|
||||||
preferences.customBrightness().changes()
|
readerPreferences.customBrightness().changes()
|
||||||
.onEach { setCustomBrightness(it) }
|
.onEach { setCustomBrightness(it) }
|
||||||
.launchIn(context.lifecycleScope)
|
.launchIn(context.lifecycleScope)
|
||||||
|
|
||||||
// Get color and update values
|
// Get color and update values
|
||||||
val color = preferences.colorFilterValue().get()
|
val color = readerPreferences.colorFilterValue().get()
|
||||||
val brightness = preferences.customBrightnessValue().get()
|
val brightness = readerPreferences.customBrightnessValue().get()
|
||||||
|
|
||||||
val argb = setValues(color)
|
val argb = setValues(color)
|
||||||
|
|
||||||
|
@ -61,11 +61,11 @@ class ReaderColorFilterSettings @JvmOverloads constructor(context: Context, attr
|
||||||
binding.sliderColorFilterBlue.value = argb[3].toFloat()
|
binding.sliderColorFilterBlue.value = argb[3].toFloat()
|
||||||
|
|
||||||
// Set listeners
|
// Set listeners
|
||||||
binding.switchColorFilter.bindToPreference(preferences.colorFilter())
|
binding.switchColorFilter.bindToPreference(readerPreferences.colorFilter())
|
||||||
binding.customBrightness.bindToPreference(preferences.customBrightness())
|
binding.customBrightness.bindToPreference(readerPreferences.customBrightness())
|
||||||
binding.colorFilterMode.bindToPreference(preferences.colorFilterMode())
|
binding.colorFilterMode.bindToPreference(readerPreferences.colorFilterMode())
|
||||||
binding.grayscale.bindToPreference(preferences.grayscale())
|
binding.grayscale.bindToPreference(readerPreferences.grayscale())
|
||||||
binding.invertedColors.bindToPreference(preferences.invertedColors())
|
binding.invertedColors.bindToPreference(readerPreferences.invertedColors())
|
||||||
|
|
||||||
binding.sliderColorFilterAlpha.addOnChangeListener { _, value, fromUser ->
|
binding.sliderColorFilterAlpha.addOnChangeListener { _, value, fromUser ->
|
||||||
if (fromUser) {
|
if (fromUser) {
|
||||||
|
@ -90,7 +90,7 @@ class ReaderColorFilterSettings @JvmOverloads constructor(context: Context, attr
|
||||||
|
|
||||||
binding.sliderBrightness.addOnChangeListener { _, value, fromUser ->
|
binding.sliderBrightness.addOnChangeListener { _, value, fromUser ->
|
||||||
if (fromUser) {
|
if (fromUser) {
|
||||||
preferences.customBrightnessValue().set(value.toInt())
|
readerPreferences.customBrightnessValue().set(value.toInt())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ class ReaderColorFilterSettings @JvmOverloads constructor(context: Context, attr
|
||||||
*/
|
*/
|
||||||
private fun setCustomBrightness(enabled: Boolean) {
|
private fun setCustomBrightness(enabled: Boolean) {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
preferences.customBrightnessValue().changes()
|
readerPreferences.customBrightnessValue().changes()
|
||||||
.sample(100)
|
.sample(100)
|
||||||
.onEach { setCustomBrightnessValue(it) }
|
.onEach { setCustomBrightnessValue(it) }
|
||||||
.launchIn((context as ReaderActivity).lifecycleScope)
|
.launchIn((context as ReaderActivity).lifecycleScope)
|
||||||
|
@ -167,7 +167,7 @@ class ReaderColorFilterSettings @JvmOverloads constructor(context: Context, attr
|
||||||
*/
|
*/
|
||||||
private fun setColorFilter(enabled: Boolean) {
|
private fun setColorFilter(enabled: Boolean) {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
preferences.colorFilterValue().changes()
|
readerPreferences.colorFilterValue().changes()
|
||||||
.sample(100)
|
.sample(100)
|
||||||
.onEach { setColorFilterValue(it) }
|
.onEach { setColorFilterValue(it) }
|
||||||
.launchIn((context as ReaderActivity).lifecycleScope)
|
.launchIn((context as ReaderActivity).lifecycleScope)
|
||||||
|
@ -190,9 +190,9 @@ class ReaderColorFilterSettings @JvmOverloads constructor(context: Context, attr
|
||||||
* @param bitShift amounts of bits that gets shifted to receive value
|
* @param bitShift amounts of bits that gets shifted to receive value
|
||||||
*/
|
*/
|
||||||
private fun setColorValue(color: Int, mask: Long, bitShift: Int) {
|
private fun setColorValue(color: Int, mask: Long, bitShift: Int) {
|
||||||
val currentColor = preferences.colorFilterValue().get()
|
readerPreferences.colorFilterValue().getAndSet { currentColor ->
|
||||||
val updatedColor = (color shl bitShift) or (currentColor and mask.inv().toInt())
|
(color shl bitShift) or (currentColor and mask.inv().toInt())
|
||||||
preferences.colorFilterValue().set(updatedColor)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ import androidx.core.view.isVisible
|
||||||
import androidx.core.widget.NestedScrollView
|
import androidx.core.widget.NestedScrollView
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|
||||||
import eu.kanade.tachiyomi.databinding.ReaderGeneralSettingsBinding
|
import eu.kanade.tachiyomi.databinding.ReaderGeneralSettingsBinding
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||||
import eu.kanade.tachiyomi.util.preference.asHotFlow
|
import eu.kanade.tachiyomi.util.preference.asHotFlow
|
||||||
|
@ -21,7 +20,7 @@ import uy.kohesive.injekt.injectLazy
|
||||||
class ReaderGeneralSettings @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
class ReaderGeneralSettings @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||||
NestedScrollView(context, attrs) {
|
NestedScrollView(context, attrs) {
|
||||||
|
|
||||||
private val preferences: PreferencesHelper by injectLazy()
|
private val readerPreferences: ReaderPreferences by injectLazy()
|
||||||
|
|
||||||
private val binding = ReaderGeneralSettingsBinding.inflate(LayoutInflater.from(context), this, false)
|
private val binding = ReaderGeneralSettingsBinding.inflate(LayoutInflater.from(context), this, false)
|
||||||
|
|
||||||
|
@ -35,20 +34,20 @@ class ReaderGeneralSettings @JvmOverloads constructor(context: Context, attrs: A
|
||||||
* Init general reader preferences.
|
* Init general reader preferences.
|
||||||
*/
|
*/
|
||||||
private fun initGeneralPreferences() {
|
private fun initGeneralPreferences() {
|
||||||
binding.backgroundColor.bindToIntPreference(preferences.readerTheme(), R.array.reader_themes_values)
|
binding.backgroundColor.bindToIntPreference(readerPreferences.readerTheme(), R.array.reader_themes_values)
|
||||||
binding.showPageNumber.bindToPreference(preferences.showPageNumber())
|
binding.showPageNumber.bindToPreference(readerPreferences.showPageNumber())
|
||||||
binding.fullscreen.bindToPreference(preferences.fullscreen())
|
binding.fullscreen.bindToPreference(readerPreferences.fullscreen())
|
||||||
preferences.fullscreen()
|
readerPreferences.fullscreen()
|
||||||
.asHotFlow {
|
.asHotFlow {
|
||||||
// If the preference is explicitly disabled, that means the setting was configured since there is a cutout
|
// If the preference is explicitly disabled, that means the setting was configured since there is a cutout
|
||||||
binding.cutoutShort.isVisible = it && ((context as ReaderActivity).hasCutout || !preferences.cutoutShort().get())
|
binding.cutoutShort.isVisible = it && ((context as ReaderActivity).hasCutout || !readerPreferences.cutoutShort().get())
|
||||||
binding.cutoutShort.bindToPreference(preferences.cutoutShort())
|
binding.cutoutShort.bindToPreference(readerPreferences.cutoutShort())
|
||||||
}
|
}
|
||||||
.launchIn((context as ReaderActivity).lifecycleScope)
|
.launchIn((context as ReaderActivity).lifecycleScope)
|
||||||
|
|
||||||
binding.keepscreen.bindToPreference(preferences.keepScreenOn())
|
binding.keepscreen.bindToPreference(readerPreferences.keepScreenOn())
|
||||||
binding.longTap.bindToPreference(preferences.readWithLongTap())
|
binding.longTap.bindToPreference(readerPreferences.readWithLongTap())
|
||||||
binding.alwaysShowChapterTransition.bindToPreference(preferences.alwaysShowChapterTransition())
|
binding.alwaysShowChapterTransition.bindToPreference(readerPreferences.alwaysShowChapterTransition())
|
||||||
binding.pageTransitions.bindToPreference(preferences.pageTransitions())
|
binding.pageTransitions.bindToPreference(readerPreferences.pageTransitions())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,114 @@
|
||||||
|
package eu.kanade.tachiyomi.ui.reader.setting
|
||||||
|
|
||||||
|
import eu.kanade.tachiyomi.core.preference.PreferenceStore
|
||||||
|
import eu.kanade.tachiyomi.core.preference.getEnum
|
||||||
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
||||||
|
|
||||||
|
class ReaderPreferences(
|
||||||
|
private val preferenceStore: PreferenceStore,
|
||||||
|
) {
|
||||||
|
|
||||||
|
// region General
|
||||||
|
|
||||||
|
fun pageTransitions() = preferenceStore.getBoolean("pref_enable_transitions_key", true)
|
||||||
|
|
||||||
|
fun doubleTapAnimSpeed() = preferenceStore.getInt("pref_double_tap_anim_speed", 500)
|
||||||
|
|
||||||
|
fun showPageNumber() = preferenceStore.getBoolean("pref_show_page_number_key", true)
|
||||||
|
|
||||||
|
fun showReadingMode() = preferenceStore.getBoolean("pref_show_reading_mode", true)
|
||||||
|
|
||||||
|
fun trueColor() = preferenceStore.getBoolean("pref_true_color_key", false)
|
||||||
|
|
||||||
|
fun fullscreen() = preferenceStore.getBoolean("fullscreen", true)
|
||||||
|
|
||||||
|
fun cutoutShort() = preferenceStore.getBoolean("cutout_short", true)
|
||||||
|
|
||||||
|
fun keepScreenOn() = preferenceStore.getBoolean("pref_keep_screen_on_key", true)
|
||||||
|
|
||||||
|
fun defaultReadingMode() = preferenceStore.getInt("pref_default_reading_mode_key", ReadingModeType.RIGHT_TO_LEFT.flagValue)
|
||||||
|
|
||||||
|
fun defaultOrientationType() = preferenceStore.getInt("pref_default_orientation_type_key", OrientationType.FREE.flagValue)
|
||||||
|
|
||||||
|
fun longStripSplitWebtoon() = preferenceStore.getBoolean("pref_long_strip_split_webtoon", true)
|
||||||
|
|
||||||
|
fun imageScaleType() = preferenceStore.getInt("pref_image_scale_type_key", 1)
|
||||||
|
|
||||||
|
fun zoomStart() = preferenceStore.getInt("pref_zoom_start_key", 1)
|
||||||
|
|
||||||
|
fun readerTheme() = preferenceStore.getInt("pref_reader_theme_key", 1)
|
||||||
|
|
||||||
|
fun alwaysShowChapterTransition() = preferenceStore.getBoolean("always_show_chapter_transition", true)
|
||||||
|
|
||||||
|
fun cropBorders() = preferenceStore.getBoolean("crop_borders", false)
|
||||||
|
|
||||||
|
fun navigateToPan() = preferenceStore.getBoolean("navigate_pan", true)
|
||||||
|
|
||||||
|
fun landscapeZoom() = preferenceStore.getBoolean("landscape_zoom", true)
|
||||||
|
|
||||||
|
fun cropBordersWebtoon() = preferenceStore.getBoolean("crop_borders_webtoon", false)
|
||||||
|
|
||||||
|
fun webtoonSidePadding() = preferenceStore.getInt("webtoon_side_padding", 0)
|
||||||
|
|
||||||
|
fun readerHideThreshold() = preferenceStore.getEnum("reader_hide_threshold", PreferenceValues.ReaderHideThreshold.LOW)
|
||||||
|
|
||||||
|
fun folderPerManga() = preferenceStore.getBoolean("create_folder_per_manga", false)
|
||||||
|
|
||||||
|
fun skipRead() = preferenceStore.getBoolean("skip_read", false)
|
||||||
|
|
||||||
|
fun skipFiltered() = preferenceStore.getBoolean("skip_filtered", true)
|
||||||
|
|
||||||
|
// endregion
|
||||||
|
|
||||||
|
// region Split two page spread
|
||||||
|
|
||||||
|
fun dualPageSplitPaged() = preferenceStore.getBoolean("pref_dual_page_split", false)
|
||||||
|
|
||||||
|
fun dualPageInvertPaged() = preferenceStore.getBoolean("pref_dual_page_invert", false)
|
||||||
|
|
||||||
|
fun dualPageSplitWebtoon() = preferenceStore.getBoolean("pref_dual_page_split_webtoon", false)
|
||||||
|
|
||||||
|
fun dualPageInvertWebtoon() = preferenceStore.getBoolean("pref_dual_page_invert_webtoon", false)
|
||||||
|
|
||||||
|
// endregion
|
||||||
|
|
||||||
|
// region Color filter
|
||||||
|
|
||||||
|
fun customBrightness() = preferenceStore.getBoolean("pref_custom_brightness_key", false)
|
||||||
|
|
||||||
|
fun customBrightnessValue() = preferenceStore.getInt("custom_brightness_value", 0)
|
||||||
|
|
||||||
|
fun colorFilter() = preferenceStore.getBoolean("pref_color_filter_key", false)
|
||||||
|
|
||||||
|
fun colorFilterValue() = preferenceStore.getInt("color_filter_value", 0)
|
||||||
|
|
||||||
|
fun colorFilterMode() = preferenceStore.getInt("color_filter_mode", 0)
|
||||||
|
|
||||||
|
fun grayscale() = preferenceStore.getBoolean("pref_grayscale", false)
|
||||||
|
|
||||||
|
fun invertedColors() = preferenceStore.getBoolean("pref_inverted_colors", false)
|
||||||
|
|
||||||
|
// endregion
|
||||||
|
|
||||||
|
// region Controls
|
||||||
|
|
||||||
|
fun readWithLongTap() = preferenceStore.getBoolean("reader_long_tap", true)
|
||||||
|
|
||||||
|
fun readWithVolumeKeys() = preferenceStore.getBoolean("reader_volume_keys", false)
|
||||||
|
|
||||||
|
fun readWithVolumeKeysInverted() = preferenceStore.getBoolean("reader_volume_keys_inverted", false)
|
||||||
|
|
||||||
|
fun navigationModePager() = preferenceStore.getInt("reader_navigation_mode_pager", 0)
|
||||||
|
|
||||||
|
fun navigationModeWebtoon() = preferenceStore.getInt("reader_navigation_mode_webtoon", 0)
|
||||||
|
|
||||||
|
fun pagerNavInverted() = preferenceStore.getEnum("reader_tapping_inverted", PreferenceValues.TappingInvertMode.NONE)
|
||||||
|
|
||||||
|
fun webtoonNavInverted() = preferenceStore.getEnum("reader_tapping_inverted_webtoon", PreferenceValues.TappingInvertMode.NONE)
|
||||||
|
|
||||||
|
fun showNavigationOverlayNewUser() = preferenceStore.getBoolean("reader_navigation_overlay_new_user", true)
|
||||||
|
|
||||||
|
fun showNavigationOverlayOnStart() = preferenceStore.getBoolean("reader_navigation_overlay_on_start", false)
|
||||||
|
|
||||||
|
// endregion
|
||||||
|
}
|
|
@ -7,7 +7,6 @@ import androidx.core.view.isVisible
|
||||||
import androidx.core.widget.NestedScrollView
|
import androidx.core.widget.NestedScrollView
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|
||||||
import eu.kanade.tachiyomi.databinding.ReaderReadingModeSettingsBinding
|
import eu.kanade.tachiyomi.databinding.ReaderReadingModeSettingsBinding
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerViewer
|
import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerViewer
|
||||||
|
@ -23,7 +22,7 @@ import uy.kohesive.injekt.injectLazy
|
||||||
class ReaderReadingModeSettings @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
class ReaderReadingModeSettings @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||||
NestedScrollView(context, attrs) {
|
NestedScrollView(context, attrs) {
|
||||||
|
|
||||||
private val preferences: PreferencesHelper by injectLazy()
|
private val readerPreferences: ReaderPreferences by injectLazy()
|
||||||
|
|
||||||
private val binding = ReaderReadingModeSettingsBinding.inflate(LayoutInflater.from(context), this, false)
|
private val binding = ReaderReadingModeSettingsBinding.inflate(LayoutInflater.from(context), this, false)
|
||||||
|
|
||||||
|
@ -69,29 +68,29 @@ class ReaderReadingModeSettings @JvmOverloads constructor(context: Context, attr
|
||||||
binding.webtoonPrefsGroup.root.isVisible = false
|
binding.webtoonPrefsGroup.root.isVisible = false
|
||||||
binding.pagerPrefsGroup.root.isVisible = true
|
binding.pagerPrefsGroup.root.isVisible = true
|
||||||
|
|
||||||
binding.pagerPrefsGroup.tappingInverted.bindToPreference(preferences.pagerNavInverted())
|
binding.pagerPrefsGroup.tappingInverted.bindToPreference(readerPreferences.pagerNavInverted())
|
||||||
|
|
||||||
binding.pagerPrefsGroup.pagerNav.bindToPreference(preferences.navigationModePager())
|
binding.pagerPrefsGroup.pagerNav.bindToPreference(readerPreferences.navigationModePager())
|
||||||
preferences.navigationModePager()
|
readerPreferences.navigationModePager()
|
||||||
.asHotFlow { binding.pagerPrefsGroup.tappingInverted.isVisible = it != 5 }
|
.asHotFlow { binding.pagerPrefsGroup.tappingInverted.isVisible = it != 5 }
|
||||||
.launchIn((context as ReaderActivity).lifecycleScope)
|
.launchIn((context as ReaderActivity).lifecycleScope)
|
||||||
// Makes so that landscape zoom gets hidden away when image scale type is not fit screen
|
// Makes so that landscape zoom gets hidden away when image scale type is not fit screen
|
||||||
binding.pagerPrefsGroup.scaleType.bindToPreference(preferences.imageScaleType(), 1)
|
binding.pagerPrefsGroup.scaleType.bindToPreference(readerPreferences.imageScaleType(), 1)
|
||||||
preferences.imageScaleType()
|
readerPreferences.imageScaleType()
|
||||||
.asHotFlow { binding.pagerPrefsGroup.landscapeZoom.isVisible = it == 1 }
|
.asHotFlow { binding.pagerPrefsGroup.landscapeZoom.isVisible = it == 1 }
|
||||||
.launchIn((context as ReaderActivity).lifecycleScope)
|
.launchIn((context as ReaderActivity).lifecycleScope)
|
||||||
binding.pagerPrefsGroup.landscapeZoom.bindToPreference(preferences.landscapeZoom())
|
binding.pagerPrefsGroup.landscapeZoom.bindToPreference(readerPreferences.landscapeZoom())
|
||||||
|
|
||||||
binding.pagerPrefsGroup.zoomStart.bindToPreference(preferences.zoomStart(), 1)
|
binding.pagerPrefsGroup.zoomStart.bindToPreference(readerPreferences.zoomStart(), 1)
|
||||||
binding.pagerPrefsGroup.cropBorders.bindToPreference(preferences.cropBorders())
|
binding.pagerPrefsGroup.cropBorders.bindToPreference(readerPreferences.cropBorders())
|
||||||
binding.pagerPrefsGroup.navigatePan.bindToPreference(preferences.navigateToPan())
|
binding.pagerPrefsGroup.navigatePan.bindToPreference(readerPreferences.navigateToPan())
|
||||||
|
|
||||||
binding.pagerPrefsGroup.dualPageSplit.bindToPreference(preferences.dualPageSplitPaged())
|
binding.pagerPrefsGroup.dualPageSplit.bindToPreference(readerPreferences.dualPageSplitPaged())
|
||||||
// Makes it so that dual page invert gets hidden away when dual page split is turned off
|
// Makes it so that dual page invert gets hidden away when dual page split is turned off
|
||||||
preferences.dualPageSplitPaged()
|
readerPreferences.dualPageSplitPaged()
|
||||||
.asHotFlow { binding.pagerPrefsGroup.dualPageInvert.isVisible = it }
|
.asHotFlow { binding.pagerPrefsGroup.dualPageInvert.isVisible = it }
|
||||||
.launchIn((context as ReaderActivity).lifecycleScope)
|
.launchIn((context as ReaderActivity).lifecycleScope)
|
||||||
binding.pagerPrefsGroup.dualPageInvert.bindToPreference(preferences.dualPageInvertPaged())
|
binding.pagerPrefsGroup.dualPageInvert.bindToPreference(readerPreferences.dualPageInvertPaged())
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -101,21 +100,21 @@ class ReaderReadingModeSettings @JvmOverloads constructor(context: Context, attr
|
||||||
binding.pagerPrefsGroup.root.isVisible = false
|
binding.pagerPrefsGroup.root.isVisible = false
|
||||||
binding.webtoonPrefsGroup.root.isVisible = true
|
binding.webtoonPrefsGroup.root.isVisible = true
|
||||||
|
|
||||||
binding.webtoonPrefsGroup.tappingInverted.bindToPreference(preferences.webtoonNavInverted())
|
binding.webtoonPrefsGroup.tappingInverted.bindToPreference(readerPreferences.webtoonNavInverted())
|
||||||
|
|
||||||
binding.webtoonPrefsGroup.webtoonNav.bindToPreference(preferences.navigationModeWebtoon())
|
binding.webtoonPrefsGroup.webtoonNav.bindToPreference(readerPreferences.navigationModeWebtoon())
|
||||||
preferences.navigationModeWebtoon()
|
readerPreferences.navigationModeWebtoon()
|
||||||
.asHotFlow { binding.webtoonPrefsGroup.tappingInverted.isVisible = it != 5 }
|
.asHotFlow { binding.webtoonPrefsGroup.tappingInverted.isVisible = it != 5 }
|
||||||
.launchIn((context as ReaderActivity).lifecycleScope)
|
.launchIn((context as ReaderActivity).lifecycleScope)
|
||||||
binding.webtoonPrefsGroup.cropBordersWebtoon.bindToPreference(preferences.cropBordersWebtoon())
|
binding.webtoonPrefsGroup.cropBordersWebtoon.bindToPreference(readerPreferences.cropBordersWebtoon())
|
||||||
binding.webtoonPrefsGroup.webtoonSidePadding.bindToIntPreference(preferences.webtoonSidePadding(), R.array.webtoon_side_padding_values)
|
binding.webtoonPrefsGroup.webtoonSidePadding.bindToIntPreference(readerPreferences.webtoonSidePadding(), R.array.webtoon_side_padding_values)
|
||||||
|
|
||||||
binding.webtoonPrefsGroup.dualPageSplit.bindToPreference(preferences.dualPageSplitWebtoon())
|
binding.webtoonPrefsGroup.dualPageSplit.bindToPreference(readerPreferences.dualPageSplitWebtoon())
|
||||||
// Makes it so that dual page invert gets hidden away when dual page split is turned off
|
// Makes it so that dual page invert gets hidden away when dual page split is turned off
|
||||||
preferences.dualPageSplitWebtoon()
|
readerPreferences.dualPageSplitWebtoon()
|
||||||
.asHotFlow { binding.webtoonPrefsGroup.dualPageInvert.isVisible = it }
|
.asHotFlow { binding.webtoonPrefsGroup.dualPageInvert.isVisible = it }
|
||||||
.launchIn((context as ReaderActivity).lifecycleScope)
|
.launchIn((context as ReaderActivity).lifecycleScope)
|
||||||
binding.webtoonPrefsGroup.dualPageInvert.bindToPreference(preferences.dualPageInvertWebtoon())
|
binding.webtoonPrefsGroup.dualPageInvert.bindToPreference(readerPreferences.dualPageInvertWebtoon())
|
||||||
binding.webtoonPrefsGroup.longStripSplit.bindToPreference(preferences.longStripSplitWebtoon())
|
binding.webtoonPrefsGroup.longStripSplit.bindToPreference(readerPreferences.longStripSplitWebtoon())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package eu.kanade.tachiyomi.ui.reader.viewer
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.core.preference.Preference
|
import eu.kanade.tachiyomi.core.preference.Preference
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues.TappingInvertMode
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues.TappingInvertMode
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
|
@ -11,7 +11,7 @@ import kotlinx.coroutines.flow.onEach
|
||||||
/**
|
/**
|
||||||
* Common configuration for all viewers.
|
* Common configuration for all viewers.
|
||||||
*/
|
*/
|
||||||
abstract class ViewerConfig(preferences: PreferencesHelper, private val scope: CoroutineScope) {
|
abstract class ViewerConfig(readerPreferences: ReaderPreferences, private val scope: CoroutineScope) {
|
||||||
|
|
||||||
var imagePropertyChangedListener: (() -> Unit)? = null
|
var imagePropertyChangedListener: (() -> Unit)? = null
|
||||||
|
|
||||||
|
@ -42,33 +42,33 @@ abstract class ViewerConfig(preferences: PreferencesHelper, private val scope: C
|
||||||
protected set
|
protected set
|
||||||
|
|
||||||
init {
|
init {
|
||||||
preferences.readWithLongTap()
|
readerPreferences.readWithLongTap()
|
||||||
.register({ longTapEnabled = it })
|
.register({ longTapEnabled = it })
|
||||||
|
|
||||||
preferences.pageTransitions()
|
readerPreferences.pageTransitions()
|
||||||
.register({ usePageTransitions = it })
|
.register({ usePageTransitions = it })
|
||||||
|
|
||||||
preferences.doubleTapAnimSpeed()
|
readerPreferences.doubleTapAnimSpeed()
|
||||||
.register({ doubleTapAnimDuration = it })
|
.register({ doubleTapAnimDuration = it })
|
||||||
|
|
||||||
preferences.readWithVolumeKeys()
|
readerPreferences.readWithVolumeKeys()
|
||||||
.register({ volumeKeysEnabled = it })
|
.register({ volumeKeysEnabled = it })
|
||||||
|
|
||||||
preferences.readWithVolumeKeysInverted()
|
readerPreferences.readWithVolumeKeysInverted()
|
||||||
.register({ volumeKeysInverted = it })
|
.register({ volumeKeysInverted = it })
|
||||||
|
|
||||||
preferences.trueColor()
|
readerPreferences.trueColor()
|
||||||
.register({ trueColor = it }, { imagePropertyChangedListener?.invoke() })
|
.register({ trueColor = it }, { imagePropertyChangedListener?.invoke() })
|
||||||
|
|
||||||
preferences.alwaysShowChapterTransition()
|
readerPreferences.alwaysShowChapterTransition()
|
||||||
.register({ alwaysShowChapterTransition = it })
|
.register({ alwaysShowChapterTransition = it })
|
||||||
|
|
||||||
forceNavigationOverlay = preferences.showNavigationOverlayNewUser().get()
|
forceNavigationOverlay = readerPreferences.showNavigationOverlayNewUser().get()
|
||||||
if (forceNavigationOverlay) {
|
if (forceNavigationOverlay) {
|
||||||
preferences.showNavigationOverlayNewUser().set(false)
|
readerPreferences.showNavigationOverlayNewUser().set(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
preferences.showNavigationOverlayOnStart()
|
readerPreferences.showNavigationOverlayOnStart()
|
||||||
.register({ navigationOverlayOnStart = it })
|
.register({ navigationOverlayOnStart = it })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.kanade.tachiyomi.ui.reader.viewer.pager
|
package eu.kanade.tachiyomi.ui.reader.viewer.pager
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.ReaderPageImageView
|
import eu.kanade.tachiyomi.ui.reader.viewer.ReaderPageImageView
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerConfig
|
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerConfig
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
||||||
|
@ -22,10 +22,10 @@ import uy.kohesive.injekt.api.get
|
||||||
class PagerConfig(
|
class PagerConfig(
|
||||||
private val viewer: PagerViewer,
|
private val viewer: PagerViewer,
|
||||||
scope: CoroutineScope,
|
scope: CoroutineScope,
|
||||||
preferences: PreferencesHelper = Injekt.get(),
|
readerPreferences: ReaderPreferences = Injekt.get(),
|
||||||
) : ViewerConfig(preferences, scope) {
|
) : ViewerConfig(readerPreferences, scope) {
|
||||||
|
|
||||||
var theme = preferences.readerTheme().get()
|
var theme = readerPreferences.readerTheme().get()
|
||||||
private set
|
private set
|
||||||
|
|
||||||
var automaticBackground = false
|
var automaticBackground = false
|
||||||
|
@ -49,7 +49,7 @@ class PagerConfig(
|
||||||
private set
|
private set
|
||||||
|
|
||||||
init {
|
init {
|
||||||
preferences.readerTheme()
|
readerPreferences.readerTheme()
|
||||||
.register(
|
.register(
|
||||||
{
|
{
|
||||||
theme = it
|
theme = it
|
||||||
|
@ -58,32 +58,32 @@ class PagerConfig(
|
||||||
{ imagePropertyChangedListener?.invoke() },
|
{ imagePropertyChangedListener?.invoke() },
|
||||||
)
|
)
|
||||||
|
|
||||||
preferences.imageScaleType()
|
readerPreferences.imageScaleType()
|
||||||
.register({ imageScaleType = it }, { imagePropertyChangedListener?.invoke() })
|
.register({ imageScaleType = it }, { imagePropertyChangedListener?.invoke() })
|
||||||
|
|
||||||
preferences.zoomStart()
|
readerPreferences.zoomStart()
|
||||||
.register({ zoomTypeFromPreference(it) }, { imagePropertyChangedListener?.invoke() })
|
.register({ zoomTypeFromPreference(it) }, { imagePropertyChangedListener?.invoke() })
|
||||||
|
|
||||||
preferences.cropBorders()
|
readerPreferences.cropBorders()
|
||||||
.register({ imageCropBorders = it }, { imagePropertyChangedListener?.invoke() })
|
.register({ imageCropBorders = it }, { imagePropertyChangedListener?.invoke() })
|
||||||
|
|
||||||
preferences.navigateToPan()
|
readerPreferences.navigateToPan()
|
||||||
.register({ navigateToPan = it })
|
.register({ navigateToPan = it })
|
||||||
|
|
||||||
preferences.landscapeZoom()
|
readerPreferences.landscapeZoom()
|
||||||
.register({ landscapeZoom = it }, { imagePropertyChangedListener?.invoke() })
|
.register({ landscapeZoom = it }, { imagePropertyChangedListener?.invoke() })
|
||||||
|
|
||||||
preferences.navigationModePager()
|
readerPreferences.navigationModePager()
|
||||||
.register({ navigationMode = it }, { updateNavigation(navigationMode) })
|
.register({ navigationMode = it }, { updateNavigation(navigationMode) })
|
||||||
|
|
||||||
preferences.pagerNavInverted()
|
readerPreferences.pagerNavInverted()
|
||||||
.register({ tappingInverted = it }, { navigator.invertMode = it })
|
.register({ tappingInverted = it }, { navigator.invertMode = it })
|
||||||
preferences.pagerNavInverted().changes()
|
readerPreferences.pagerNavInverted().changes()
|
||||||
.drop(1)
|
.drop(1)
|
||||||
.onEach { navigationModeChangedListener?.invoke() }
|
.onEach { navigationModeChangedListener?.invoke() }
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
|
|
||||||
preferences.dualPageSplitPaged()
|
readerPreferences.dualPageSplitPaged()
|
||||||
.register(
|
.register(
|
||||||
{ dualPageSplit = it },
|
{ dualPageSplit = it },
|
||||||
{
|
{
|
||||||
|
@ -92,7 +92,7 @@ class PagerConfig(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
preferences.dualPageInvertPaged()
|
readerPreferences.dualPageInvertPaged()
|
||||||
.register({ dualPageInvert = it }, { imagePropertyChangedListener?.invoke() })
|
.register({ dualPageInvert = it }, { imagePropertyChangedListener?.invoke() })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.kanade.tachiyomi.ui.reader.viewer.webtoon
|
package eu.kanade.tachiyomi.ui.reader.viewer.webtoon
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerConfig
|
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerConfig
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.navigation.DisabledNavigation
|
import eu.kanade.tachiyomi.ui.reader.viewer.navigation.DisabledNavigation
|
||||||
|
@ -21,8 +21,8 @@ import uy.kohesive.injekt.api.get
|
||||||
*/
|
*/
|
||||||
class WebtoonConfig(
|
class WebtoonConfig(
|
||||||
scope: CoroutineScope,
|
scope: CoroutineScope,
|
||||||
preferences: PreferencesHelper = Injekt.get(),
|
readerPreferences: ReaderPreferences = Injekt.get(),
|
||||||
) : ViewerConfig(preferences, scope) {
|
) : ViewerConfig(readerPreferences, scope) {
|
||||||
|
|
||||||
var themeChangedListener: (() -> Unit)? = null
|
var themeChangedListener: (() -> Unit)? = null
|
||||||
|
|
||||||
|
@ -37,32 +37,32 @@ class WebtoonConfig(
|
||||||
|
|
||||||
var longStripSplitChangedListener: ((Boolean) -> Unit)? = null
|
var longStripSplitChangedListener: ((Boolean) -> Unit)? = null
|
||||||
|
|
||||||
val theme = preferences.readerTheme().get()
|
val theme = readerPreferences.readerTheme().get()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
preferences.cropBordersWebtoon()
|
readerPreferences.cropBordersWebtoon()
|
||||||
.register({ imageCropBorders = it }, { imagePropertyChangedListener?.invoke() })
|
.register({ imageCropBorders = it }, { imagePropertyChangedListener?.invoke() })
|
||||||
|
|
||||||
preferences.webtoonSidePadding()
|
readerPreferences.webtoonSidePadding()
|
||||||
.register({ sidePadding = it }, { imagePropertyChangedListener?.invoke() })
|
.register({ sidePadding = it }, { imagePropertyChangedListener?.invoke() })
|
||||||
|
|
||||||
preferences.navigationModeWebtoon()
|
readerPreferences.navigationModeWebtoon()
|
||||||
.register({ navigationMode = it }, { updateNavigation(it) })
|
.register({ navigationMode = it }, { updateNavigation(it) })
|
||||||
|
|
||||||
preferences.webtoonNavInverted()
|
readerPreferences.webtoonNavInverted()
|
||||||
.register({ tappingInverted = it }, { navigator.invertMode = it })
|
.register({ tappingInverted = it }, { navigator.invertMode = it })
|
||||||
preferences.webtoonNavInverted().changes()
|
readerPreferences.webtoonNavInverted().changes()
|
||||||
.drop(1)
|
.drop(1)
|
||||||
.onEach { navigationModeChangedListener?.invoke() }
|
.onEach { navigationModeChangedListener?.invoke() }
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
|
|
||||||
preferences.dualPageSplitWebtoon()
|
readerPreferences.dualPageSplitWebtoon()
|
||||||
.register({ dualPageSplit = it }, { imagePropertyChangedListener?.invoke() })
|
.register({ dualPageSplit = it }, { imagePropertyChangedListener?.invoke() })
|
||||||
|
|
||||||
preferences.dualPageInvertWebtoon()
|
readerPreferences.dualPageInvertWebtoon()
|
||||||
.register({ dualPageInvert = it }, { imagePropertyChangedListener?.invoke() })
|
.register({ dualPageInvert = it }, { imagePropertyChangedListener?.invoke() })
|
||||||
|
|
||||||
preferences.longStripSplitWebtoon()
|
readerPreferences.longStripSplitWebtoon()
|
||||||
.register(
|
.register(
|
||||||
{ longStripSplit = it },
|
{ longStripSplit = it },
|
||||||
{
|
{
|
||||||
|
@ -71,7 +71,7 @@ class WebtoonConfig(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
preferences.readerTheme().changes()
|
readerPreferences.readerTheme().changes()
|
||||||
.drop(1)
|
.drop(1)
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
.onEach { themeChangedListener?.invoke() }
|
.onEach { themeChangedListener?.invoke() }
|
||||||
|
|
|
@ -12,12 +12,12 @@ import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.recyclerview.widget.WebtoonLayoutManager
|
import androidx.recyclerview.widget.WebtoonLayoutManager
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition
|
import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.StencilPage
|
import eu.kanade.tachiyomi.ui.reader.model.StencilPage
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
||||||
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer
|
import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation.NavigationRegion
|
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation.NavigationRegion
|
||||||
import eu.kanade.tachiyomi.util.system.logcat
|
import eu.kanade.tachiyomi.util.system.logcat
|
||||||
|
@ -80,7 +80,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
|
||||||
val subscriptions = CompositeSubscription()
|
val subscriptions = CompositeSubscription()
|
||||||
|
|
||||||
private val threshold: Int =
|
private val threshold: Int =
|
||||||
Injekt.get<PreferencesHelper>()
|
Injekt.get<ReaderPreferences>()
|
||||||
.readerHideThreshold()
|
.readerHideThreshold()
|
||||||
.get()
|
.get()
|
||||||
.threshold
|
.threshold
|
||||||
|
|
|
@ -6,6 +6,7 @@ import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues.TappingInvertMode
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues.TappingInvertMode
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
||||||
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
||||||
import eu.kanade.tachiyomi.util.preference.bindTo
|
import eu.kanade.tachiyomi.util.preference.bindTo
|
||||||
import eu.kanade.tachiyomi.util.preference.entriesRes
|
import eu.kanade.tachiyomi.util.preference.entriesRes
|
||||||
|
@ -16,14 +17,17 @@ import eu.kanade.tachiyomi.util.preference.summaryRes
|
||||||
import eu.kanade.tachiyomi.util.preference.switchPreference
|
import eu.kanade.tachiyomi.util.preference.switchPreference
|
||||||
import eu.kanade.tachiyomi.util.preference.titleRes
|
import eu.kanade.tachiyomi.util.preference.titleRes
|
||||||
import eu.kanade.tachiyomi.util.system.hasDisplayCutout
|
import eu.kanade.tachiyomi.util.system.hasDisplayCutout
|
||||||
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
class SettingsReaderController : SettingsController() {
|
class SettingsReaderController : SettingsController() {
|
||||||
|
|
||||||
|
private val readerPreferences: ReaderPreferences by injectLazy()
|
||||||
|
|
||||||
override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply {
|
override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply {
|
||||||
titleRes = R.string.pref_category_reader
|
titleRes = R.string.pref_category_reader
|
||||||
|
|
||||||
intListPreference {
|
intListPreference {
|
||||||
bindTo(preferences.defaultReadingMode())
|
bindTo(readerPreferences.defaultReadingMode())
|
||||||
titleRes = R.string.pref_viewer_type
|
titleRes = R.string.pref_viewer_type
|
||||||
entriesRes = arrayOf(
|
entriesRes = arrayOf(
|
||||||
R.string.left_to_right_viewer,
|
R.string.left_to_right_viewer,
|
||||||
|
@ -37,31 +41,31 @@ class SettingsReaderController : SettingsController() {
|
||||||
summary = "%s"
|
summary = "%s"
|
||||||
}
|
}
|
||||||
intListPreference {
|
intListPreference {
|
||||||
bindTo(preferences.doubleTapAnimSpeed())
|
bindTo(readerPreferences.doubleTapAnimSpeed())
|
||||||
titleRes = R.string.pref_double_tap_anim_speed
|
titleRes = R.string.pref_double_tap_anim_speed
|
||||||
entries = arrayOf(context.getString(R.string.double_tap_anim_speed_0), context.getString(R.string.double_tap_anim_speed_normal), context.getString(R.string.double_tap_anim_speed_fast))
|
entries = arrayOf(context.getString(R.string.double_tap_anim_speed_0), context.getString(R.string.double_tap_anim_speed_normal), context.getString(R.string.double_tap_anim_speed_fast))
|
||||||
entryValues = arrayOf("1", "500", "250") // using a value of 0 breaks the image viewer, so min is 1
|
entryValues = arrayOf("1", "500", "250") // using a value of 0 breaks the image viewer, so min is 1
|
||||||
summary = "%s"
|
summary = "%s"
|
||||||
}
|
}
|
||||||
switchPreference {
|
switchPreference {
|
||||||
bindTo(preferences.showReadingMode())
|
bindTo(readerPreferences.showReadingMode())
|
||||||
titleRes = R.string.pref_show_reading_mode
|
titleRes = R.string.pref_show_reading_mode
|
||||||
summaryRes = R.string.pref_show_reading_mode_summary
|
summaryRes = R.string.pref_show_reading_mode_summary
|
||||||
}
|
}
|
||||||
switchPreference {
|
switchPreference {
|
||||||
bindTo(preferences.showNavigationOverlayOnStart())
|
bindTo(readerPreferences.showNavigationOverlayOnStart())
|
||||||
titleRes = R.string.pref_show_navigation_mode
|
titleRes = R.string.pref_show_navigation_mode
|
||||||
summaryRes = R.string.pref_show_navigation_mode_summary
|
summaryRes = R.string.pref_show_navigation_mode_summary
|
||||||
}
|
}
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
switchPreference {
|
switchPreference {
|
||||||
bindTo(preferences.trueColor())
|
bindTo(readerPreferences.trueColor())
|
||||||
titleRes = R.string.pref_true_color
|
titleRes = R.string.pref_true_color
|
||||||
summaryRes = R.string.pref_true_color_summary
|
summaryRes = R.string.pref_true_color_summary
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switchPreference {
|
switchPreference {
|
||||||
bindTo(preferences.pageTransitions())
|
bindTo(readerPreferences.pageTransitions())
|
||||||
titleRes = R.string.pref_page_transitions
|
titleRes = R.string.pref_page_transitions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +73,7 @@ class SettingsReaderController : SettingsController() {
|
||||||
titleRes = R.string.pref_category_display
|
titleRes = R.string.pref_category_display
|
||||||
|
|
||||||
intListPreference {
|
intListPreference {
|
||||||
bindTo(preferences.defaultOrientationType())
|
bindTo(readerPreferences.defaultOrientationType())
|
||||||
titleRes = R.string.pref_rotation_type
|
titleRes = R.string.pref_rotation_type
|
||||||
entriesRes = arrayOf(
|
entriesRes = arrayOf(
|
||||||
R.string.rotation_free,
|
R.string.rotation_free,
|
||||||
|
@ -84,32 +88,32 @@ class SettingsReaderController : SettingsController() {
|
||||||
summary = "%s"
|
summary = "%s"
|
||||||
}
|
}
|
||||||
intListPreference {
|
intListPreference {
|
||||||
bindTo(preferences.readerTheme())
|
bindTo(readerPreferences.readerTheme())
|
||||||
titleRes = R.string.pref_reader_theme
|
titleRes = R.string.pref_reader_theme
|
||||||
entriesRes = arrayOf(R.string.black_background, R.string.gray_background, R.string.white_background, R.string.automatic_background)
|
entriesRes = arrayOf(R.string.black_background, R.string.gray_background, R.string.white_background, R.string.automatic_background)
|
||||||
entryValues = arrayOf("1", "2", "0", "3")
|
entryValues = arrayOf("1", "2", "0", "3")
|
||||||
summary = "%s"
|
summary = "%s"
|
||||||
}
|
}
|
||||||
switchPreference {
|
switchPreference {
|
||||||
bindTo(preferences.fullscreen())
|
bindTo(readerPreferences.fullscreen())
|
||||||
titleRes = R.string.pref_fullscreen
|
titleRes = R.string.pref_fullscreen
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activity?.hasDisplayCutout() == true) {
|
if (activity?.hasDisplayCutout() == true) {
|
||||||
switchPreference {
|
switchPreference {
|
||||||
bindTo(preferences.cutoutShort())
|
bindTo(readerPreferences.cutoutShort())
|
||||||
titleRes = R.string.pref_cutout_short
|
titleRes = R.string.pref_cutout_short
|
||||||
|
|
||||||
visibleIf(preferences.fullscreen()) { it }
|
visibleIf(readerPreferences.fullscreen()) { it }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switchPreference {
|
switchPreference {
|
||||||
bindTo(preferences.keepScreenOn())
|
bindTo(readerPreferences.keepScreenOn())
|
||||||
titleRes = R.string.pref_keep_screen_on
|
titleRes = R.string.pref_keep_screen_on
|
||||||
}
|
}
|
||||||
switchPreference {
|
switchPreference {
|
||||||
bindTo(preferences.showPageNumber())
|
bindTo(readerPreferences.showPageNumber())
|
||||||
titleRes = R.string.pref_show_page_number
|
titleRes = R.string.pref_show_page_number
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,15 +122,15 @@ class SettingsReaderController : SettingsController() {
|
||||||
titleRes = R.string.pref_category_reading
|
titleRes = R.string.pref_category_reading
|
||||||
|
|
||||||
switchPreference {
|
switchPreference {
|
||||||
bindTo(preferences.skipRead())
|
bindTo(readerPreferences.skipRead())
|
||||||
titleRes = R.string.pref_skip_read_chapters
|
titleRes = R.string.pref_skip_read_chapters
|
||||||
}
|
}
|
||||||
switchPreference {
|
switchPreference {
|
||||||
bindTo(preferences.skipFiltered())
|
bindTo(readerPreferences.skipFiltered())
|
||||||
titleRes = R.string.pref_skip_filtered_chapters
|
titleRes = R.string.pref_skip_filtered_chapters
|
||||||
}
|
}
|
||||||
switchPreference {
|
switchPreference {
|
||||||
bindTo(preferences.alwaysShowChapterTransition())
|
bindTo(readerPreferences.alwaysShowChapterTransition())
|
||||||
titleRes = R.string.pref_always_show_chapter_transition
|
titleRes = R.string.pref_always_show_chapter_transition
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,7 +139,7 @@ class SettingsReaderController : SettingsController() {
|
||||||
titleRes = R.string.pager_viewer
|
titleRes = R.string.pager_viewer
|
||||||
|
|
||||||
intListPreference {
|
intListPreference {
|
||||||
bindTo(preferences.navigationModePager())
|
bindTo(readerPreferences.navigationModePager())
|
||||||
titleRes = R.string.pref_viewer_nav
|
titleRes = R.string.pref_viewer_nav
|
||||||
entries = context.resources.getStringArray(R.array.pager_nav).also { values ->
|
entries = context.resources.getStringArray(R.array.pager_nav).also { values ->
|
||||||
entryValues = values.indices.map { index -> "$index" }.toTypedArray()
|
entryValues = values.indices.map { index -> "$index" }.toTypedArray()
|
||||||
|
@ -143,7 +147,7 @@ class SettingsReaderController : SettingsController() {
|
||||||
summary = "%s"
|
summary = "%s"
|
||||||
}
|
}
|
||||||
listPreference {
|
listPreference {
|
||||||
bindTo(preferences.pagerNavInverted())
|
bindTo(readerPreferences.pagerNavInverted())
|
||||||
titleRes = R.string.pref_read_with_tapping_inverted
|
titleRes = R.string.pref_read_with_tapping_inverted
|
||||||
entriesRes = arrayOf(
|
entriesRes = arrayOf(
|
||||||
R.string.tapping_inverted_none,
|
R.string.tapping_inverted_none,
|
||||||
|
@ -158,10 +162,10 @@ class SettingsReaderController : SettingsController() {
|
||||||
TappingInvertMode.BOTH.name,
|
TappingInvertMode.BOTH.name,
|
||||||
)
|
)
|
||||||
summary = "%s"
|
summary = "%s"
|
||||||
visibleIf(preferences.navigationModePager()) { it != 5 }
|
visibleIf(readerPreferences.navigationModePager()) { it != 5 }
|
||||||
}
|
}
|
||||||
intListPreference {
|
intListPreference {
|
||||||
bindTo(preferences.imageScaleType())
|
bindTo(readerPreferences.imageScaleType())
|
||||||
titleRes = R.string.pref_image_scale_type
|
titleRes = R.string.pref_image_scale_type
|
||||||
entriesRes = arrayOf(
|
entriesRes = arrayOf(
|
||||||
R.string.scale_type_fit_screen,
|
R.string.scale_type_fit_screen,
|
||||||
|
@ -175,12 +179,12 @@ class SettingsReaderController : SettingsController() {
|
||||||
summary = "%s"
|
summary = "%s"
|
||||||
}
|
}
|
||||||
switchPreference {
|
switchPreference {
|
||||||
bindTo(preferences.landscapeZoom())
|
bindTo(readerPreferences.landscapeZoom())
|
||||||
titleRes = R.string.pref_landscape_zoom
|
titleRes = R.string.pref_landscape_zoom
|
||||||
visibleIf(preferences.imageScaleType()) { it == 1 }
|
visibleIf(readerPreferences.imageScaleType()) { it == 1 }
|
||||||
}
|
}
|
||||||
intListPreference {
|
intListPreference {
|
||||||
bindTo(preferences.zoomStart())
|
bindTo(readerPreferences.zoomStart())
|
||||||
titleRes = R.string.pref_zoom_start
|
titleRes = R.string.pref_zoom_start
|
||||||
entriesRes = arrayOf(
|
entriesRes = arrayOf(
|
||||||
R.string.zoom_start_automatic,
|
R.string.zoom_start_automatic,
|
||||||
|
@ -192,22 +196,22 @@ class SettingsReaderController : SettingsController() {
|
||||||
summary = "%s"
|
summary = "%s"
|
||||||
}
|
}
|
||||||
switchPreference {
|
switchPreference {
|
||||||
bindTo(preferences.cropBorders())
|
bindTo(readerPreferences.cropBorders())
|
||||||
titleRes = R.string.pref_crop_borders
|
titleRes = R.string.pref_crop_borders
|
||||||
}
|
}
|
||||||
switchPreference {
|
switchPreference {
|
||||||
bindTo(preferences.navigateToPan())
|
bindTo(readerPreferences.navigateToPan())
|
||||||
titleRes = R.string.pref_navigate_pan
|
titleRes = R.string.pref_navigate_pan
|
||||||
}
|
}
|
||||||
switchPreference {
|
switchPreference {
|
||||||
bindTo(preferences.dualPageSplitPaged())
|
bindTo(readerPreferences.dualPageSplitPaged())
|
||||||
titleRes = R.string.pref_dual_page_split
|
titleRes = R.string.pref_dual_page_split
|
||||||
}
|
}
|
||||||
switchPreference {
|
switchPreference {
|
||||||
bindTo(preferences.dualPageInvertPaged())
|
bindTo(readerPreferences.dualPageInvertPaged())
|
||||||
titleRes = R.string.pref_dual_page_invert
|
titleRes = R.string.pref_dual_page_invert
|
||||||
summaryRes = R.string.pref_dual_page_invert_summary
|
summaryRes = R.string.pref_dual_page_invert_summary
|
||||||
visibleIf(preferences.dualPageSplitPaged()) { it }
|
visibleIf(readerPreferences.dualPageSplitPaged()) { it }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +219,7 @@ class SettingsReaderController : SettingsController() {
|
||||||
titleRes = R.string.webtoon_viewer
|
titleRes = R.string.webtoon_viewer
|
||||||
|
|
||||||
intListPreference {
|
intListPreference {
|
||||||
bindTo(preferences.navigationModeWebtoon())
|
bindTo(readerPreferences.navigationModeWebtoon())
|
||||||
titleRes = R.string.pref_viewer_nav
|
titleRes = R.string.pref_viewer_nav
|
||||||
entries = context.resources.getStringArray(R.array.webtoon_nav).also { values ->
|
entries = context.resources.getStringArray(R.array.webtoon_nav).also { values ->
|
||||||
entryValues = values.indices.map { index -> "$index" }.toTypedArray()
|
entryValues = values.indices.map { index -> "$index" }.toTypedArray()
|
||||||
|
@ -223,7 +227,7 @@ class SettingsReaderController : SettingsController() {
|
||||||
summary = "%s"
|
summary = "%s"
|
||||||
}
|
}
|
||||||
listPreference {
|
listPreference {
|
||||||
bindTo(preferences.webtoonNavInverted())
|
bindTo(readerPreferences.webtoonNavInverted())
|
||||||
titleRes = R.string.pref_read_with_tapping_inverted
|
titleRes = R.string.pref_read_with_tapping_inverted
|
||||||
entriesRes = arrayOf(
|
entriesRes = arrayOf(
|
||||||
R.string.tapping_inverted_none,
|
R.string.tapping_inverted_none,
|
||||||
|
@ -238,10 +242,10 @@ class SettingsReaderController : SettingsController() {
|
||||||
TappingInvertMode.BOTH.name,
|
TappingInvertMode.BOTH.name,
|
||||||
)
|
)
|
||||||
summary = "%s"
|
summary = "%s"
|
||||||
visibleIf(preferences.navigationModeWebtoon()) { it != 5 }
|
visibleIf(readerPreferences.navigationModeWebtoon()) { it != 5 }
|
||||||
}
|
}
|
||||||
intListPreference {
|
intListPreference {
|
||||||
bindTo(preferences.webtoonSidePadding())
|
bindTo(readerPreferences.webtoonSidePadding())
|
||||||
titleRes = R.string.pref_webtoon_side_padding
|
titleRes = R.string.pref_webtoon_side_padding
|
||||||
entriesRes = arrayOf(
|
entriesRes = arrayOf(
|
||||||
R.string.webtoon_side_padding_0,
|
R.string.webtoon_side_padding_0,
|
||||||
|
@ -255,7 +259,7 @@ class SettingsReaderController : SettingsController() {
|
||||||
summary = "%s"
|
summary = "%s"
|
||||||
}
|
}
|
||||||
listPreference {
|
listPreference {
|
||||||
bindTo(preferences.readerHideThreshold())
|
bindTo(readerPreferences.readerHideThreshold())
|
||||||
titleRes = R.string.pref_hide_threshold
|
titleRes = R.string.pref_hide_threshold
|
||||||
entriesRes = arrayOf(
|
entriesRes = arrayOf(
|
||||||
R.string.pref_highest,
|
R.string.pref_highest,
|
||||||
|
@ -269,21 +273,21 @@ class SettingsReaderController : SettingsController() {
|
||||||
summary = "%s"
|
summary = "%s"
|
||||||
}
|
}
|
||||||
switchPreference {
|
switchPreference {
|
||||||
bindTo(preferences.cropBordersWebtoon())
|
bindTo(readerPreferences.cropBordersWebtoon())
|
||||||
titleRes = R.string.pref_crop_borders
|
titleRes = R.string.pref_crop_borders
|
||||||
}
|
}
|
||||||
switchPreference {
|
switchPreference {
|
||||||
bindTo(preferences.dualPageSplitWebtoon())
|
bindTo(readerPreferences.dualPageSplitWebtoon())
|
||||||
titleRes = R.string.pref_dual_page_split
|
titleRes = R.string.pref_dual_page_split
|
||||||
}
|
}
|
||||||
switchPreference {
|
switchPreference {
|
||||||
bindTo(preferences.dualPageInvertWebtoon())
|
bindTo(readerPreferences.dualPageInvertWebtoon())
|
||||||
titleRes = R.string.pref_dual_page_invert
|
titleRes = R.string.pref_dual_page_invert
|
||||||
summaryRes = R.string.pref_dual_page_invert_summary
|
summaryRes = R.string.pref_dual_page_invert_summary
|
||||||
visibleIf(preferences.dualPageSplitWebtoon()) { it }
|
visibleIf(readerPreferences.dualPageSplitWebtoon()) { it }
|
||||||
}
|
}
|
||||||
switchPreference {
|
switchPreference {
|
||||||
bindTo(preferences.longStripSplitWebtoon())
|
bindTo(readerPreferences.longStripSplitWebtoon())
|
||||||
titleRes = R.string.pref_long_strip_split
|
titleRes = R.string.pref_long_strip_split
|
||||||
summaryRes = R.string.split_tall_images_summary
|
summaryRes = R.string.split_tall_images_summary
|
||||||
}
|
}
|
||||||
|
@ -293,13 +297,13 @@ class SettingsReaderController : SettingsController() {
|
||||||
titleRes = R.string.pref_reader_navigation
|
titleRes = R.string.pref_reader_navigation
|
||||||
|
|
||||||
switchPreference {
|
switchPreference {
|
||||||
bindTo(preferences.readWithVolumeKeys())
|
bindTo(readerPreferences.readWithVolumeKeys())
|
||||||
titleRes = R.string.pref_read_with_volume_keys
|
titleRes = R.string.pref_read_with_volume_keys
|
||||||
}
|
}
|
||||||
switchPreference {
|
switchPreference {
|
||||||
bindTo(preferences.readWithVolumeKeysInverted())
|
bindTo(readerPreferences.readWithVolumeKeysInverted())
|
||||||
titleRes = R.string.pref_read_with_volume_keys_inverted
|
titleRes = R.string.pref_read_with_volume_keys_inverted
|
||||||
visibleIf(preferences.readWithVolumeKeys()) { it }
|
visibleIf(readerPreferences.readWithVolumeKeys()) { it }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,11 +311,11 @@ class SettingsReaderController : SettingsController() {
|
||||||
titleRes = R.string.pref_reader_actions
|
titleRes = R.string.pref_reader_actions
|
||||||
|
|
||||||
switchPreference {
|
switchPreference {
|
||||||
bindTo(preferences.readWithLongTap())
|
bindTo(readerPreferences.readWithLongTap())
|
||||||
titleRes = R.string.pref_read_with_long_tap
|
titleRes = R.string.pref_read_with_long_tap
|
||||||
}
|
}
|
||||||
switchPreference {
|
switchPreference {
|
||||||
bindTo(preferences.folderPerManga())
|
bindTo(readerPreferences.folderPerManga())
|
||||||
titleRes = R.string.pref_create_folder_per_manga
|
titleRes = R.string.pref_create_folder_per_manga
|
||||||
summaryRes = R.string.pref_create_folder_per_manga_summary
|
summaryRes = R.string.pref_create_folder_per_manga_summary
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.ui.base.delegate.ThemingDelegate
|
import eu.kanade.tachiyomi.ui.base.delegate.ThemingDelegate
|
||||||
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||||
import eu.kanade.tachiyomi.util.lang.truncateCenter
|
import eu.kanade.tachiyomi.util.lang.truncateCenter
|
||||||
import logcat.LogPriority
|
import logcat.LogPriority
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
|
@ -295,7 +296,8 @@ fun Context.isNightMode(): Boolean {
|
||||||
*/
|
*/
|
||||||
fun Context.createReaderThemeContext(): Context {
|
fun Context.createReaderThemeContext(): Context {
|
||||||
val preferences = Injekt.get<PreferencesHelper>()
|
val preferences = Injekt.get<PreferencesHelper>()
|
||||||
val isDarkBackground = when (preferences.readerTheme().get()) {
|
val readerPreferences = Injekt.get<ReaderPreferences>()
|
||||||
|
val isDarkBackground = when (readerPreferences.readerTheme().get()) {
|
||||||
1, 2 -> true // Black, Gray
|
1, 2 -> true // Black, Gray
|
||||||
3 -> applicationContext.isNightMode() // Automatic bg uses activity background by default
|
3 -> applicationContext.isNightMode() // Automatic bg uses activity background by default
|
||||||
else -> false // White
|
else -> false // White
|
||||||
|
|
Loading…
Reference in a new issue