chore: Update SSIV and Image Decoder

This commit is contained in:
Ahmad Ansori Palembani 2024-05-21 10:21:09 +07:00
parent 32a34b7cf4
commit c3faccacd2
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
10 changed files with 59 additions and 24 deletions

View file

@ -15,4 +15,6 @@ class BasePreferences(private val preferenceStore: PreferenceStore) {
PRIVATE(R.string.ext_installer_private, false),
LEGACY(R.string.ext_installer_legacy, true), // Technically useless, but just in case it being missing crashes the app
}
fun displayProfile() = preferenceStore.getString("pref_display_profile_key", "")
}

View file

@ -25,7 +25,7 @@ class TachiyomiImageDecoder(private val resources: ImageSource, private val opti
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()
check(bitmap != null) { "Failed to decode image." }

View file

@ -24,8 +24,6 @@ object PreferenceKeys {
const val showPageNumber = "pref_show_page_number_key"
const val trueColor = "pref_true_color_key"
const val fullscreen = "fullscreen"
const val keepScreenOn = "pref_keep_screen_on_key"

View file

@ -109,8 +109,6 @@ class PreferencesHelper(val context: Context, val preferenceStore: PreferenceSto
fun showPageNumber() = preferenceStore.getBoolean(Keys.showPageNumber, true)
fun trueColor() = preferenceStore.getBoolean(Keys.trueColor, false)
fun fullscreen() = preferenceStore.getBoolean(Keys.fullscreen, true)
fun keepScreenOn() = preferenceStore.getBoolean(Keys.keepScreenOn, true)

View file

@ -74,6 +74,8 @@ import com.google.android.material.snackbar.Snackbar
import com.google.android.material.transition.platform.MaterialContainerTransformSharedElementCallback
import com.google.common.primitives.Floats.max
import com.google.common.primitives.Ints.max
import dev.yokai.domain.base.BasePreferences
import dev.yokai.domain.ui.settings.ReaderPreferences
import dev.yokai.presentation.extension.repo.ExtensionRepoController
import eu.kanade.tachiyomi.BuildConfig
import eu.kanade.tachiyomi.Migrations
@ -206,6 +208,18 @@ open class MainActivity : BaseActivity<MainActivityBinding>() {
}
}
// Ideally we want this to be inside the controller itself, but Conductor doesn't support the new ActivityResult API
// Should be fine once we moved completely to Compose..... someday....
// REF: https://github.com/bluelinelabs/Conductor/issues/612
private fun requestColourProfile(context: Context, basePreferences: BasePreferences) =
registerForActivityResult(ActivityResultContracts.OpenDocument()) { uri ->
uri?.let {
val flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
context.contentResolver.takePersistableUriPermission(uri, flags)
basePreferences.displayProfile().set(uri.toString())
}
}
fun setUndoSnackBar(snackBar: Snackbar?, extraViewToCheck: View? = null) {
this.snackBar = snackBar
canDismissSnackBar = false
@ -995,6 +1009,11 @@ open class MainActivity : BaseActivity<MainActivityBinding>() {
}
}
fun showColourProfilePicker(context: Context, basePreferences: BasePreferences) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return
requestColourProfile(context, basePreferences).launch(arrayOf("*/*"))
}
override fun onNewIntent(intent: Intent) {
if (!handleIntentAction(intent)) {
super.onNewIntent(intent)

View file

@ -41,6 +41,7 @@ import androidx.activity.viewModels
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.content.ContextCompat
import androidx.core.graphics.ColorUtils
import androidx.core.net.toUri
import androidx.core.text.buildSpannedString
import androidx.core.text.inSpans
import androidx.core.transition.addListener
@ -71,6 +72,8 @@ import com.google.android.material.slider.Slider
import com.google.android.material.snackbar.Snackbar
import com.google.android.material.transition.platform.MaterialContainerTransform
import com.google.android.material.transition.platform.MaterialContainerTransformSharedElementCallback
import com.hippo.unifile.UniFile
import dev.yokai.domain.base.BasePreferences
import dev.yokai.domain.ui.settings.ReaderPreferences
import dev.yokai.domain.ui.settings.ReaderPreferences.LandscapeCutoutBehaviour
import eu.kanade.tachiyomi.BuildConfig
@ -155,6 +158,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import timber.log.Timber
import uy.kohesive.injekt.injectLazy
import java.io.ByteArrayOutputStream
import java.io.File
import java.text.DecimalFormat
import java.text.DecimalFormatSymbols
@ -239,6 +243,7 @@ class ReaderActivity : BaseActivity<ReaderActivityBinding>() {
}
private val readerPreferences: ReaderPreferences by injectLazy()
private val basePreferences: BasePreferences by injectLazy()
companion object {
@ -1954,7 +1959,7 @@ class ReaderActivity : BaseActivity<ReaderActivityBinding>() {
.onEach { setCutoutMode() }
.launchIn(scope)
preferences.trueColor().changesIn(scope) { setTrueColor(it) }
basePreferences.displayProfile().changesIn(scope) { setDisplayProfile(it) }
preferences.fullscreen().changesIn(scope) { setFullscreen(it) }
@ -2001,13 +2006,19 @@ class ReaderActivity : BaseActivity<ReaderActivityBinding>() {
}
/**
* Sets the 32-bit color mode according to [enabled].
* Sets the display profile to [path].
*/
private fun setTrueColor(enabled: Boolean) {
if (enabled) {
SubsamplingScaleImageView.setPreferredBitmapConfig(Bitmap.Config.ARGB_8888)
} else {
SubsamplingScaleImageView.setPreferredBitmapConfig(Bitmap.Config.RGB_565)
private fun setDisplayProfile(path: String) {
val file = UniFile.fromUri(baseContext, path.toUri())
if (file != null && file.exists()) {
val inputStream = file.openInputStream()
val outputStream = ByteArrayOutputStream()
inputStream.use { input ->
outputStream.use { output ->
input.copyTo(output)
}
}
SubsamplingScaleImageView.setDisplayProfile(outputStream.toByteArray())
}
}

View file

@ -16,7 +16,6 @@ import androidx.lifecycle.lifecycleScope
import androidx.preference.PreferenceScreen
import com.google.firebase.crashlytics.ktx.crashlytics
import com.google.firebase.ktx.Firebase
import dev.yokai.domain.base.BasePreferences
import dev.yokai.domain.base.BasePreferences.ExtensionInstaller
import dev.yokai.domain.extension.TrustExtension
import eu.kanade.tachiyomi.BuildConfig
@ -41,6 +40,7 @@ import eu.kanade.tachiyomi.network.PREF_DOH_GOOGLE
import eu.kanade.tachiyomi.network.PREF_DOH_QUAD101
import eu.kanade.tachiyomi.network.PREF_DOH_QUAD9
import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.ui.main.MainActivity
import eu.kanade.tachiyomi.ui.setting.database.ClearDatabaseController
import eu.kanade.tachiyomi.ui.setting.debug.DebugController
import eu.kanade.tachiyomi.util.CrashLogUtil
@ -398,6 +398,20 @@ class SettingsAdvancedController : SettingsController() {
onClick { LibraryUpdateJob.startNow(context, target = Target.TRACKING) }
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
preferenceCategory {
titleRes = R.string.reader
preference {
key = "pref_display_profile"
titleRes = R.string.pref_display_profile
onClick {
(activity as? MainActivity)?.showColourProfilePicker(context, basePreferences)
}
}
}
}
}
private fun cleanupDownloads(removeRead: Boolean, removeNonFavorite: Boolean) {

View file

@ -58,14 +58,6 @@ class SettingsReaderController : SettingsController() {
titleRes = R.string.animate_page_transitions
defaultValue = true
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
switchPreference {
key = Keys.trueColor
titleRes = R.string.true_32bit_color
summaryRes = R.string.reduces_banding_impacts_performance
defaultValue = false
}
}
intListPreference(activity) {
key = Keys.preloadSize
titleRes = R.string.page_preload_amount

View file

@ -522,6 +522,7 @@
<item quantity="one">Skipping %d chapter, either the source is missing it or it has been filtered out</item>
<item quantity="other">Skipping %d chapters, either the source is missing them or they have been filtered out</item>
</plurals>
<string name="pref_display_profile">Custom display profile</string>
<!-- Manga details -->
<string name="about_this_">About this %1$s</string>
@ -1208,4 +1209,4 @@
<string name="sfw">SFW</string>
<string name="nsfw">NSFW</string>
<string name="content_type">Content Type</string>
</resources>
</resources>

View file

@ -29,7 +29,7 @@ flexible-adapter = { module = "com.github.arkon.FlexibleAdapter:flexible-adapter
google-services = { module = "com.google.gms:google-services", version = "4.3.15" }
gradle = { module = "com.android.tools.build:gradle", version = "8.1.4" }
guava = { module = "com.google.guava:guava", version = "31.1-android" }
image-decoder = { module = "com.github.tachiyomiorg:image-decoder", version = "fbd6601290" }
image-decoder = { module = "com.github.tachiyomiorg:image-decoder", version = "e08e9be535" }
injekt-core = { module = "com.github.inorichi.injekt:injekt-core", version = "65b0440" }
material = { module = "com.google.android.material:material", version = "1.11.0" }
material-design-dimens = { module = "com.dmitrymalkovich.android:material-design-dimens", version = "1.4" }
@ -56,7 +56,7 @@ rxjava = { module = "io.reactivex:rxjava", version = "1.3.8" }
rxandroid = { module = "io.reactivex:rxandroid", version = "1.2.1" }
slice = { module = "com.github.mthli:Slice", version = "v1.2" }
sqlite-android = { module = "com.github.requery:sqlite-android", version = "3.39.2" }
subsamplingscaleimageview = { module = "com.github.null2264:subsampling-scale-image-view", version = "e3cffd59c5" }
subsamplingscaleimageview = { module = "com.github.null2264:subsampling-scale-image-view", version = "338caedb5f" }
shizuku-api = { module = "dev.rikka.shizuku:api", version.ref = "shizuku" }
shizuku-provider = { module = "dev.rikka.shizuku:provider", version.ref = "shizuku" }
taptargetview = { module = "com.getkeepsafe.taptargetview:taptargetview", version = "1.13.3" }