新版本自动更新在线朗读规则

pull/783/head
gedoor 4 years ago
parent 61b13a70c3
commit d241fd410d
  1. 6
      app/src/main/java/io/legado/app/help/DefaultData.kt
  2. 6
      app/src/main/java/io/legado/app/help/LocalConfig.kt
  3. 4
      app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineViewModel.kt
  4. 6
      app/src/main/java/io/legado/app/ui/main/MainViewModel.kt

@ -45,6 +45,12 @@ object DefaultData {
GSON.fromJsonArray<ThemeConfig.Config>(json)!! GSON.fromJsonArray<ThemeConfig.Config>(json)!!
} }
fun importDefaultHttpTTS() {
httpTTS.let {
App.db.httpTTSDao.insert(*it.toTypedArray())
}
}
fun importDefaultTocRules() { fun importDefaultTocRules() {
App.db.txtTocRule.deleteDefault() App.db.txtTocRule.deleteDefault()
txtTocRules.let { txtTocRules.let {

@ -63,4 +63,10 @@ object LocalConfig {
val ruleHelpVersionIsLast: Boolean val ruleHelpVersionIsLast: Boolean
get() = isLastVersion(1, "ruleHelpVersion") get() = isLastVersion(1, "ruleHelpVersion")
val hasUpHttpTTS: Boolean
get() = isLastVersion(1, "httpTtsVersion")
val hasUpTxtTocRule: Boolean
get() = isLastVersion(1, "txtTocRuleVersion")
} }

@ -14,9 +14,7 @@ class SpeakEngineViewModel(application: Application) : BaseViewModel(application
fun importDefault() { fun importDefault() {
execute { execute {
DefaultData.httpTTS.let { DefaultData.importDefaultHttpTTS()
App.db.httpTTSDao.insert(*it.toTypedArray())
}
} }
} }

@ -9,6 +9,7 @@ import io.legado.app.data.entities.Book
import io.legado.app.help.AppConfig import io.legado.app.help.AppConfig
import io.legado.app.help.BookHelp import io.legado.app.help.BookHelp
import io.legado.app.help.DefaultData import io.legado.app.help.DefaultData
import io.legado.app.help.LocalConfig
import io.legado.app.model.webBook.WebBook import io.legado.app.model.webBook.WebBook
import io.legado.app.service.help.CacheBook import io.legado.app.service.help.CacheBook
import io.legado.app.utils.FileUtils import io.legado.app.utils.FileUtils
@ -148,7 +149,12 @@ class MainViewModel(application: Application) : BaseViewModel(application) {
fun upVersion() { fun upVersion() {
execute { execute {
if (LocalConfig.hasUpHttpTTS) {
DefaultData.importDefaultHttpTTS()
}
if (LocalConfig.hasUpTxtTocRule) {
DefaultData.importDefaultTocRules() DefaultData.importDefaultTocRules()
} }
} }
}
} }
Loading…
Cancel
Save