Update image-decoder, color management (#523)
* Update image-decoder, color management * move display profile pref * remove true color pref * Move Display Profile settings to a new section * Partially revert "remove true color pref" This partially reverts commit e1a75816950e100936699279e1618adb2fa341aa. * Tweak label --------- Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> (cherry picked from commit 3f2c8e9ef6db540c77b818ffdf771674b3e46c8b) # Conflicts: # app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt # app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt # app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt # gradle/libs.versions.toml
This commit is contained in:
parent
74505565ef
commit
742fdc19ca
@ -32,4 +32,6 @@ class BasePreferences(
|
|||||||
SHIZUKU(MR.strings.ext_installer_shizuku, false),
|
SHIZUKU(MR.strings.ext_installer_shizuku, false),
|
||||||
PRIVATE(MR.strings.ext_installer_private, false),
|
PRIVATE(MR.strings.ext_installer_private, false),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun displayProfile() = preferenceStore.getString("pref_display_profile_key", "")
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,8 @@ import android.provider.Settings
|
|||||||
import android.webkit.WebStorage
|
import android.webkit.WebStorage
|
||||||
import android.webkit.WebView
|
import android.webkit.WebView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||||
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.material3.AlertDialog
|
import androidx.compose.material3.AlertDialog
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
@ -112,15 +114,7 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
val basePreferences = remember { Injekt.get<BasePreferences>() }
|
val basePreferences = remember { Injekt.get<BasePreferences>() }
|
||||||
val networkPreferences = remember { Injekt.get<NetworkPreferences>() }
|
val networkPreferences = remember { Injekt.get<NetworkPreferences>() }
|
||||||
|
|
||||||
return buildList {
|
return listOf(
|
||||||
addAll(
|
|
||||||
listOf(
|
|
||||||
/* SY --> Preference.PreferenceItem.SwitchPreference(
|
|
||||||
pref = basePreferences.acraEnabled(),
|
|
||||||
title = stringResource(MR.strings.pref_enable_acra),
|
|
||||||
subtitle = stringResource(MR.strings.pref_acra_summary),
|
|
||||||
enabled = isPreviewBuildType || isReleaseBuildType,
|
|
||||||
), SY <-- */
|
|
||||||
Preference.PreferenceItem.TextPreference(
|
Preference.PreferenceItem.TextPreference(
|
||||||
title = stringResource(MR.strings.pref_dump_crash_logs),
|
title = stringResource(MR.strings.pref_dump_crash_logs),
|
||||||
subtitle = stringResource(MR.strings.pref_dump_crash_logs_summary),
|
subtitle = stringResource(MR.strings.pref_dump_crash_logs_summary),
|
||||||
@ -147,10 +141,6 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
title = stringResource(MR.strings.pref_onboarding_guide),
|
title = stringResource(MR.strings.pref_onboarding_guide),
|
||||||
onClick = { navigator.push(OnboardingScreen()) },
|
onClick = { navigator.push(OnboardingScreen()) },
|
||||||
),
|
),
|
||||||
),
|
|
||||||
)
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
||||||
add(
|
|
||||||
Preference.PreferenceItem.TextPreference(
|
Preference.PreferenceItem.TextPreference(
|
||||||
title = stringResource(MR.strings.pref_manage_notifications),
|
title = stringResource(MR.strings.pref_manage_notifications),
|
||||||
onClick = {
|
onClick = {
|
||||||
@ -160,24 +150,19 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
context.startActivity(intent)
|
context.startActivity(intent)
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
|
||||||
}
|
|
||||||
addAll(
|
|
||||||
listOf(
|
|
||||||
getBackgroundActivityGroup(),
|
getBackgroundActivityGroup(),
|
||||||
getDataGroup(),
|
getDataGroup(),
|
||||||
getNetworkGroup(networkPreferences = networkPreferences),
|
getNetworkGroup(networkPreferences = networkPreferences),
|
||||||
getLibraryGroup(),
|
getLibraryGroup(),
|
||||||
|
getReaderGroup(basePreferences = basePreferences),
|
||||||
getExtensionsGroup(basePreferences = basePreferences),
|
getExtensionsGroup(basePreferences = basePreferences),
|
||||||
// SY -->
|
// SY -->
|
||||||
// getDownloaderGroup(),
|
// getDownloaderGroup(),
|
||||||
getDataSaverGroup(),
|
getDataSaverGroup(),
|
||||||
getDeveloperToolsGroup(),
|
getDeveloperToolsGroup(),
|
||||||
// SY <--
|
// SY <--
|
||||||
),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun getBackgroundActivityGroup(): Preference.PreferenceGroup {
|
private fun getBackgroundActivityGroup(): Preference.PreferenceGroup {
|
||||||
@ -367,6 +352,34 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun getReaderGroup(
|
||||||
|
basePreferences: BasePreferences,
|
||||||
|
): Preference.PreferenceGroup {
|
||||||
|
val context = LocalContext.current
|
||||||
|
val chooseColorProfile = rememberLauncherForActivityResult(
|
||||||
|
contract = ActivityResultContracts.OpenDocument(),
|
||||||
|
) { uri ->
|
||||||
|
uri?.let {
|
||||||
|
val flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
|
||||||
|
context.contentResolver.takePersistableUriPermission(uri, flags)
|
||||||
|
basePreferences.displayProfile().set(uri.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Preference.PreferenceGroup(
|
||||||
|
title = stringResource(MR.strings.pref_category_reader),
|
||||||
|
preferenceItems = persistentListOf(
|
||||||
|
Preference.PreferenceItem.TextPreference(
|
||||||
|
title = stringResource(MR.strings.pref_display_profile),
|
||||||
|
subtitle = basePreferences.displayProfile().get(),
|
||||||
|
onClick = {
|
||||||
|
chooseColorProfile.launch(arrayOf("*/*"))
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun getExtensionsGroup(
|
private fun getExtensionsGroup(
|
||||||
basePreferences: BasePreferences,
|
basePreferences: BasePreferences,
|
||||||
|
@ -35,6 +35,7 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
// SY -->
|
// SY -->
|
||||||
val forceHorizontalSeekbar by readerPref.forceHorizontalSeekbar().collectAsState()
|
val forceHorizontalSeekbar by readerPref.forceHorizontalSeekbar().collectAsState()
|
||||||
// SY <--
|
// SY <--
|
||||||
|
|
||||||
return listOf(
|
return listOf(
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
pref = readerPref.defaultReadingMode(),
|
pref = readerPref.defaultReadingMode(),
|
||||||
@ -81,12 +82,6 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
enabled = !forceHorizontalSeekbar,
|
enabled = !forceHorizontalSeekbar,
|
||||||
),
|
),
|
||||||
// SY <--
|
// SY <--
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
|
||||||
pref = readerPref.trueColor(),
|
|
||||||
title = stringResource(MR.strings.pref_true_color),
|
|
||||||
subtitle = stringResource(MR.strings.pref_true_color_summary),
|
|
||||||
enabled = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O,
|
|
||||||
),
|
|
||||||
/* SY -->
|
/* SY -->
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
pref = readerPref.pageTransitions(),
|
pref = readerPref.pageTransitions(),
|
||||||
|
@ -46,7 +46,7 @@ class TachiyomiImageDecoder(private val resources: ImageSource, private val opti
|
|||||||
|
|
||||||
check(decoder != null && decoder.width > 0 && decoder.height > 0) { "Failed to initialize decoder" }
|
check(decoder != null && decoder.width > 0 && decoder.height > 0) { "Failed to initialize decoder" }
|
||||||
|
|
||||||
val bitmap = decoder.decode(rgb565 = options.allowRgb565)
|
val bitmap = decoder.decode()
|
||||||
decoder.recycle()
|
decoder.recycle()
|
||||||
|
|
||||||
check(bitmap != null) { "Failed to decode image" }
|
check(bitmap != null) { "Failed to decode image" }
|
||||||
|
@ -47,6 +47,7 @@ import androidx.lifecycle.repeatOnLifecycle
|
|||||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||||
import com.google.android.material.elevation.SurfaceColors
|
import com.google.android.material.elevation.SurfaceColors
|
||||||
import com.google.android.material.transition.platform.MaterialContainerTransform
|
import com.google.android.material.transition.platform.MaterialContainerTransform
|
||||||
|
import com.hippo.unifile.UniFile
|
||||||
import dev.chrisbanes.insetter.applyInsetter
|
import dev.chrisbanes.insetter.applyInsetter
|
||||||
import eu.kanade.domain.base.BasePreferences
|
import eu.kanade.domain.base.BasePreferences
|
||||||
import eu.kanade.domain.manga.model.readingMode
|
import eu.kanade.domain.manga.model.readingMode
|
||||||
@ -123,6 +124,7 @@ import tachiyomi.i18n.sy.SYMR
|
|||||||
import tachiyomi.presentation.core.util.collectAsState
|
import tachiyomi.presentation.core.util.collectAsState
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
import java.io.ByteArrayOutputStream
|
||||||
import kotlin.time.Duration.Companion.seconds
|
import kotlin.time.Duration.Companion.seconds
|
||||||
|
|
||||||
class ReaderActivity : BaseActivity() {
|
class ReaderActivity : BaseActivity() {
|
||||||
@ -1197,8 +1199,8 @@ class ReaderActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
.launchIn(lifecycleScope)
|
.launchIn(lifecycleScope)
|
||||||
|
|
||||||
readerPreferences.trueColor().changes()
|
preferences.displayProfile().changes()
|
||||||
.onEach(::setTrueColor)
|
.onEach { setDisplayProfile(it) }
|
||||||
.launchIn(lifecycleScope)
|
.launchIn(lifecycleScope)
|
||||||
|
|
||||||
readerPreferences.cutoutShort().changes()
|
readerPreferences.cutoutShort().changes()
|
||||||
@ -1266,13 +1268,19 @@ class ReaderActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the 32-bit color mode according to [enabled].
|
* Sets the display profile to [path].
|
||||||
*/
|
*/
|
||||||
private fun setTrueColor(enabled: Boolean) {
|
private fun setDisplayProfile(path: String) {
|
||||||
if (enabled) {
|
val file = UniFile.fromUri(baseContext, path.toUri())
|
||||||
SubsamplingScaleImageView.setPreferredBitmapConfig(Bitmap.Config.ARGB_8888)
|
if (file != null && file.exists()) {
|
||||||
} else {
|
val inputStream = file.openInputStream()
|
||||||
SubsamplingScaleImageView.setPreferredBitmapConfig(Bitmap.Config.RGB_565)
|
val outputStream = ByteArrayOutputStream()
|
||||||
|
inputStream.use { input ->
|
||||||
|
outputStream.use { output ->
|
||||||
|
input.copyTo(output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SubsamplingScaleImageView.setDisplayProfile(outputStream.toByteArray())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,9 +29,6 @@ class ReaderPreferences(
|
|||||||
|
|
||||||
fun showReadingMode() = preferenceStore.getBoolean("pref_show_reading_mode", true)
|
fun showReadingMode() = preferenceStore.getBoolean("pref_show_reading_mode", true)
|
||||||
|
|
||||||
// TODO: default this to true if reader long strip ever goes stable
|
|
||||||
fun trueColor() = preferenceStore.getBoolean("pref_true_color_key", false)
|
|
||||||
|
|
||||||
fun fullscreen() = preferenceStore.getBoolean("fullscreen", true)
|
fun fullscreen() = preferenceStore.getBoolean("fullscreen", true)
|
||||||
|
|
||||||
fun cutoutShort() = preferenceStore.getBoolean("cutout_short", true)
|
fun cutoutShort() = preferenceStore.getBoolean("cutout_short", true)
|
||||||
|
@ -21,7 +21,6 @@ abstract class ViewerConfig(readerPreferences: ReaderPreferences, private val sc
|
|||||||
var doubleTapAnimDuration = 500
|
var doubleTapAnimDuration = 500
|
||||||
var volumeKeysEnabled = false
|
var volumeKeysEnabled = false
|
||||||
var volumeKeysInverted = false
|
var volumeKeysInverted = false
|
||||||
var trueColor = false
|
|
||||||
var alwaysShowChapterTransition = true
|
var alwaysShowChapterTransition = true
|
||||||
var navigationMode = 0
|
var navigationMode = 0
|
||||||
protected set
|
protected set
|
||||||
@ -58,9 +57,6 @@ abstract class ViewerConfig(readerPreferences: ReaderPreferences, private val sc
|
|||||||
readerPreferences.readWithVolumeKeysInverted()
|
readerPreferences.readWithVolumeKeysInverted()
|
||||||
.register({ volumeKeysInverted = it })
|
.register({ volumeKeysInverted = it })
|
||||||
|
|
||||||
readerPreferences.trueColor()
|
|
||||||
.register({ trueColor = it }, { imagePropertyChangedListener?.invoke() })
|
|
||||||
|
|
||||||
readerPreferences.alwaysShowChapterTransition()
|
readerPreferences.alwaysShowChapterTransition()
|
||||||
.register({ alwaysShowChapterTransition = it })
|
.register({ alwaysShowChapterTransition = it })
|
||||||
|
|
||||||
|
@ -52,8 +52,8 @@ coil-gif = { module = "io.coil-kt.coil3:coil-gif" }
|
|||||||
coil-compose = { module = "io.coil-kt.coil3:coil-compose" }
|
coil-compose = { module = "io.coil-kt.coil3:coil-compose" }
|
||||||
coil-network-okhttp = { module = "io.coil-kt.coil3:coil-network-okhttp" }
|
coil-network-okhttp = { module = "io.coil-kt.coil3:coil-network-okhttp" }
|
||||||
|
|
||||||
subsamplingscaleimageview = "com.github.tachiyomiorg:subsampling-scale-image-view:7e57335"
|
subsamplingscaleimageview = "com.github.tachiyomiorg:subsampling-scale-image-view:aeaa170036"
|
||||||
image-decoder = "com.github.tachiyomiorg:image-decoder:398d3c074f"
|
image-decoder = "com.github.tachiyomiorg:image-decoder:e08e9be535"
|
||||||
exifinterface = "androidx.exifinterface:exifinterface:1.3.6"
|
exifinterface = "androidx.exifinterface:exifinterface:1.3.6"
|
||||||
|
|
||||||
natural-comparator = "com.github.gpanther:java-nat-sort:natural-comparator-1.1"
|
natural-comparator = "com.github.gpanther:java-nat-sort:natural-comparator-1.1"
|
||||||
|
@ -370,8 +370,7 @@
|
|||||||
<string name="pref_show_page_number">Show page number</string>
|
<string name="pref_show_page_number">Show page number</string>
|
||||||
<string name="pref_show_reading_mode">Show reading mode</string>
|
<string name="pref_show_reading_mode">Show reading mode</string>
|
||||||
<string name="pref_show_reading_mode_summary">Briefly show current mode when reader is opened</string>
|
<string name="pref_show_reading_mode_summary">Briefly show current mode when reader is opened</string>
|
||||||
<string name="pref_true_color">32-bit color</string>
|
<string name="pref_display_profile">Custom display profile</string>
|
||||||
<string name="pref_true_color_summary">Reduces banding, but may impact performance</string>
|
|
||||||
<string name="pref_crop_borders">Crop borders</string>
|
<string name="pref_crop_borders">Crop borders</string>
|
||||||
<string name="pref_custom_brightness">Custom brightness</string>
|
<string name="pref_custom_brightness">Custom brightness</string>
|
||||||
<string name="pref_grayscale">Grayscale</string>
|
<string name="pref_grayscale">Grayscale</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user