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 b7229d709..ea4f9a846 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -244,6 +244,12 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener { appCtx.putPrefString(PreferKey.ttsEngine, value) } + var webPort: Int + get() = appCtx.getPrefInt(PreferKey.webPort, 1122) + set(value) { + appCtx.putPrefInt(PreferKey.webPort, value) + } + val autoChangeSource: Boolean get() = appCtx.getPrefBoolean(PreferKey.autoChangeSource, true) diff --git a/app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt b/app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt index 0cdb6ba84..bf28c0ea2 100644 --- a/app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt +++ b/app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt @@ -48,6 +48,7 @@ class FileAssociationActivity : if (treeUriStr.isNullOrEmpty()) { localBookTreeSelect.launch { title = "选择保存书籍的文件夹" + mode = HandleFileContract.DIR_SYS } } else { importBook(Uri.parse(treeUriStr), uri) diff --git a/app/src/main/java/io/legado/app/ui/book/read/BaseReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/BaseReadBookActivity.kt index ec77fbbd7..27aa92a7c 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/BaseReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/BaseReadBookActivity.kt @@ -61,7 +61,7 @@ abstract class BaseReadBookActivity : binding.navigationBar.setBackgroundColor(bottomBackground) viewModel.permissionDenialLiveData.observe(this) { selectBookFolderResult.launch { - mode = HandleFileContract.SYS_DIR + mode = HandleFileContract.DIR_SYS title = "选择书籍所在文件夹" } } diff --git a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt index b4b4d4ceb..20089afd9 100644 --- a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt @@ -19,6 +19,7 @@ import io.legado.app.lib.dialogs.alert import io.legado.app.lib.theme.primaryColor import io.legado.app.receiver.SharedReceiverActivity import io.legado.app.service.WebService +import io.legado.app.ui.document.HandleFileContract import io.legado.app.ui.widget.number.NumberPickerDialog import io.legado.app.utils.* import splitties.init.appCtx @@ -32,7 +33,11 @@ class OtherConfigFragment : BasePreferenceFragment(), appCtx, SharedReceiverActivity::class.java.name ) - private val webPort get() = getPrefInt(PreferKey.webPort, 1122) + private val localBookTreeSelect = registerForActivityResult(HandleFileContract()) { + it.uri?.let { treeUri -> + AppConfig.defaultBookTreeUri = treeUri.toString() + } + } override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { putPrefBoolean(PreferKey.processText, isProcessTextEnabled()) @@ -43,7 +48,10 @@ class OtherConfigFragment : BasePreferenceFragment(), upPreferenceSummary(PreferKey.userAgent, AppConfig.userAgent) upPreferenceSummary(PreferKey.preDownloadNum, AppConfig.preDownloadNum.toString()) upPreferenceSummary(PreferKey.threadCount, AppConfig.threadCount.toString()) - upPreferenceSummary(PreferKey.webPort, webPort.toString()) + upPreferenceSummary(PreferKey.webPort, AppConfig.webPort.toString()) + AppConfig.defaultBookTreeUri?.let { + upPreferenceSummary(PreferKey.defaultBookTreeUri, it) + } } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -61,6 +69,10 @@ class OtherConfigFragment : BasePreferenceFragment(), override fun onPreferenceTreeClick(preference: Preference?): Boolean { when (preference?.key) { PreferKey.userAgent -> showUserAgentDialog() + PreferKey.defaultBookTreeUri -> localBookTreeSelect.launch { + title = "选择保存书籍的文件夹" + mode = HandleFileContract.DIR_SYS + } PreferKey.preDownloadNum -> NumberPickerDialog(requireContext()) .setTitle(getString(R.string.pre_download)) .setMaxValue(9999) @@ -81,9 +93,9 @@ class OtherConfigFragment : BasePreferenceFragment(), .setTitle(getString(R.string.web_port_title)) .setMaxValue(60000) .setMinValue(1024) - .setValue(webPort) + .setValue(AppConfig.webPort) .show { - putPrefInt(PreferKey.webPort, it) + AppConfig.webPort = it } PreferKey.cleanCache -> clearCache() "uploadRule" -> DirectLinkUploadConfig().show(childFragmentManager, "uploadRuleConfig") @@ -101,12 +113,15 @@ class OtherConfigFragment : BasePreferenceFragment(), postEvent(PreferKey.threadCount, "") } PreferKey.webPort -> { - upPreferenceSummary(key, webPort.toString()) + upPreferenceSummary(key, AppConfig.webPort.toString()) if (WebService.isRun) { WebService.stop(requireContext()) WebService.start(requireContext()) } } + PreferKey.defaultBookTreeUri -> { + upPreferenceSummary(key, AppConfig.defaultBookTreeUri) + } PreferKey.recordLog -> LogUtils.upLevel() PreferKey.processText -> sharedPreferences?.let { setProcessTextEnable(it.getBoolean(key, true)) diff --git a/app/src/main/java/io/legado/app/ui/document/HandleFileActivity.kt b/app/src/main/java/io/legado/app/ui/document/HandleFileActivity.kt index 2f4cebcb9..1d315c883 100644 --- a/app/src/main/java/io/legado/app/ui/document/HandleFileActivity.kt +++ b/app/src/main/java/io/legado/app/ui/document/HandleFileActivity.kt @@ -58,7 +58,7 @@ class HandleFileActivity : } val allowExtensions = intent.getStringArrayExtra("allowExtensions") val selectList: ArrayList> = when (mode) { - HandleFileContract.SYS_DIR -> getDirActions(true) + HandleFileContract.DIR_SYS -> getDirActions(true) HandleFileContract.DIR -> getDirActions() HandleFileContract.FILE -> getFileActions() HandleFileContract.EXPORT -> arrayListOf( diff --git a/app/src/main/java/io/legado/app/ui/document/HandleFileContract.kt b/app/src/main/java/io/legado/app/ui/document/HandleFileContract.kt index 76d13d73d..919e56690 100644 --- a/app/src/main/java/io/legado/app/ui/document/HandleFileContract.kt +++ b/app/src/main/java/io/legado/app/ui/document/HandleFileContract.kt @@ -46,7 +46,7 @@ class HandleFileContract : companion object { const val DIR = 0 const val FILE = 1 - const val SYS_DIR = 2 + const val DIR_SYS = 2 const val EXPORT = 3 } diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index 34c9d2811..40ab66282 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -909,5 +909,7 @@ 语速加 打开系统文件夹选择器出错,自动打开应用文件夹选择器 展开文本选择菜单 + 书籍保存位置 + 从其它应用打开的书籍保存位置 diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index 8bbace29d..941df5cd6 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -912,5 +912,7 @@ 语速加 打开系统文件夹选择器出错,自动打开应用文件夹选择器 展开文本选择菜单 + 书籍保存位置 + 从其它应用打开的书籍保存位置 diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index a060275a7..60ec51145 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -912,5 +912,7 @@ 语速加 打开系统文件夹选择器出错,自动打开应用文件夹选择器 展开文本选择菜单 + 书籍保存位置 + 从其它应用打开的书籍保存位置 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 04aa47e15..43e13a2d5 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -909,5 +909,7 @@ 語速加 打开系统文件夹选择器出错,自动打开应用文件夹选择器 展开文本选择菜单 + 书籍保存位置 + 从其它应用打开的书籍保存位置 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 82e3646b4..dbbf3a53d 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -911,5 +911,7 @@ 打开系统文件夹选择器出错,自动打开应用文件夹选择器 展开文本选择菜单 搜索結果 + 书籍保存位置 + 从其它应用打开的书籍保存位置 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 7c5c12665..1b42bc052 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -911,5 +911,7 @@ 语速加 打开系统文件夹选择器出错,自动打开应用文件夹选择器 展开文本选择菜单 + 书籍保存位置 + 从其它应用打开的书籍保存位置 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 279aa914b..6f83accdb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -912,5 +912,7 @@ 语速加 打开系统文件夹选择器出错,自动打开应用文件夹选择器 展开文本选择菜单 + 书籍保存位置 + 从其它应用打开的书籍保存位置 diff --git a/app/src/main/res/xml/pref_config_other.xml b/app/src/main/res/xml/pref_config_other.xml index ab979fc40..27a3cb17e 100644 --- a/app/src/main/res/xml/pref_config_other.xml +++ b/app/src/main/res/xml/pref_config_other.xml @@ -56,6 +56,11 @@ android:key="userAgent" android:title="UserAgent" /> + +