diff --git a/app/src/main/java/com/lagradost/quicknovel/BookDownloader2.kt b/app/src/main/java/com/lagradost/quicknovel/BookDownloader2.kt index 29b87ca5..bc90b419 100644 --- a/app/src/main/java/com/lagradost/quicknovel/BookDownloader2.kt +++ b/app/src/main/java/com/lagradost/quicknovel/BookDownloader2.kt @@ -597,7 +597,7 @@ object BookDownloader2Helper { } @WorkerThread - fun turnToEpub(activity: Activity?, author: String?, name: String, apiName: String): Boolean { + fun turnToEpub(activity: Activity?, author: String?, name: String, apiName: String, synopsis: String?): Boolean { if (activity == null) return false if (!activity.checkWrite()) { activity.requestRW() @@ -689,6 +689,11 @@ object BookDownloader2Helper { if (author != null) { metadata.addAuthor(Author(author)) } + + if (synopsis != null) { + metadata.addDescription(synopsis) + } + metadata.addTitle(name) val posterFilepath = @@ -1017,7 +1022,7 @@ object BookDownloader2 { @WorkerThread suspend fun stream(res: EpubResponse, apiName: String) { downloadAsync(res, getApiFromName(apiName)) - readEpub(res.author, res.name, apiName) + readEpub(res.author, res.name, apiName, res.synopsis) } @WorkerThread @@ -1064,20 +1069,20 @@ object BookDownloader2 { } } - private fun generateAndReadEpub(author: String?, name: String, apiName: String) { + private fun generateAndReadEpub(author: String?, name: String, apiName: String, synopsis: String?) { showToast(R.string.generating_epub) - if (!turnToEpub(author, name, apiName)) { + if (!turnToEpub(author, name, apiName, synopsis)) { showToast(R.string.error_loading_novel) return } openEpub(name) } - private fun readEpub(author: String?, name: String, apiName: String) { + private fun readEpub(author: String?, name: String, apiName: String, synopsis: String?) { if (hasEpub(name)) { openEpub(name) } else { - generateAndReadEpub(author, name, apiName) + generateAndReadEpub(author, name, apiName, synopsis) } } @@ -1089,16 +1094,17 @@ object BookDownloader2 { downloadedCount: Int, author: String?, name: String, - apiName: String + apiName: String, + synopsis: String? ) { if (readEpubMutex.isLocked) return readEpubMutex.withLock { val downloaded = getKey(DOWNLOAD_EPUB_SIZE, id.toString(), 0)!! val shouldUpdate = downloadedCount - downloaded != 0 if (shouldUpdate) { - generateAndReadEpub(author, name, apiName) + generateAndReadEpub(author, name, apiName, synopsis) } else { - readEpub(author, name, apiName) + readEpub(author, name, apiName, synopsis) } } } @@ -1138,8 +1144,8 @@ object BookDownloader2 { deleteNovelAsync(author, name, apiName) } - private fun turnToEpub(author: String?, name: String, apiName: String): Boolean { - return BookDownloader2Helper.turnToEpub(activity, author, name, apiName) + private fun turnToEpub(author: String?, name: String, apiName: String, synopsis: String?): Boolean { + return BookDownloader2Helper.turnToEpub(activity, author, name, apiName, synopsis) } private fun hasEpub(name: String): Boolean { @@ -1789,4 +1795,4 @@ object BookDownloader2 { init { initDownloadProgress() } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/lagradost/quicknovel/ui/download/DownloadViewModel.kt b/app/src/main/java/com/lagradost/quicknovel/ui/download/DownloadViewModel.kt index 73157a80..f21a888c 100644 --- a/app/src/main/java/com/lagradost/quicknovel/ui/download/DownloadViewModel.kt +++ b/app/src/main/java/com/lagradost/quicknovel/ui/download/DownloadViewModel.kt @@ -106,7 +106,8 @@ class DownloadViewModel : ViewModel() { card.downloadedCount, card.author, card.name, - card.apiName + card.apiName, + card.synopsis ) } finally { setKey(DOWNLOAD_EPUB_LAST_ACCESS, card.id.toString(), System.currentTimeMillis()) @@ -454,4 +455,4 @@ class DownloadViewModel : ViewModel() { } } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/lagradost/quicknovel/ui/result/ResultViewModel.kt b/app/src/main/java/com/lagradost/quicknovel/ui/result/ResultViewModel.kt index 41a78c0b..9258b522 100644 --- a/app/src/main/java/com/lagradost/quicknovel/ui/result/ResultViewModel.kt +++ b/app/src/main/java/com/lagradost/quicknovel/ui/result/ResultViewModel.kt @@ -168,7 +168,8 @@ class ResultViewModel : ViewModel() { downloadState.value?.progress ?: return@launch, load.author, load.name, - apiName + apiName, + load.synopsis ) } } @@ -533,4 +534,4 @@ class ResultViewModel : ViewModel() { loadResponse.postValue(data) } } -} \ No newline at end of file +}