From 06933c3612c1616c14197d6d42855b90db3bc673 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Tue, 10 Aug 2021 22:40:45 -0400 Subject: [PATCH] Adding back option to save animated covers --- .../eu/kanade/tachiyomi/ui/manga/FullCoverDialog.kt | 5 ----- .../tachiyomi/ui/manga/MangaDetailsController.kt | 11 +---------- .../tachiyomi/ui/manga/MangaDetailsPresenter.kt | 12 +++++++----- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/FullCoverDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/FullCoverDialog.kt index 4321e0fab4..c510ea20b4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/FullCoverDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/FullCoverDialog.kt @@ -5,7 +5,6 @@ import android.animation.ValueAnimator import android.app.Dialog import android.graphics.Color import android.graphics.Rect -import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.Drawable import android.os.Build import android.view.LayoutInflater @@ -13,7 +12,6 @@ import android.view.View import android.view.animation.DecelerateInterpolator import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.animation.addListener -import androidx.core.view.isVisible import androidx.transition.ChangeBounds import androidx.transition.ChangeImageTransform import androidx.transition.TransitionManager @@ -66,9 +64,6 @@ class FullCoverDialog(val controller: MangaDetailsController, drawable: Drawable .build() expandedImageView.setImageDrawable(drawable) - if (drawable !is BitmapDrawable) { - binding.buttonContainer.isVisible = false - } val rect = Rect() thumbView.getGlobalVisibleRect(rect) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt index afce1f78d8..38e1307551 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt @@ -29,7 +29,6 @@ import androidx.palette.graphics.Palette import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView -import coil.Coil import coil.imageLoader import coil.request.ImageRequest import com.afollestad.materialdialogs.MaterialDialog @@ -924,15 +923,7 @@ class MangaDetailsController : override fun prepareToShareManga() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { - val request = ImageRequest.Builder(activity!!).data(manga).target( - onError = { - shareManga() - }, - onSuccess = { - presenter.shareManga((it as BitmapDrawable).bitmap) - } - ).build() - Coil.imageLoader(activity!!).enqueue(request) + presenter.shareManga() } else { shareManga() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt index 44efd4ed93..69770a7ad7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt @@ -51,6 +51,7 @@ import eu.kanade.tachiyomi.util.system.ImageUtil import eu.kanade.tachiyomi.util.manga.MangaShortcutManager import eu.kanade.tachiyomi.util.system.executeOnIO import eu.kanade.tachiyomi.util.system.launchIO +import eu.kanade.tachiyomi.util.system.withUIContext import eu.kanade.tachiyomi.widget.TriStateCheckBox import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -669,17 +670,18 @@ class MangaDetailsPresenter( } } - fun shareManga(cover: Bitmap) { + fun shareManga() { val context = Injekt.get() val destDir = File(context.cacheDir, "shared_image") - scope.launch(Dispatchers.IO) { + scope.launchIO { destDir.deleteRecursively() try { - val image = saveImage(cover, destDir, manga) - if (image != null) controller.shareManga(image) - else controller.shareManga() + val file = saveCover(destDir) + withUIContext { + controller.shareManga(file) + } } catch (e: java.lang.Exception) { } }