Add custom Thumbnail Url. Support backup & restore (#1059)
* Add custom thumbnail url. Support backup & restore - add custom thumbnail url in edit info/custom - include it in backup n restore * increase chop char * edit chop char again to match screenshoot * tweak truncating middle part * apply edited cover to history, updates , others * simplify placeholder logic --------- Co-authored-by: jobobby04 <jobobby04@users.noreply.github.com>
This commit is contained in:
@@ -55,6 +55,7 @@ fun Manga.copyFrom(other: SManga): Manga {
|
||||
// SY -->
|
||||
val author = other.author ?: ogAuthor
|
||||
val artist = other.artist ?: ogArtist
|
||||
val thumbnailUrl = other.thumbnail_url ?: ogThumbnailUrl
|
||||
val description = other.description ?: ogDescription
|
||||
val genres = if (other.genre != null) {
|
||||
other.getGenres()
|
||||
@@ -62,15 +63,14 @@ fun Manga.copyFrom(other: SManga): Manga {
|
||||
ogGenre
|
||||
}
|
||||
// SY <--
|
||||
val thumbnailUrl = other.thumbnail_url ?: thumbnailUrl
|
||||
return this.copy(
|
||||
// SY -->
|
||||
ogAuthor = author,
|
||||
ogArtist = artist,
|
||||
ogThumbnailUrl = thumbnailUrl,
|
||||
ogDescription = description,
|
||||
ogGenre = genres,
|
||||
// SY <--
|
||||
thumbnailUrl = thumbnailUrl,
|
||||
// SY -->
|
||||
ogStatus = other.status.toLong(),
|
||||
// SY <--
|
||||
@@ -86,11 +86,11 @@ fun SManga.toDomainManga(sourceId: Long): Manga {
|
||||
ogTitle = title,
|
||||
ogArtist = artist,
|
||||
ogAuthor = author,
|
||||
ogThumbnailUrl = thumbnail_url,
|
||||
ogDescription = description,
|
||||
ogGenre = getGenres(),
|
||||
ogStatus = status.toLong(),
|
||||
// SY <--
|
||||
thumbnailUrl = thumbnail_url,
|
||||
updateStrategy = update_strategy,
|
||||
initialized = initialized,
|
||||
source = sourceId,
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ private fun BrowseSourceComfortableGridItem(
|
||||
mangaId = manga.id,
|
||||
sourceId = manga.source,
|
||||
isMangaFavorite = manga.favorite,
|
||||
url = manga.thumbnailUrl,
|
||||
ogUrl = manga.thumbnailUrl,
|
||||
lastModified = manga.coverLastModified,
|
||||
),
|
||||
coverAlpha = if (manga.favorite) CommonMangaItemDefaults.BrowseFavoriteCoverAlpha else 1f,
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ private fun BrowseSourceCompactGridItem(
|
||||
mangaId = manga.id,
|
||||
sourceId = manga.source,
|
||||
isMangaFavorite = manga.favorite,
|
||||
url = manga.thumbnailUrl,
|
||||
ogUrl = manga.thumbnailUrl,
|
||||
lastModified = manga.coverLastModified,
|
||||
),
|
||||
coverAlpha = if (manga.favorite) CommonMangaItemDefaults.BrowseFavoriteCoverAlpha else 1f,
|
||||
|
||||
@@ -79,7 +79,7 @@ private fun BrowseSourceListItem(
|
||||
mangaId = manga.id,
|
||||
sourceId = manga.source,
|
||||
isMangaFavorite = manga.favorite,
|
||||
url = manga.thumbnailUrl,
|
||||
ogUrl = manga.thumbnailUrl,
|
||||
lastModified = manga.coverLastModified,
|
||||
),
|
||||
coverAlpha = if (manga.favorite) CommonMangaItemDefaults.BrowseFavoriteCoverAlpha else 1f,
|
||||
|
||||
@@ -103,7 +103,7 @@ class HistoryScreenModelStateProvider : PreviewParameterProvider<HistoryScreenMo
|
||||
mangaId = Random.nextLong(),
|
||||
sourceId = Random.nextLong(),
|
||||
isMangaFavorite = Random.nextBoolean(),
|
||||
url = "https://example.com/cover.png",
|
||||
ogUrl = "https://example.com/cover.png",
|
||||
lastModified = Random.nextLong(),
|
||||
),
|
||||
),
|
||||
|
||||
+3
-3
@@ -20,7 +20,7 @@ internal class HistoryWithRelationsProvider : PreviewParameterProvider<HistoryWi
|
||||
mangaId = 3L,
|
||||
sourceId = 4L,
|
||||
isMangaFavorite = false,
|
||||
url = "https://example.com/cover.png",
|
||||
ogUrl = "https://example.com/cover.png",
|
||||
lastModified = 5L,
|
||||
),
|
||||
)
|
||||
@@ -39,7 +39,7 @@ internal class HistoryWithRelationsProvider : PreviewParameterProvider<HistoryWi
|
||||
mangaId = 3L,
|
||||
sourceId = 4L,
|
||||
isMangaFavorite = false,
|
||||
url = "https://example.com/cover.png",
|
||||
ogUrl = "https://example.com/cover.png",
|
||||
lastModified = 5L,
|
||||
),
|
||||
)
|
||||
@@ -58,7 +58,7 @@ internal class HistoryWithRelationsProvider : PreviewParameterProvider<HistoryWi
|
||||
mangaId = 3L,
|
||||
sourceId = 4L,
|
||||
isMangaFavorite = false,
|
||||
url = "https://example.com/cover.png",
|
||||
ogUrl = "https://example.com/cover.png",
|
||||
lastModified = 5L,
|
||||
),
|
||||
)
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ internal fun LibraryComfortableGrid(
|
||||
mangaId = manga.id,
|
||||
sourceId = manga.source,
|
||||
isMangaFavorite = manga.favorite,
|
||||
url = manga.thumbnailUrl,
|
||||
ogUrl = manga.thumbnailUrl,
|
||||
lastModified = manga.coverLastModified,
|
||||
),
|
||||
coverBadgeStart = {
|
||||
|
||||
@@ -42,7 +42,7 @@ internal fun LibraryCompactGrid(
|
||||
mangaId = manga.id,
|
||||
sourceId = manga.source,
|
||||
isMangaFavorite = manga.favorite,
|
||||
url = manga.thumbnailUrl,
|
||||
ogUrl = manga.thumbnailUrl,
|
||||
lastModified = manga.coverLastModified,
|
||||
),
|
||||
coverBadgeStart = {
|
||||
|
||||
@@ -51,7 +51,7 @@ internal fun LibraryList(
|
||||
mangaId = manga.id,
|
||||
sourceId = manga.source,
|
||||
isMangaFavorite = manga.favorite,
|
||||
url = manga.thumbnailUrl,
|
||||
ogUrl = manga.thumbnailUrl,
|
||||
lastModified = manga.coverLastModified,
|
||||
),
|
||||
badge = {
|
||||
|
||||
+1
@@ -140,6 +140,7 @@ private fun Manga.toBackupManga(/* SY --> */customMangaInfo: CustomMangaInfo?/*
|
||||
backupManga.customTitle = it.title
|
||||
backupManga.customArtist = it.artist
|
||||
backupManga.customAuthor = it.author
|
||||
backupManga.customThumbnailUrl = it.thumbnailUrl
|
||||
backupManga.customDescription = it.description
|
||||
backupManga.customGenre = it.genre
|
||||
backupManga.customStatus = it.status?.toInt() ?: 0
|
||||
|
||||
@@ -45,6 +45,7 @@ data class BackupManga(
|
||||
@ProtoNumber(600) var mergedMangaReferences: List<BackupMergedMangaReference> = emptyList(),
|
||||
@ProtoNumber(601) var flatMetadata: BackupFlatMetadata? = null,
|
||||
@ProtoNumber(602) var customStatus: Int = 0,
|
||||
@ProtoNumber(603) var customThumbnailUrl: String? = null,
|
||||
|
||||
// J2K specific values
|
||||
@ProtoNumber(800) var customTitle: String? = null,
|
||||
@@ -53,6 +54,7 @@ data class BackupManga(
|
||||
// skipping 803 due to using duplicate value in previous builds
|
||||
@ProtoNumber(804) var customDescription: String? = null,
|
||||
@ProtoNumber(805) var customGenre: List<String>? = null,
|
||||
|
||||
) {
|
||||
fun getMangaImpl(): Manga {
|
||||
return Manga.create().copy(
|
||||
@@ -61,11 +63,11 @@ data class BackupManga(
|
||||
ogTitle = this@BackupManga.title,
|
||||
ogArtist = this@BackupManga.artist,
|
||||
ogAuthor = this@BackupManga.author,
|
||||
ogThumbnailUrl = this@BackupManga.thumbnailUrl,
|
||||
ogDescription = this@BackupManga.description,
|
||||
ogGenre = this@BackupManga.genre,
|
||||
ogStatus = this@BackupManga.status.toLong(),
|
||||
// SY <--
|
||||
thumbnailUrl = this@BackupManga.thumbnailUrl,
|
||||
favorite = this@BackupManga.favorite,
|
||||
source = this@BackupManga.source,
|
||||
dateAdded = this@BackupManga.dateAdded,
|
||||
|
||||
+3
-1
@@ -120,7 +120,7 @@ class MangaRestorer(
|
||||
ogArtist = newer.artist,
|
||||
ogDescription = newer.description,
|
||||
ogGenre = newer.genre,
|
||||
thumbnailUrl = newer.thumbnailUrl,
|
||||
ogThumbnailUrl = newer.thumbnailUrl,
|
||||
ogStatus = newer.status,
|
||||
// SY <--
|
||||
initialized = this.initialized || newer.initialized,
|
||||
@@ -507,6 +507,7 @@ class MangaRestorer(
|
||||
if (customTitle != null ||
|
||||
customArtist != null ||
|
||||
customAuthor != null ||
|
||||
customThumbnailUrl != null ||
|
||||
customDescription != null ||
|
||||
customGenre != null ||
|
||||
customStatus != 0
|
||||
@@ -516,6 +517,7 @@ class MangaRestorer(
|
||||
title = customTitle,
|
||||
author = customAuthor,
|
||||
artist = customArtist,
|
||||
thumbnailUrl = customThumbnailUrl,
|
||||
description = customDescription,
|
||||
genre = customGenre,
|
||||
status = customStatus.takeUnless { it == 0 }?.toLong(),
|
||||
|
||||
@@ -729,6 +729,7 @@ class LibraryScreenModel(
|
||||
title = editedTitle.nullIfBlank(),
|
||||
author = manga.author.takeUnless { it == manga.ogAuthor },
|
||||
artist = manga.artist.takeUnless { it == manga.ogArtist },
|
||||
thumbnailUrl = manga.thumbnailUrl.takeUnless { it == manga.ogThumbnailUrl },
|
||||
description = manga.description.takeUnless { it == manga.ogDescription },
|
||||
genre = manga.genre.takeUnless { it == manga.ogGenre },
|
||||
status = manga.status.takeUnless { it == manga.ogStatus }?.toLong(),
|
||||
|
||||
@@ -50,6 +50,7 @@ fun EditMangaDialog(
|
||||
title: String?,
|
||||
author: String?,
|
||||
artist: String?,
|
||||
thumbnailUrl: String?,
|
||||
description: String?,
|
||||
tags: List<String>?,
|
||||
status: Long?,
|
||||
@@ -69,6 +70,7 @@ fun EditMangaDialog(
|
||||
binding.title.text.toString(),
|
||||
binding.mangaAuthor.text.toString(),
|
||||
binding.mangaArtist.text.toString(),
|
||||
binding.thumbnailUrl.text.toString(),
|
||||
binding.mangaDescription.text.toString(),
|
||||
binding.mangaGenresTags.getTextStrings(),
|
||||
binding.status.selectedItemPosition.let {
|
||||
@@ -157,6 +159,7 @@ private fun onViewCreated(manga: Manga, context: Context, binding: EditMangaDial
|
||||
binding.title.hint = context.stringResource(SYMR.strings.title_hint, manga.url)
|
||||
binding.mangaAuthor.setText(manga.author.orEmpty())
|
||||
binding.mangaArtist.setText(manga.artist.orEmpty())
|
||||
binding.thumbnailUrl.setText(manga.thumbnailUrl.orEmpty())
|
||||
binding.mangaDescription.setText(manga.description.orEmpty())
|
||||
binding.mangaGenresTags.setChips(manga.genre.orEmpty().dropBlank(), scope)
|
||||
} else {
|
||||
@@ -169,12 +172,16 @@ private fun onViewCreated(manga: Manga, context: Context, binding: EditMangaDial
|
||||
if (manga.artist != manga.ogArtist) {
|
||||
binding.mangaArtist.append(manga.artist.orEmpty())
|
||||
}
|
||||
if (manga.thumbnailUrl != manga.ogThumbnailUrl) {
|
||||
binding.thumbnailUrl.append(manga.thumbnailUrl.orEmpty())
|
||||
}
|
||||
if (manga.description != manga.ogDescription) {
|
||||
binding.mangaDescription.append(manga.description.orEmpty())
|
||||
}
|
||||
binding.mangaGenresTags.setChips(manga.genre.orEmpty().dropBlank(), scope)
|
||||
|
||||
binding.title.hint = context.stringResource(SYMR.strings.title_hint, manga.ogTitle)
|
||||
|
||||
binding.mangaAuthor.hint = context.stringResource(SYMR.strings.author_hint, manga.ogAuthor ?: "")
|
||||
binding.mangaArtist.hint = context.stringResource(SYMR.strings.artist_hint, manga.ogArtist ?: "")
|
||||
binding.mangaDescription.hint =
|
||||
@@ -182,6 +189,13 @@ private fun onViewCreated(manga: Manga, context: Context, binding: EditMangaDial
|
||||
SYMR.strings.description_hint,
|
||||
manga.ogDescription?.takeIf { it.isNotBlank() }?.let { it.replace("\n", " ").chop(20) } ?: ""
|
||||
)
|
||||
binding.thumbnailUrl.hint =
|
||||
context.stringResource(
|
||||
SYMR.strings.thumbnail_url_hint,
|
||||
manga.ogThumbnailUrl?.let {
|
||||
it.chop(40) + if (it.length > 46) "." + it.substringAfterLast(".").chop(6) else ""
|
||||
} ?: ""
|
||||
)
|
||||
}
|
||||
binding.mangaGenresTags.clearFocus()
|
||||
|
||||
|
||||
@@ -488,6 +488,7 @@ class MangaScreenModel(
|
||||
title: String?,
|
||||
author: String?,
|
||||
artist: String?,
|
||||
thumbnailUrl: String?,
|
||||
description: String?,
|
||||
tags: List<String>?,
|
||||
status: Long?,
|
||||
@@ -498,11 +499,13 @@ class MangaScreenModel(
|
||||
val newTitle = if (title.isNullOrBlank()) manga.url else title.trim()
|
||||
val newAuthor = author?.trimOrNull()
|
||||
val newArtist = artist?.trimOrNull()
|
||||
val newThumbnailUrl = thumbnailUrl?.trimOrNull()
|
||||
val newDesc = description?.trimOrNull()
|
||||
manga = manga.copy(
|
||||
ogTitle = newTitle,
|
||||
ogAuthor = author?.trimOrNull(),
|
||||
ogArtist = artist?.trimOrNull(),
|
||||
ogThumbnailUrl = thumbnailUrl?.trimOrNull(),
|
||||
ogDescription = description?.trimOrNull(),
|
||||
ogGenre = tags?.nullIfEmpty(),
|
||||
ogStatus = status ?: 0,
|
||||
@@ -516,6 +519,7 @@ class MangaScreenModel(
|
||||
title = newTitle,
|
||||
author = newAuthor,
|
||||
artist = newArtist,
|
||||
thumbnailUrl = newThumbnailUrl,
|
||||
description = newDesc,
|
||||
genre = tags,
|
||||
status = status,
|
||||
@@ -534,6 +538,7 @@ class MangaScreenModel(
|
||||
title?.trimOrNull(),
|
||||
author?.trimOrNull(),
|
||||
artist?.trimOrNull(),
|
||||
thumbnailUrl?.trimOrNull(),
|
||||
description?.trimOrNull(),
|
||||
genre,
|
||||
status.takeUnless { it == state.manga.ogStatus },
|
||||
|
||||
Reference in New Issue
Block a user