FooIbar committed 2023-10-05 13:30:33 +08:00
1 parent 2caf3f0174
commit 8288559e44
3 files changed
+7 -2

No files matched your search

@@ -24,6 +24,7 @@ import com.hippo.ehviewer.Settings.archivePasswds
import com.hippo.ehviewer.image.Image
import com.hippo.ehviewer.image.rewriteGifSource
import com.hippo.ehviewer.util.FileUtils
import com.hippo.ehviewer.util.isAtLeastU
import com.hippo.unifile.UniFile
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.CoroutineStart
@@ -102,7 +103,9 @@ class ArchivePageLoader(context: Context, private val uri: Uri, passwdFlow: Flow
val buffer = extractToByteBuffer(index)
buffer ?: return
check(buffer.isDirect)
rewriteGifSource(buffer)
if (!isAtLeastU) {
rewriteGifSource(buffer)
}
val source = ImageDecoder.createSource(buffer)
val src = object : Image.CloseableSource {
override val source: ImageDecoder.Source
@@ -34,6 +34,7 @@ import com.hippo.ehviewer.gallery.SUPPORT_IMAGE_EXTENSIONS
import com.hippo.ehviewer.image.Image.CloseableSource
import com.hippo.ehviewer.image.rewriteGifSource2
import com.hippo.ehviewer.util.FileUtils
import com.hippo.ehviewer.util.isAtLeastU
import com.hippo.ehviewer.util.isCronetSupported
import com.hippo.ehviewer.util.sendTo
import com.hippo.unifile.UniFile
@@ -163,7 +164,7 @@ class SpiderDen(mGalleryInfo: GalleryInfo) {
private suspend fun saveResponseMeta(index: Int, ext: String, length: Long, fops: suspend (UniFile) -> Unit): Boolean {
suspend fun realFops(f: UniFile) = fops(f).apply {
if (ext.lowercase() == "gif") {
if (ext.lowercase() == "gif" && !isAtLeastU) {
f.openFileDescriptor("rw").use { rewriteGifSource2(it.fd) }
}
}
@@ -5,4 +5,5 @@ import android.os.ext.SdkExtensions
val isAtLeastQ = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
val isAtLeastR = Build.VERSION.SDK_INT >= Build.VERSION_CODES.R
val isAtLeastU = Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE
val isAtLeastSExtension7 = isAtLeastR && SdkExtensions.getExtensionVersion(Build.VERSION_CODES.S) >= 7