diff --git a/app/src/main/java/io/legado/app/help/DefaultData.kt b/app/src/main/java/io/legado/app/help/DefaultData.kt index db14e1f29..b9708ba91 100644 --- a/app/src/main/java/io/legado/app/help/DefaultData.kt +++ b/app/src/main/java/io/legado/app/help/DefaultData.kt @@ -45,6 +45,12 @@ object DefaultData { GSON.fromJsonArray(json)!! } + fun importDefaultHttpTTS() { + httpTTS.let { + App.db.httpTTSDao.insert(*it.toTypedArray()) + } + } + fun importDefaultTocRules() { App.db.txtTocRule.deleteDefault() txtTocRules.let { diff --git a/app/src/main/java/io/legado/app/help/LocalConfig.kt b/app/src/main/java/io/legado/app/help/LocalConfig.kt index 084113293..ac0d3034d 100644 --- a/app/src/main/java/io/legado/app/help/LocalConfig.kt +++ b/app/src/main/java/io/legado/app/help/LocalConfig.kt @@ -63,4 +63,10 @@ object LocalConfig { val ruleHelpVersionIsLast: Boolean get() = isLastVersion(1, "ruleHelpVersion") + + val hasUpHttpTTS: Boolean + get() = isLastVersion(1, "httpTtsVersion") + + val hasUpTxtTocRule: Boolean + get() = isLastVersion(1, "txtTocRuleVersion") } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineViewModel.kt index b72f65343..bfcb8ae2b 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineViewModel.kt @@ -14,9 +14,7 @@ class SpeakEngineViewModel(application: Application) : BaseViewModel(application fun importDefault() { execute { - DefaultData.httpTTS.let { - App.db.httpTTSDao.insert(*it.toTypedArray()) - } + DefaultData.importDefaultHttpTTS() } } 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 239b0c9ff..242e94baa 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 @@ -9,6 +9,7 @@ import io.legado.app.data.entities.Book import io.legado.app.help.AppConfig import io.legado.app.help.BookHelp import io.legado.app.help.DefaultData +import io.legado.app.help.LocalConfig import io.legado.app.model.webBook.WebBook import io.legado.app.service.help.CacheBook import io.legado.app.utils.FileUtils @@ -148,7 +149,12 @@ class MainViewModel(application: Application) : BaseViewModel(application) { fun upVersion() { execute { - DefaultData.importDefaultTocRules() + if (LocalConfig.hasUpHttpTTS) { + DefaultData.importDefaultHttpTTS() + } + if (LocalConfig.hasUpTxtTocRule) { + DefaultData.importDefaultTocRules() + } } } } \ No newline at end of file