Skip to content

Commit

Permalink
Add custom thumbnail url. Support backup & restore
Browse files Browse the repository at this point in the history
- add custom thumbnail url in edit info/custom
- include it in backup n restore
  • Loading branch information
Riztard committed Jan 29, 2024
1 parent 7e151dd commit 19b2dc1
Show file tree
Hide file tree
Showing 17 changed files with 64 additions and 12 deletions.
6 changes: 3 additions & 3 deletions app/src/main/java/eu/kanade/domain/manga/model/Manga.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,22 @@ 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()
} else {
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 <--
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,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,
@ProtoNumber(806) var customThumbnailUrl: String? = null,

// Neko specific values
@ProtoNumber(901) var filtered_scanlators: String? = null,
Expand All @@ -63,11 +64,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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,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,
Expand Down Expand Up @@ -504,6 +504,7 @@ class MangaRestorer(
if (customTitle != null ||
customArtist != null ||
customAuthor != null ||
customThumbnailUrl != null ||
customDescription != null ||
customGenre != null ||
customStatus != 0
Expand All @@ -513,6 +514,7 @@ class MangaRestorer(
title = customTitle,
author = customAuthor,
artist = customArtist,
thumbnailUrl = customThumbnailUrl,
description = customDescription,
genre = customGenre,
status = customStatus.takeUnless { it == 0 }?.toLong(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/eu/kanade/tachiyomi/ui/manga/EditMangaDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ fun EditMangaDialog(
title: String?,
author: String?,
artist: String?,
thumbnailUrl: String?,
description: String?,
tags: List<String>?,
status: Long?,
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -169,6 +172,9 @@ 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())
}
Expand All @@ -181,6 +187,13 @@ private fun onViewCreated(manga: Manga, context: Context, binding: EditMangaDial
if (manga.ogArtist != null) {
binding.mangaArtist.hint = context.stringResource(SYMR.strings.artist_hint, manga.ogArtist!!)
}
if (manga.ogThumbnailUrl != null) {
binding.thumbnailUrl.hint =
context.stringResource(
SYMR.strings.thumbnail_url_hint,
manga.ogThumbnailUrl!!.chop(30) + "." + manga.ogThumbnailUrl!!.substringAfterLast(".").chop(6)
)
}
if (!manga.ogDescription.isNullOrBlank()) {
binding.mangaDescription.hint =
context.stringResource(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ class MangaScreenModel(
title: String?,
author: String?,
artist: String?,
thumbnailUrl: String?,
description: String?,
tags: List<String>?,
status: Long?,
Expand All @@ -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,
Expand All @@ -516,6 +519,7 @@ class MangaScreenModel(
title = newTitle,
author = newAuthor,
artist = newArtist,
thumbnailUrl = newThumbnailUrl,
description = newDesc,
genre = tags,
status = status,
Expand All @@ -534,6 +538,7 @@ class MangaScreenModel(
title?.trimOrNull(),
author?.trimOrNull(),
artist?.trimOrNull(),
thumbnailUrl?.trimOrNull(),
description?.trimOrNull(),
genre,
status.takeUnless { it == state.manga.ogStatus },
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/res/layout/edit_manga_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,22 @@

</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp">

<eu.kanade.tachiyomi.widget.TachiyomiTextInputEditText
android:id="@+id/thumbnail_url"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text|textMultiLine"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />

</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class CustomMangaRepositoryImpl(context: Context) : CustomMangaRepository {
mangaInfo.title == null &&
mangaInfo.author == null &&
mangaInfo.artist == null &&
mangaInfo.thumbnailUrl == null &&
mangaInfo.description == null &&
mangaInfo.genre == null &&
mangaInfo.status == null
Expand Down Expand Up @@ -72,6 +73,7 @@ class CustomMangaRepositoryImpl(context: Context) : CustomMangaRepository {
val title: String? = null,
val author: String? = null,
val artist: String? = null,
val thumbnailUrl: String? = null,
val description: String? = null,
val genre: List<String>? = null,
val status: Long? = null,
Expand All @@ -82,6 +84,7 @@ class CustomMangaRepositoryImpl(context: Context) : CustomMangaRepository {
title = this@MangaJson.title?.takeUnless { it.isBlank() },
author = this@MangaJson.author,
artist = this@MangaJson.artist,
thumbnailUrl = this@MangaJson.thumbnailUrl,
description = this@MangaJson.description,
genre = this@MangaJson.genre,
status = this@MangaJson.status?.takeUnless { it == 0L },
Expand All @@ -94,6 +97,7 @@ class CustomMangaRepositoryImpl(context: Context) : CustomMangaRepository {
title,
author,
artist,
thumbnailUrl,
description,
genre,
status,
Expand Down
4 changes: 2 additions & 2 deletions data/src/main/java/tachiyomi/data/manga/MangaMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ object MangaMapper {
ogTitle = title,
ogArtist = artist,
ogAuthor = author,
ogThumbnailUrl = thumbnailUrl,
ogDescription = description,
ogGenre = genre,
ogStatus = status,
// SY <--
thumbnailUrl = thumbnailUrl,
updateStrategy = updateStrategy,
initialized = initialized,
lastModifiedAt = lastModifiedAt,
Expand Down Expand Up @@ -150,7 +150,7 @@ object MangaMapper {
ogDescription = libraryView.description,
ogGenre = libraryView.genre,
ogStatus = libraryView.status,
thumbnailUrl = libraryView.thumbnail_url,
ogThumbnailUrl = libraryView.thumbnail_url,
updateStrategy = libraryView.update_strategy,
initialized = libraryView.initialized,
fetchInterval = libraryView.calculate_interval.toInt(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ data class CustomMangaInfo(
val title: String?,
val author: String? = null,
val artist: String? = null,
val thumbnailUrl: String? = null,
val description: String? = null,
val genre: List<String>? = null,
val status: Long? = null,
Expand Down
7 changes: 5 additions & 2 deletions domain/src/main/java/tachiyomi/domain/manga/model/Manga.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ data class Manga(
val ogTitle: String,
val ogArtist: String?,
val ogAuthor: String?,
val ogThumbnailUrl: String?,
val ogDescription: String?,
val ogGenre: List<String>?,
val ogStatus: Long,
// SY <--
val thumbnailUrl: String?,
val updateStrategy: UpdateStrategy,
val initialized: Boolean,
val lastModifiedAt: Long,
Expand All @@ -51,6 +51,9 @@ data class Manga(
val artist: String?
get() = customMangaInfo?.artist ?: ogArtist

val thumbnailUrl: String?
get() = customMangaInfo?.thumbnailUrl ?: ogThumbnailUrl

val description: String?
get() = customMangaInfo?.description ?: ogDescription

Expand Down Expand Up @@ -147,11 +150,11 @@ data class Manga(
// SY -->
ogArtist = null,
ogAuthor = null,
ogThumbnailUrl = null,
ogDescription = null,
ogGenre = null,
ogStatus = 0L,
// SY <--
thumbnailUrl = null,
updateStrategy = UpdateStrategy.ALWAYS_UPDATE,
initialized = false,
lastModifiedAt = 0L,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ fun Manga.toMangaUpdate(): MangaUpdate {
title = ogTitle,
artist = ogArtist,
author = ogAuthor,
thumbnailUrl = ogThumbnailUrl,
description = ogDescription,
genre = ogGenre,
status = ogStatus,
// SY <--
thumbnailUrl = thumbnailUrl,
updateStrategy = updateStrategy,
initialized = initialized,
)
Expand Down
1 change: 1 addition & 0 deletions i18n-sy/src/commonMain/resources/MR/base/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@
<string name="description_hint">Description: %1$s</string>
<string name="author_hint">Author: %1$s</string>
<string name="artist_hint">Artist: %1$s</string>
<string name="thumbnail_url_hint">Thumbnail Url: %1$s</string>

<!-- Browse -->
<!-- Sources Tab -->
Expand Down
1 change: 1 addition & 0 deletions i18n-sy/src/commonMain/resources/MR/in/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@
<string name="description_hint">Deskripsi: %1$s</string>
<string name="author_hint">Author: %1$s</string>
<string name="artist_hint">Artist: %1$s</string>
<string name="thumbnail_url_hint">Thumbnail Url: %1$s</string>

<!-- Browse -->
<!-- Sources Tab -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ interface SManga : Serializable {
val originalTitle: String
val originalAuthor: String?
val originalArtist: String?
val originalThumbnailUrl: String?
val originalDescription: String?
val originalGenre: String?
val originalStatus: Int
Expand All @@ -44,11 +45,11 @@ interface SManga : Serializable {
it.title = originalTitle
it.artist = originalArtist
it.author = originalAuthor
it.thumbnail_url = originalThumbnailUrl
it.description = originalDescription
it.genre = originalGenre
it.status = originalStatus
// SY <--
it.thumbnail_url = thumbnail_url
it.update_strategy = update_strategy
it.initialized = initialized
}
Expand Down Expand Up @@ -103,7 +104,7 @@ fun SManga.copy(
description: String? = this.originalDescription,
genre: String? = this.originalGenre,
status: Int = this.status,
thumbnail_url: String? = this.thumbnail_url,
thumbnail_url: String? = this.originalThumbnailUrl,
initialized: Boolean = this.initialized,
) = SManga.create().also {
it.url = url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class SMangaImpl : SManga {
get() = author
override val originalArtist: String?
get() = artist
override val originalThumbnailUrl: String?
get() = thumbnail_url
override val originalDescription: String?
get() = description
override val originalGenre: String?
Expand Down

0 comments on commit 19b2dc1

Please sign in to comment.