feat: 添加自动换源配置

pull/209/head
kunfei 5 years ago
parent a7f35e66f8
commit d9224fa389
  1. 2
      app/src/main/java/io/legado/app/help/AppConfig.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt
  3. 1
      app/src/main/res/values/strings.xml
  4. 6
      app/src/main/res/xml/pref_config_read.xml

@ -127,6 +127,8 @@ object AppConfig {
App.INSTANCE.putPrefInt("elevation", value)
}
val autoChangeSource: Boolean get() = App.INSTANCE.getPrefBoolean("autoChangeSource", true)
val readBodyToLh: Boolean get() = App.INSTANCE.getPrefBoolean(PreferKey.readBodyToLh, true)
val isGooglePlay: Boolean get() = App.INSTANCE.channel == "google"

@ -7,6 +7,7 @@ import io.legado.app.R
import io.legado.app.base.BaseViewModel
import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter
import io.legado.app.help.AppConfig
import io.legado.app.help.BookHelp
import io.legado.app.help.IntentDataHelp
import io.legado.app.model.WebBook
@ -163,6 +164,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
}
private fun autoChangeSource(name: String, author: String) {
if (!AppConfig.autoChangeSource) return
execute {
App.db.bookSourceDao().allTextEnabled.forEach { source ->
try {

@ -689,5 +689,6 @@
<string name="night_accent">夜间,强调色</string>
<string name="night_background_color">夜间,背景色</string>
<string name="night_navbar_color">夜间,底栏色</string>
<string name="auto_change_source">自动换源</string>
</resources>

@ -60,6 +60,12 @@
android:key="volumeKeyPageOnPlay"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true"
android:title="@string/auto_change_source"
android:key="autoChangeSource"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false"
android:title="@string/selectText"

Loading…
Cancel
Save