pull/84/head
kunfei 5 years ago
parent 9e8eed355c
commit d47ddef4d7
  1. 4
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  2. 6
      app/src/main/java/io/legado/app/help/AppConfig.kt
  3. 4
      app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt
  4. 12
      app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt

@ -1,7 +1,7 @@
package io.legado.app.constant
object PreferKey {
const val themeMode = "themeMode"
const val downloadPath = "downloadPath"
const val hideStatusBar = "hideStatusBar"
const val clickAllNext = "clickAllNext"
@ -21,5 +21,5 @@ object PreferKey {
const val backupPath = "backupUri"
const val threadCount = "threadCount"
const val keepLight = "keep_light"
const val autoDarkMode = "autoDarkMode"
const val webService = "webService"
}

@ -8,7 +8,7 @@ object AppConfig {
var isNightTheme: Boolean
get() {
return when (App.INSTANCE.getPrefString("themeMode", "0")) {
return when (App.INSTANCE.getPrefString(PreferKey.themeMode, "0")) {
"1" -> false
"2" -> true
else -> App.INSTANCE.sysIsDarkMode()
@ -16,9 +16,9 @@ object AppConfig {
}
set(value) {
if (value) {
App.INSTANCE.putPrefString("themeMode", "2")
App.INSTANCE.putPrefString(PreferKey.themeMode, "2")
} else {
App.INSTANCE.putPrefString("themeMode", "1")
App.INSTANCE.putPrefString(PreferKey.themeMode, "1")
}
}

@ -8,6 +8,7 @@ import io.legado.app.utils.DocumentUtils
import io.legado.app.utils.EncodingDetect
import io.legado.app.utils.FileUtils
import java.io.File
import java.io.RandomAccessFile
object AnalyzeTxtFile {
private const val folderName = "bookTxt"
@ -29,6 +30,9 @@ object AnalyzeTxtFile {
}
book.charset = EncodingDetect.getEncode(bookFile)
//获取文件流
val bookStream = RandomAccessFile(bookFile, "r")
}
}

@ -174,13 +174,13 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config) {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
if (WebService.isRun) {
putPrefBoolean("webService", true)
putPrefBoolean(PreferKey.webService, true)
} else {
putPrefBoolean("webService", false)
putPrefBoolean(PreferKey.webService, false)
}
addPreferencesFromResource(R.xml.pref_main)
observeEvent<Boolean>(Bus.WEB_SERVICE_STOP) {
findPreference<SwitchPreference>("webService")?.let {
findPreference<SwitchPreference>(PreferKey.webService)?.let {
it.isChecked = false
}
}
@ -203,8 +203,8 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config) {
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
when (key) {
"themeMode" -> App.INSTANCE.applyDayNight()
"webService" -> {
PreferKey.themeMode -> App.INSTANCE.applyDayNight()
PreferKey.webService -> {
if (requireContext().getPrefBoolean("webService")) {
WebService.start(requireContext())
toast("正在启动服务\n具体信息查看通知栏")
@ -213,8 +213,8 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config) {
toast("服务已停止")
}
}
PreferKey.downloadPath -> BookHelp.upDownloadPath()
"recordLog" -> LogUtils.upLevel()
"downloadPath" -> BookHelp.upDownloadPath()
}
}

Loading…
Cancel
Save