mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
feat(source/local): Button to invalidate local source manga cover
In case Android somehow messing up the URI the first time
This commit is contained in:
parent
931a4e84c3
commit
4f46d0ee28
5 changed files with 34 additions and 12 deletions
|
@ -72,6 +72,13 @@ class LocalSource(private val context: Context) : CatalogueSource, UnmeteredSour
|
|||
}
|
||||
}
|
||||
|
||||
fun invalidateCover(manga: SManga) {
|
||||
val dir = getBaseDirectory()?.findFile(manga.url) ?: return
|
||||
val cover = getCoverFile(dir) ?: return
|
||||
|
||||
manga.thumbnail_url = cover.uri.toString()
|
||||
}
|
||||
|
||||
fun updateCover(manga: SManga, input: InputStream): UniFile? {
|
||||
val dir = getBaseDirectory()?.findFile(manga.url)
|
||||
if (dir == null) {
|
||||
|
|
|
@ -216,14 +216,22 @@ class EditMangaDialog : DialogController {
|
|||
true
|
||||
}
|
||||
|
||||
binding.resetCover.isVisible = !isLocal
|
||||
binding.resetCover.setOnClickListener {
|
||||
binding.mangaCover.load(
|
||||
manga,
|
||||
) {
|
||||
extras[MangaCoverFetcher.USE_CUSTOM_COVER_KEY] = false
|
||||
binding.resetCover.text = context.getString(
|
||||
if (isLocal) {
|
||||
MR.strings.invalidate_cover
|
||||
} else {
|
||||
MR.strings.reset_cover
|
||||
}
|
||||
)
|
||||
binding.resetCover.setOnClickListener {
|
||||
if (!isLocal) {
|
||||
binding.mangaCover.load(
|
||||
manga,
|
||||
) {
|
||||
extras[MangaCoverFetcher.USE_CUSTOM_COVER_KEY] = false
|
||||
}
|
||||
customCoverUri = null
|
||||
}
|
||||
customCoverUri = null
|
||||
willResetCover = true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,10 +12,6 @@ import coil3.request.SuccessResult
|
|||
import com.hippo.unifile.UniFile
|
||||
import dev.icerock.moko.resources.StringResource
|
||||
import eu.kanade.tachiyomi.BuildConfig
|
||||
import eu.kanade.tachiyomi.R
|
||||
import yokai.i18n.MR
|
||||
import yokai.util.lang.getString
|
||||
import dev.icerock.moko.resources.compose.stringResource
|
||||
import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
import eu.kanade.tachiyomi.data.database.models.Category
|
||||
|
@ -81,6 +77,8 @@ import yokai.domain.library.custom.model.CustomMangaInfo
|
|||
import yokai.domain.manga.interactor.UpdateManga
|
||||
import yokai.domain.manga.models.MangaUpdate
|
||||
import yokai.domain.storage.StorageManager
|
||||
import yokai.i18n.MR
|
||||
import yokai.util.lang.getString
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.OutputStream
|
||||
|
@ -854,7 +852,11 @@ class MangaDetailsPresenter(
|
|||
if (uri != null) {
|
||||
editCoverWithStream(uri)
|
||||
} else if (resetCover) {
|
||||
coverCache.deleteCustomCover(manga)
|
||||
if (!manga.isLocal()) {
|
||||
coverCache.deleteCustomCover(manga)
|
||||
} else {
|
||||
LocalSource.invalidateCover(manga)
|
||||
}
|
||||
view?.setPaletteColor()
|
||||
}
|
||||
view?.updateHeader()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue