From 54f421df3793d35595fdbf3e32b30e5360f71972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C9=91rry=20Shiv=C9=91m?= Date: Fri, 9 Feb 2024 21:34:35 +0530 Subject: [PATCH] Fix crash due to title tag missing in OPF index (#109) * Fix crash due to title tag missing in OPF index * Show full title in chapters screen of e-book reader --------- Signed-off-by: starry-shivam --- app/src/main/java/com/starry/myne/epub/EpubParser.kt | 6 ++---- app/src/main/java/com/starry/myne/repo/BookRepository.kt | 1 - .../ui/screens/reader/composables/ReaderDetailScreen.kt | 2 -- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/starry/myne/epub/EpubParser.kt b/app/src/main/java/com/starry/myne/epub/EpubParser.kt index 31a99852..444c5f4e 100644 --- a/app/src/main/java/com/starry/myne/epub/EpubParser.kt +++ b/app/src/main/java/com/starry/myne/epub/EpubParser.kt @@ -47,9 +47,7 @@ data class EpubFile(val absPath: String, val data: ByteArray) { other as EpubFile if (absPath != other.absPath) return false - if (!data.contentEquals(other.data)) return false - - return true + return data.contentEquals(other.data) } override fun hashCode(): Int { @@ -95,7 +93,7 @@ private suspend fun parseAndCreateEpubBook(inputStream: FileInputStream): EpubBo ?: throw Exception(".opf file spine section missing") val metadataTitle = metadata.selectFirstChildTag("dc:title")?.textContent - ?: throw Exception(".opf metadata title tag missing") + ?: "Unknown Title" val metadataCoverId = metadata .selectChildTag("meta") diff --git a/app/src/main/java/com/starry/myne/repo/BookRepository.kt b/app/src/main/java/com/starry/myne/repo/BookRepository.kt index db1a673f..cd1be50c 100644 --- a/app/src/main/java/com/starry/myne/repo/BookRepository.kt +++ b/app/src/main/java/com/starry/myne/repo/BookRepository.kt @@ -111,7 +111,6 @@ class BookRepository { suspend fun getExtraInfo(bookName: String): ExtraInfo? = suspendCoroutine { continuation -> val encodedName = URLEncoder.encode(bookName, "UTF-8") val url = "${googleBooksUrl}?q=$encodedName&startIndex=0&maxResults=1&key=$googleApiKey" - println(url) val request = Request.Builder().get().url(url).build() okHttpClient.newCall(request).enqueue(object : Callback { override fun onFailure(call: Call, e: IOException) { diff --git a/app/src/main/java/com/starry/myne/ui/screens/reader/composables/ReaderDetailScreen.kt b/app/src/main/java/com/starry/myne/ui/screens/reader/composables/ReaderDetailScreen.kt index c5584412..434d8a0e 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/reader/composables/ReaderDetailScreen.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/reader/composables/ReaderDetailScreen.kt @@ -242,8 +242,6 @@ fun ReaderDetailScreen( fontSize = 24.sp, fontFamily = figeronaFont, fontWeight = FontWeight.Bold, - maxLines = 2, - overflow = TextOverflow.Ellipsis, color = MaterialTheme.colorScheme.onBackground, )