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

@ -8,7 +8,7 @@ object AppConfig {
var isNightTheme: Boolean var isNightTheme: Boolean
get() { get() {
return when (App.INSTANCE.getPrefString("themeMode", "0")) { return when (App.INSTANCE.getPrefString(PreferKey.themeMode, "0")) {
"1" -> false "1" -> false
"2" -> true "2" -> true
else -> App.INSTANCE.sysIsDarkMode() else -> App.INSTANCE.sysIsDarkMode()
@ -16,9 +16,9 @@ object AppConfig {
} }
set(value) { set(value) {
if (value) { if (value) {
App.INSTANCE.putPrefString("themeMode", "2") App.INSTANCE.putPrefString(PreferKey.themeMode, "2")
} else { } 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.EncodingDetect
import io.legado.app.utils.FileUtils import io.legado.app.utils.FileUtils
import java.io.File import java.io.File
import java.io.RandomAccessFile
object AnalyzeTxtFile { object AnalyzeTxtFile {
private const val folderName = "bookTxt" private const val folderName = "bookTxt"
@ -29,6 +30,9 @@ object AnalyzeTxtFile {
} }
book.charset = EncodingDetect.getEncode(bookFile) 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?) { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
if (WebService.isRun) { if (WebService.isRun) {
putPrefBoolean("webService", true) putPrefBoolean(PreferKey.webService, true)
} else { } else {
putPrefBoolean("webService", false) putPrefBoolean(PreferKey.webService, false)
} }
addPreferencesFromResource(R.xml.pref_main) addPreferencesFromResource(R.xml.pref_main)
observeEvent<Boolean>(Bus.WEB_SERVICE_STOP) { observeEvent<Boolean>(Bus.WEB_SERVICE_STOP) {
findPreference<SwitchPreference>("webService")?.let { findPreference<SwitchPreference>(PreferKey.webService)?.let {
it.isChecked = false it.isChecked = false
} }
} }
@ -203,8 +203,8 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config) {
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
when (key) { when (key) {
"themeMode" -> App.INSTANCE.applyDayNight() PreferKey.themeMode -> App.INSTANCE.applyDayNight()
"webService" -> { PreferKey.webService -> {
if (requireContext().getPrefBoolean("webService")) { if (requireContext().getPrefBoolean("webService")) {
WebService.start(requireContext()) WebService.start(requireContext())
toast("正在启动服务\n具体信息查看通知栏") toast("正在启动服务\n具体信息查看通知栏")
@ -213,8 +213,8 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config) {
toast("服务已停止") toast("服务已停止")
} }
} }
PreferKey.downloadPath -> BookHelp.upDownloadPath()
"recordLog" -> LogUtils.upLevel() "recordLog" -> LogUtils.upLevel()
"downloadPath" -> BookHelp.upDownloadPath()
} }
} }

Loading…
Cancel
Save