diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt
index de28caddc..f4e902ba0 100644
--- a/app/src/main/java/io/legado/app/constant/PreferKey.kt
+++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt
@@ -64,6 +64,7 @@ object PreferKey {
const val importKeepName = "importKeepName"
const val screenOrientation = "screenOrientation"
const val syncBookProgress = "syncBookProgress"
+ const val preDownload = "preDownload"
const val cPrimary = "colorPrimary"
const val cAccent = "colorAccent"
diff --git a/app/src/main/java/io/legado/app/help/AppConfig.kt b/app/src/main/java/io/legado/app/help/AppConfig.kt
index 076bbfdc4..1c5c10a72 100644
--- a/app/src/main/java/io/legado/app/help/AppConfig.kt
+++ b/app/src/main/java/io/legado/app/help/AppConfig.kt
@@ -149,6 +149,8 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
val syncBookProgress get() = context.getPrefBoolean(PreferKey.syncBookProgress, true)
+ val preDownload get() = context.getPrefBoolean(PreferKey.preDownload, true)
+
private fun getPrefUserAgent(): String {
val ua = context.getPrefString(PreferKey.userAgent)
if (ua.isNullOrBlank()) {
diff --git a/app/src/main/java/io/legado/app/service/help/ReadBook.kt b/app/src/main/java/io/legado/app/service/help/ReadBook.kt
index 3a331ab33..c76386bd6 100644
--- a/app/src/main/java/io/legado/app/service/help/ReadBook.kt
+++ b/app/src/main/java/io/legado/app/service/help/ReadBook.kt
@@ -133,10 +133,12 @@ object ReadBook {
callBack?.upContent()
}
loadContent(durChapterIndex.plus(1), upContent, false)
- GlobalScope.launch(Dispatchers.IO) {
- for (i in 2..10) {
- delay(100)
- download(durChapterIndex + i)
+ if (AppConfig.preDownload) {
+ GlobalScope.launch(Dispatchers.IO) {
+ for (i in 2..9) {
+ delay(1000)
+ download(durChapterIndex + i)
+ }
}
}
}
@@ -163,10 +165,12 @@ object ReadBook {
callBack?.upContent()
}
loadContent(durChapterIndex.minus(1), upContent, false)
- GlobalScope.launch(Dispatchers.IO) {
- for (i in -5..-2) {
- delay(100)
- download(durChapterIndex + i)
+ if (AppConfig.preDownload) {
+ GlobalScope.launch(Dispatchers.IO) {
+ for (i in 2..9) {
+ delay(1000)
+ download(durChapterIndex - i)
+ }
}
}
}
diff --git a/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt b/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt
index eea5da5e1..88969fe5d 100644
--- a/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt
+++ b/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt
@@ -81,7 +81,9 @@ class MainViewModel(application: Application) : BaseViewModel(application) {
App.db.bookDao.update(book)
App.db.bookChapterDao.delByBook(book.bookUrl)
App.db.bookChapterDao.insert(*it.toTypedArray())
- cacheBook(webBook, book)
+ if (AppConfig.preDownload) {
+ cacheBook(webBook, book)
+ }
}
.onError {
it.printStackTrace()
diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml
index 44ad0524b..63f2ec2e1 100644
--- a/app/src/main/res/values-zh-rHK/strings.xml
+++ b/app/src/main/res/values-zh-rHK/strings.xml
@@ -797,5 +797,7 @@
单URL
导出书单
导入书单
+ 预下载
+ 预先下载10章正文
diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml
index 04601c9a6..af90b7f86 100644
--- a/app/src/main/res/values-zh-rTW/strings.xml
+++ b/app/src/main/res/values-zh-rTW/strings.xml
@@ -798,5 +798,7 @@
单URL
导出书单
导入书单
+ 预下载
+ 预先下载10章正文
diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml
index e42728e52..48eb53cb6 100644
--- a/app/src/main/res/values-zh/strings.xml
+++ b/app/src/main/res/values-zh/strings.xml
@@ -801,5 +801,7 @@
单URL
导出书单
导入书单
+ 预下载
+ 预先下载10章正文
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 70fa7277b..d2c078fec 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -804,5 +804,7 @@
单URL
导出书单
导入书单
+ 预下载
+ 预先下载10章正文
diff --git a/app/src/main/res/xml/pref_config_other.xml b/app/src/main/res/xml/pref_config_other.xml
index 7077d665b..c3439baf8 100644
--- a/app/src/main/res/xml/pref_config_other.xml
+++ b/app/src/main/res/xml/pref_config_other.xml
@@ -55,6 +55,12 @@
android:key="userAgent"
android:title="UserAgent" />
+
+