From d47ddef4d7b728cb71591dee3298b50fc3d06031 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 2 Feb 2020 10:57:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/constant/PreferKey.kt | 4 ++-- app/src/main/java/io/legado/app/help/AppConfig.kt | 6 +++--- .../io/legado/app/model/localBook/AnalyzeTxtFile.kt | 4 ++++ .../main/java/io/legado/app/ui/main/my/MyFragment.kt | 12 ++++++------ 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index 1cb5e2edc..3c6046bde 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.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" } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/help/AppConfig.kt b/app/src/main/java/io/legado/app/help/AppConfig.kt index f8eb4f62e..31107ad5f 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -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") } } diff --git a/app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt b/app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt index 148c5c8f6..96a44e1c5 100644 --- a/app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt +++ b/app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt @@ -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") + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt index e8b061144..7e95c1c34 100644 --- a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt @@ -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(Bus.WEB_SERVICE_STOP) { - findPreference("webService")?.let { + findPreference(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() } }