Skip to content

Commit

Permalink
Fix crash due to title tag missing in OPF index (#109)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
starry-shivam authored Feb 9, 2024
1 parent f92cccc commit 54f421d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 7 deletions.
6 changes: 2 additions & 4 deletions app/src/main/java/com/starry/myne/epub/EpubParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/com/starry/myne/repo/BookRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,6 @@ fun ReaderDetailScreen(
fontSize = 24.sp,
fontFamily = figeronaFont,
fontWeight = FontWeight.Bold,
maxLines = 2,
overflow = TextOverflow.Ellipsis,
color = MaterialTheme.colorScheme.onBackground,
)

Expand Down

0 comments on commit 54f421d

Please sign in to comment.