Adding back option to save animated covers

This commit is contained in:
Jays2Kings 2021-08-10 22:40:45 -04:00
parent d96365bd93
commit 06933c3612
3 changed files with 8 additions and 20 deletions

View File

@ -5,7 +5,6 @@ import android.animation.ValueAnimator
import android.app.Dialog import android.app.Dialog
import android.graphics.Color import android.graphics.Color
import android.graphics.Rect import android.graphics.Rect
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.os.Build import android.os.Build
import android.view.LayoutInflater import android.view.LayoutInflater
@ -13,7 +12,6 @@ import android.view.View
import android.view.animation.DecelerateInterpolator import android.view.animation.DecelerateInterpolator
import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.animation.addListener import androidx.core.animation.addListener
import androidx.core.view.isVisible
import androidx.transition.ChangeBounds import androidx.transition.ChangeBounds
import androidx.transition.ChangeImageTransform import androidx.transition.ChangeImageTransform
import androidx.transition.TransitionManager import androidx.transition.TransitionManager
@ -66,9 +64,6 @@ class FullCoverDialog(val controller: MangaDetailsController, drawable: Drawable
.build() .build()
expandedImageView.setImageDrawable(drawable) expandedImageView.setImageDrawable(drawable)
if (drawable !is BitmapDrawable) {
binding.buttonContainer.isVisible = false
}
val rect = Rect() val rect = Rect()
thumbView.getGlobalVisibleRect(rect) thumbView.getGlobalVisibleRect(rect)

View File

@ -29,7 +29,6 @@ import androidx.palette.graphics.Palette
import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import coil.Coil
import coil.imageLoader import coil.imageLoader
import coil.request.ImageRequest import coil.request.ImageRequest
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
@ -924,15 +923,7 @@ class MangaDetailsController :
override fun prepareToShareManga() { override fun prepareToShareManga() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
val request = ImageRequest.Builder(activity!!).data(manga).target( presenter.shareManga()
onError = {
shareManga()
},
onSuccess = {
presenter.shareManga((it as BitmapDrawable).bitmap)
}
).build()
Coil.imageLoader(activity!!).enqueue(request)
} else { } else {
shareManga() shareManga()
} }

View File

@ -51,6 +51,7 @@ import eu.kanade.tachiyomi.util.system.ImageUtil
import eu.kanade.tachiyomi.util.manga.MangaShortcutManager import eu.kanade.tachiyomi.util.manga.MangaShortcutManager
import eu.kanade.tachiyomi.util.system.executeOnIO import eu.kanade.tachiyomi.util.system.executeOnIO
import eu.kanade.tachiyomi.util.system.launchIO import eu.kanade.tachiyomi.util.system.launchIO
import eu.kanade.tachiyomi.util.system.withUIContext
import eu.kanade.tachiyomi.widget.TriStateCheckBox import eu.kanade.tachiyomi.widget.TriStateCheckBox
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -669,17 +670,18 @@ class MangaDetailsPresenter(
} }
} }
fun shareManga(cover: Bitmap) { fun shareManga() {
val context = Injekt.get<Application>() val context = Injekt.get<Application>()
val destDir = File(context.cacheDir, "shared_image") val destDir = File(context.cacheDir, "shared_image")
scope.launch(Dispatchers.IO) { scope.launchIO {
destDir.deleteRecursively() destDir.deleteRecursively()
try { try {
val image = saveImage(cover, destDir, manga) val file = saveCover(destDir)
if (image != null) controller.shareManga(image) withUIContext {
else controller.shareManga() controller.shareManga(file)
}
} catch (e: java.lang.Exception) { } catch (e: java.lang.Exception) {
} }
} }