From bb4d9fc81a043ac4f2d0105f19c09974ae2f7201 Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Sat, 2 Nov 2024 20:12:53 +0600 Subject: [PATCH] Add option to always use SSIV for image decoding --- CHANGELOG.md | 1 + app/src/main/java/eu/kanade/domain/base/BasePreferences.kt | 2 ++ .../more/settings/screen/SettingsAdvancedScreen.kt | 4 ++++ .../tachiyomi/ui/reader/viewer/ReaderPageImageView.kt | 7 ++++++- i18n/src/commonMain/moko-resources/base/strings.xml | 1 + 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3e653d9a..cd07d6bf4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co - Fixed "currentTab was used multiple times" - Fixed a rare crash when invoking "Mark previous as read" action - Fixed long strip images not loading in some old devices + - Added option to always use SSIV for image decoding ### Improved - Bangumi search now shows the score and summary of a search result ([@MajorTanya](https://github.com/MajorTanya)) ([#1396](https://github.com/mihonapp/mihon/pull/1396)) diff --git a/app/src/main/java/eu/kanade/domain/base/BasePreferences.kt b/app/src/main/java/eu/kanade/domain/base/BasePreferences.kt index 1700f0a02..15969d5b3 100644 --- a/app/src/main/java/eu/kanade/domain/base/BasePreferences.kt +++ b/app/src/main/java/eu/kanade/domain/base/BasePreferences.kt @@ -30,4 +30,6 @@ class BasePreferences( } fun displayProfile() = preferenceStore.getString("pref_display_profile_key", "") + + fun alwaysUseSSIVToDecode() = preferenceStore.getBoolean("pref_always_use_ssiv_to_decode", false) } diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt index 8cf062ee9..b53483e41 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt @@ -341,6 +341,10 @@ object SettingsAdvancedScreen : SearchableSettings { chooseColorProfile.launch(arrayOf("*/*")) }, ), + Preference.PreferenceItem.SwitchPreference( + pref = basePreferences.alwaysUseSSIVToDecode(), + title = stringResource(MR.strings.pref_always_use_ssiv_to_decode), + ), ), ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderPageImageView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderPageImageView.kt index bd6f419c9..ddff31fad 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderPageImageView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderPageImageView.kt @@ -33,6 +33,7 @@ import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView.EASE_IN_OUT import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView.EASE_OUT_QUAD import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView.SCALE_TYPE_CENTER_INSIDE import com.github.chrisbanes.photoview.PhotoView +import eu.kanade.domain.base.BasePreferences import eu.kanade.tachiyomi.data.coil.cropBorders import eu.kanade.tachiyomi.data.coil.customDecoder import eu.kanade.tachiyomi.ui.reader.viewer.webtoon.WebtoonSubsamplingImageView @@ -41,6 +42,8 @@ import eu.kanade.tachiyomi.util.system.animatorDurationScale import eu.kanade.tachiyomi.util.view.isVisibleOnScreen import okio.BufferedSource import tachiyomi.core.common.util.system.ImageUtil +import uy.kohesive.injekt.Injekt +import uy.kohesive.injekt.api.get /** * A wrapper view for showing page image. @@ -58,6 +61,8 @@ open class ReaderPageImageView @JvmOverloads constructor( private val isWebtoon: Boolean = false, ) : FrameLayout(context, attrs, defStyleAttrs, defStyleRes) { + private val alwaysUseSSIVToDecode by lazy { Injekt.get().alwaysUseSSIVToDecode().get() } + private var pageView: View? = null private var config: Config? = null @@ -295,7 +300,7 @@ open class ReaderPageImageView @JvmOverloads constructor( isVisible = true } is BufferedSource -> { - if (!isWebtoon || !ImageUtil.canUseCoilToDecode(data)) { + if (alwaysUseSSIVToDecode || !isWebtoon || !ImageUtil.canUseCoilToDecode(data)) { setImage(ImageSource.inputStream(data.inputStream())) isVisible = true } else { diff --git a/i18n/src/commonMain/moko-resources/base/strings.xml b/i18n/src/commonMain/moko-resources/base/strings.xml index 6d7e7adba..7d1f3bf7d 100644 --- a/i18n/src/commonMain/moko-resources/base/strings.xml +++ b/i18n/src/commonMain/moko-resources/base/strings.xml @@ -392,6 +392,7 @@ Show reading mode Briefly show current mode when reader is opened Custom display profile + Always use SSIV to decode long strip images Crop borders Custom brightness Grayscale