From aa95743d1cb9c1171bfc875d12e0daafc8f72fdc Mon Sep 17 00:00:00 2001
From: Patrick Loser <69157453+CD-Z@users.noreply.github.com>
Date: Tue, 25 Jun 2024 15:20:47 +0200
Subject: [PATCH 1/3] Fix: hide progressbar on opening drawer (#1102)
---
src/screens/reader/ReaderScreen.tsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/screens/reader/ReaderScreen.tsx b/src/screens/reader/ReaderScreen.tsx
index ad77a638a..89e5d1eb8 100644
--- a/src/screens/reader/ReaderScreen.tsx
+++ b/src/screens/reader/ReaderScreen.tsx
@@ -291,8 +291,8 @@ export const ChapterContent = ({
const openDrawer = useCallback(() => {
drawerRef.current?.openDrawer();
- setHidden(true);
- }, [drawerRef]);
+ hideHeader();
+ }, [drawerRef, hideHeader]);
if (loading) {
return ;
From 70220a5a8780f5bbd00030cfc318829c74eb2463 Mon Sep 17 00:00:00 2001
From: r1di <33724815+r1di@users.noreply.github.com>
Date: Tue, 25 Jun 2024 15:48:10 +0200
Subject: [PATCH 2/3] Fix: Volume scrolling (#1114)
* Volume scrolling fix
the scrolling by volume button right now scrolls 100% of the screen, which hides text when scrolled so, the commit is just changing the the scrolling to 50%.
* typo
* 50% to 75% scroll
---------
Co-authored-by: Ridi
---
src/screens/reader/ReaderScreen.tsx | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/screens/reader/ReaderScreen.tsx b/src/screens/reader/ReaderScreen.tsx
index 89e5d1eb8..b526e96fe 100644
--- a/src/screens/reader/ReaderScreen.tsx
+++ b/src/screens/reader/ReaderScreen.tsx
@@ -132,15 +132,16 @@ export const ChapterContent = ({
VolumeButtonListener.preventDefault();
emmiter.current.addListener('VolumeUp', () => {
webViewRef.current?.injectJavaScript(`(()=>{
- window.scrollBy({top:${-Dimensions.get('window')
- .height},behavior:'smooth',})
+ window.scrollBy({top: -${
+ Dimensions.get('window').height * 0.75
+ }, behavior: 'smooth'})
})()`);
});
emmiter.current.addListener('VolumeDown', () => {
webViewRef.current?.injectJavaScript(`(()=>{
- window.scrollBy({top:${
- Dimensions.get('window').height
- },behavior:'smooth',})
+ window.scrollBy({top: ${
+ Dimensions.get('window').height * 0.75
+ }, behavior: 'smooth'})
})()`);
});
};
From 9b4bdfea894d8de3b6255ed83e51027623b45a15 Mon Sep 17 00:00:00 2001
From: nyagami
Date: Thu, 27 Jun 2024 16:04:50 +0700
Subject: [PATCH 3/3] Merge epub chapters (#1117)
* Fix: ignore non existed files
* merge chapters & scan cover
* remove unused tocMap
* clean code
---
.../EpubUtil/ChapterEntry.kt | 3 ++
.../rajarsheechatterjee/EpubUtil/EpubUtil.kt | 46 ++++++++++++++-----
2 files changed, 38 insertions(+), 11 deletions(-)
create mode 100644 android/app/src/main/java/com/rajarsheechatterjee/EpubUtil/ChapterEntry.kt
diff --git a/android/app/src/main/java/com/rajarsheechatterjee/EpubUtil/ChapterEntry.kt b/android/app/src/main/java/com/rajarsheechatterjee/EpubUtil/ChapterEntry.kt
new file mode 100644
index 000000000..730b82629
--- /dev/null
+++ b/android/app/src/main/java/com/rajarsheechatterjee/EpubUtil/ChapterEntry.kt
@@ -0,0 +1,3 @@
+package com.rajarsheechatterjee.EpubUtil
+
+class ChapterEntry (val name: String, val href: String)
\ No newline at end of file
diff --git a/android/app/src/main/java/com/rajarsheechatterjee/EpubUtil/EpubUtil.kt b/android/app/src/main/java/com/rajarsheechatterjee/EpubUtil/EpubUtil.kt
index bcce9acba..611dfe1f5 100644
--- a/android/app/src/main/java/com/rajarsheechatterjee/EpubUtil/EpubUtil.kt
+++ b/android/app/src/main/java/com/rajarsheechatterjee/EpubUtil/EpubUtil.kt
@@ -37,7 +37,7 @@ class EpubUtil(context: ReactApplicationContext) : ReactContextBaseJavaModule(co
}
private fun cleanUrl(url: String): String {
- return url.replaceFirst("#[^.]+?$", "")
+ return url.replaceFirst("#[^.]+?$".toRegex(), "")
}
@ReactMethod
@@ -69,11 +69,11 @@ class EpubUtil(context: ReactApplicationContext) : ReactContextBaseJavaModule(co
val chapters: WritableArray = WritableNativeArray()
val parser = initParse(file)
val refMap = HashMap()
- val tocMap = HashMap()
+ val entryList = mutableListOf()
val tocFile = File(contentDir, "toc.ncx")
if (tocFile.exists()) {
val tocParser = initParse(tocFile)
- var label: String? = null
+ var label = ""
while (tocParser.next() != XmlPullParser.END_DOCUMENT) {
val tag = tocParser.name
if (tag != null) {
@@ -81,12 +81,18 @@ class EpubUtil(context: ReactApplicationContext) : ReactContextBaseJavaModule(co
label = readText(tocParser)
} else if (tag == "content") {
val href = cleanUrl(tocParser.getAttributeValue(null, "src"))
- tocMap[href] = label
+ if(label.isNotBlank()){
+ entryList.add(ChapterEntry(name = label, href = href))
+ }
+ label = ""
}
}
}
+ }else{
+ throw Error("Table of content doesn't exist!")
}
var cover: String? = null
+ var entryIndex = 0;
while (parser.next() != XmlPullParser.END_DOCUMENT) {
val tag = parser.name
if (tag != null) {
@@ -98,16 +104,21 @@ class EpubUtil(context: ReactApplicationContext) : ReactContextBaseJavaModule(co
refMap[id] = href
}
}
-
"itemref" -> {
val idRef = parser.getAttributeValue(null, "idref")
val href = refMap[idRef]
- if (href != null) {
- val chapter: WritableMap = WritableNativeMap()
- chapter.putString("path", "$contentDir/$href")
- val name = tocMap[href]
- chapter.putString("name", name ?: href)
- chapters.pushMap(chapter)
+ val chapterFile = File("$contentDir/$href")
+ if (chapterFile.exists()) {
+ if (entryIndex == 0 || entryIndex < entryList.size && entryList[entryIndex].href == href) {
+ val newChapter = WritableNativeMap()
+ newChapter.putString("path", chapterFile.path)
+ newChapter.putString("name", entryList[entryIndex].name)
+ chapters.pushMap(newChapter)
+ entryIndex += 1
+ }else{
+ // merge to previous entry
+ File("$contentDir/${entryList[entryIndex - 1].href}").appendBytes(chapterFile.readBytes())
+ }
}
}
@@ -128,6 +139,19 @@ class EpubUtil(context: ReactApplicationContext) : ReactContextBaseJavaModule(co
if (cover != null) {
val coverPath = contentDir + "/" + refMap[cover]
novel.putString("cover", coverPath)
+ } else {
+ // try scanning Images dir if exists
+ val imageDir = File("$contentDir/Images")
+ if(imageDir.exists() && imageDir.isDirectory){
+ imageDir.listFiles()?.forEach { img ->
+ if (img.isFile && img.name.lowercase().contains("cover|illus".toRegex())){
+ cover = img.path
+ }
+ }
+ }
+ if (cover != null){
+ novel.putString("cover", cover)
+ }
}
novel.putArray("chapters", chapters)
return novel