设置里增加书籍文件夹配置,方便切换外部书籍保存文件夹
This commit is contained in:
@@ -244,6 +244,12 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
|||||||
appCtx.putPrefString(PreferKey.ttsEngine, value)
|
appCtx.putPrefString(PreferKey.ttsEngine, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var webPort: Int
|
||||||
|
get() = appCtx.getPrefInt(PreferKey.webPort, 1122)
|
||||||
|
set(value) {
|
||||||
|
appCtx.putPrefInt(PreferKey.webPort, value)
|
||||||
|
}
|
||||||
|
|
||||||
val autoChangeSource: Boolean
|
val autoChangeSource: Boolean
|
||||||
get() = appCtx.getPrefBoolean(PreferKey.autoChangeSource, true)
|
get() = appCtx.getPrefBoolean(PreferKey.autoChangeSource, true)
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ class FileAssociationActivity :
|
|||||||
if (treeUriStr.isNullOrEmpty()) {
|
if (treeUriStr.isNullOrEmpty()) {
|
||||||
localBookTreeSelect.launch {
|
localBookTreeSelect.launch {
|
||||||
title = "选择保存书籍的文件夹"
|
title = "选择保存书籍的文件夹"
|
||||||
|
mode = HandleFileContract.DIR_SYS
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
importBook(Uri.parse(treeUriStr), uri)
|
importBook(Uri.parse(treeUriStr), uri)
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ abstract class BaseReadBookActivity :
|
|||||||
binding.navigationBar.setBackgroundColor(bottomBackground)
|
binding.navigationBar.setBackgroundColor(bottomBackground)
|
||||||
viewModel.permissionDenialLiveData.observe(this) {
|
viewModel.permissionDenialLiveData.observe(this) {
|
||||||
selectBookFolderResult.launch {
|
selectBookFolderResult.launch {
|
||||||
mode = HandleFileContract.SYS_DIR
|
mode = HandleFileContract.DIR_SYS
|
||||||
title = "选择书籍所在文件夹"
|
title = "选择书籍所在文件夹"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import io.legado.app.lib.dialogs.alert
|
|||||||
import io.legado.app.lib.theme.primaryColor
|
import io.legado.app.lib.theme.primaryColor
|
||||||
import io.legado.app.receiver.SharedReceiverActivity
|
import io.legado.app.receiver.SharedReceiverActivity
|
||||||
import io.legado.app.service.WebService
|
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.ui.widget.number.NumberPickerDialog
|
||||||
import io.legado.app.utils.*
|
import io.legado.app.utils.*
|
||||||
import splitties.init.appCtx
|
import splitties.init.appCtx
|
||||||
@@ -32,7 +33,11 @@ class OtherConfigFragment : BasePreferenceFragment(),
|
|||||||
appCtx,
|
appCtx,
|
||||||
SharedReceiverActivity::class.java.name
|
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?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
putPrefBoolean(PreferKey.processText, isProcessTextEnabled())
|
putPrefBoolean(PreferKey.processText, isProcessTextEnabled())
|
||||||
@@ -43,7 +48,10 @@ class OtherConfigFragment : BasePreferenceFragment(),
|
|||||||
upPreferenceSummary(PreferKey.userAgent, AppConfig.userAgent)
|
upPreferenceSummary(PreferKey.userAgent, AppConfig.userAgent)
|
||||||
upPreferenceSummary(PreferKey.preDownloadNum, AppConfig.preDownloadNum.toString())
|
upPreferenceSummary(PreferKey.preDownloadNum, AppConfig.preDownloadNum.toString())
|
||||||
upPreferenceSummary(PreferKey.threadCount, AppConfig.threadCount.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?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
@@ -61,6 +69,10 @@ class OtherConfigFragment : BasePreferenceFragment(),
|
|||||||
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
|
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
|
||||||
when (preference?.key) {
|
when (preference?.key) {
|
||||||
PreferKey.userAgent -> showUserAgentDialog()
|
PreferKey.userAgent -> showUserAgentDialog()
|
||||||
|
PreferKey.defaultBookTreeUri -> localBookTreeSelect.launch {
|
||||||
|
title = "选择保存书籍的文件夹"
|
||||||
|
mode = HandleFileContract.DIR_SYS
|
||||||
|
}
|
||||||
PreferKey.preDownloadNum -> NumberPickerDialog(requireContext())
|
PreferKey.preDownloadNum -> NumberPickerDialog(requireContext())
|
||||||
.setTitle(getString(R.string.pre_download))
|
.setTitle(getString(R.string.pre_download))
|
||||||
.setMaxValue(9999)
|
.setMaxValue(9999)
|
||||||
@@ -81,9 +93,9 @@ class OtherConfigFragment : BasePreferenceFragment(),
|
|||||||
.setTitle(getString(R.string.web_port_title))
|
.setTitle(getString(R.string.web_port_title))
|
||||||
.setMaxValue(60000)
|
.setMaxValue(60000)
|
||||||
.setMinValue(1024)
|
.setMinValue(1024)
|
||||||
.setValue(webPort)
|
.setValue(AppConfig.webPort)
|
||||||
.show {
|
.show {
|
||||||
putPrefInt(PreferKey.webPort, it)
|
AppConfig.webPort = it
|
||||||
}
|
}
|
||||||
PreferKey.cleanCache -> clearCache()
|
PreferKey.cleanCache -> clearCache()
|
||||||
"uploadRule" -> DirectLinkUploadConfig().show(childFragmentManager, "uploadRuleConfig")
|
"uploadRule" -> DirectLinkUploadConfig().show(childFragmentManager, "uploadRuleConfig")
|
||||||
@@ -101,12 +113,15 @@ class OtherConfigFragment : BasePreferenceFragment(),
|
|||||||
postEvent(PreferKey.threadCount, "")
|
postEvent(PreferKey.threadCount, "")
|
||||||
}
|
}
|
||||||
PreferKey.webPort -> {
|
PreferKey.webPort -> {
|
||||||
upPreferenceSummary(key, webPort.toString())
|
upPreferenceSummary(key, AppConfig.webPort.toString())
|
||||||
if (WebService.isRun) {
|
if (WebService.isRun) {
|
||||||
WebService.stop(requireContext())
|
WebService.stop(requireContext())
|
||||||
WebService.start(requireContext())
|
WebService.start(requireContext())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
PreferKey.defaultBookTreeUri -> {
|
||||||
|
upPreferenceSummary(key, AppConfig.defaultBookTreeUri)
|
||||||
|
}
|
||||||
PreferKey.recordLog -> LogUtils.upLevel()
|
PreferKey.recordLog -> LogUtils.upLevel()
|
||||||
PreferKey.processText -> sharedPreferences?.let {
|
PreferKey.processText -> sharedPreferences?.let {
|
||||||
setProcessTextEnable(it.getBoolean(key, true))
|
setProcessTextEnable(it.getBoolean(key, true))
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class HandleFileActivity :
|
|||||||
}
|
}
|
||||||
val allowExtensions = intent.getStringArrayExtra("allowExtensions")
|
val allowExtensions = intent.getStringArrayExtra("allowExtensions")
|
||||||
val selectList: ArrayList<SelectItem<Int>> = when (mode) {
|
val selectList: ArrayList<SelectItem<Int>> = when (mode) {
|
||||||
HandleFileContract.SYS_DIR -> getDirActions(true)
|
HandleFileContract.DIR_SYS -> getDirActions(true)
|
||||||
HandleFileContract.DIR -> getDirActions()
|
HandleFileContract.DIR -> getDirActions()
|
||||||
HandleFileContract.FILE -> getFileActions()
|
HandleFileContract.FILE -> getFileActions()
|
||||||
HandleFileContract.EXPORT -> arrayListOf(
|
HandleFileContract.EXPORT -> arrayListOf(
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class HandleFileContract :
|
|||||||
companion object {
|
companion object {
|
||||||
const val DIR = 0
|
const val DIR = 0
|
||||||
const val FILE = 1
|
const val FILE = 1
|
||||||
const val SYS_DIR = 2
|
const val DIR_SYS = 2
|
||||||
const val EXPORT = 3
|
const val EXPORT = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -909,5 +909,7 @@
|
|||||||
<string name="tts_speech_add">语速加</string>
|
<string name="tts_speech_add">语速加</string>
|
||||||
<string name="open_sys_dir_picker_error">打开系统文件夹选择器出错,自动打开应用文件夹选择器</string>
|
<string name="open_sys_dir_picker_error">打开系统文件夹选择器出错,自动打开应用文件夹选择器</string>
|
||||||
<string name="expand_text_menu">展开文本选择菜单</string>
|
<string name="expand_text_menu">展开文本选择菜单</string>
|
||||||
|
<string name="book_tree_uri_t">书籍保存位置</string>
|
||||||
|
<string name="book_tree_uri_s">从其它应用打开的书籍保存位置</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -912,5 +912,7 @@
|
|||||||
<string name="tts_speech_add">语速加</string>
|
<string name="tts_speech_add">语速加</string>
|
||||||
<string name="open_sys_dir_picker_error">打开系统文件夹选择器出错,自动打开应用文件夹选择器</string>
|
<string name="open_sys_dir_picker_error">打开系统文件夹选择器出错,自动打开应用文件夹选择器</string>
|
||||||
<string name="expand_text_menu">展开文本选择菜单</string>
|
<string name="expand_text_menu">展开文本选择菜单</string>
|
||||||
|
<string name="book_tree_uri_t">书籍保存位置</string>
|
||||||
|
<string name="book_tree_uri_s">从其它应用打开的书籍保存位置</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -912,5 +912,7 @@
|
|||||||
<string name="tts_speech_add">语速加</string>
|
<string name="tts_speech_add">语速加</string>
|
||||||
<string name="open_sys_dir_picker_error">打开系统文件夹选择器出错,自动打开应用文件夹选择器</string>
|
<string name="open_sys_dir_picker_error">打开系统文件夹选择器出错,自动打开应用文件夹选择器</string>
|
||||||
<string name="expand_text_menu">展开文本选择菜单</string>
|
<string name="expand_text_menu">展开文本选择菜单</string>
|
||||||
|
<string name="book_tree_uri_t">书籍保存位置</string>
|
||||||
|
<string name="book_tree_uri_s">从其它应用打开的书籍保存位置</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -909,5 +909,7 @@
|
|||||||
<string name="tts_speech_add">語速加</string>
|
<string name="tts_speech_add">語速加</string>
|
||||||
<string name="open_sys_dir_picker_error">打开系统文件夹选择器出错,自动打开应用文件夹选择器</string>
|
<string name="open_sys_dir_picker_error">打开系统文件夹选择器出错,自动打开应用文件夹选择器</string>
|
||||||
<string name="expand_text_menu">展开文本选择菜单</string>
|
<string name="expand_text_menu">展开文本选择菜单</string>
|
||||||
|
<string name="book_tree_uri_t">书籍保存位置</string>
|
||||||
|
<string name="book_tree_uri_s">从其它应用打开的书籍保存位置</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -911,5 +911,7 @@
|
|||||||
<string name="open_sys_dir_picker_error">打开系统文件夹选择器出错,自动打开应用文件夹选择器</string>
|
<string name="open_sys_dir_picker_error">打开系统文件夹选择器出错,自动打开应用文件夹选择器</string>
|
||||||
<string name="expand_text_menu">展开文本选择菜单</string>
|
<string name="expand_text_menu">展开文本选择菜单</string>
|
||||||
<string name="search_content_size">搜索結果</string>
|
<string name="search_content_size">搜索結果</string>
|
||||||
|
<string name="book_tree_uri_t">书籍保存位置</string>
|
||||||
|
<string name="book_tree_uri_s">从其它应用打开的书籍保存位置</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -911,5 +911,7 @@
|
|||||||
<string name="tts_speech_add">语速加</string>
|
<string name="tts_speech_add">语速加</string>
|
||||||
<string name="open_sys_dir_picker_error">打开系统文件夹选择器出错,自动打开应用文件夹选择器</string>
|
<string name="open_sys_dir_picker_error">打开系统文件夹选择器出错,自动打开应用文件夹选择器</string>
|
||||||
<string name="expand_text_menu">展开文本选择菜单</string>
|
<string name="expand_text_menu">展开文本选择菜单</string>
|
||||||
|
<string name="book_tree_uri_t">书籍保存位置</string>
|
||||||
|
<string name="book_tree_uri_s">从其它应用打开的书籍保存位置</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -912,5 +912,7 @@
|
|||||||
<string name="tts_speech_add">语速加</string>
|
<string name="tts_speech_add">语速加</string>
|
||||||
<string name="open_sys_dir_picker_error">打开系统文件夹选择器出错,自动打开应用文件夹选择器</string>
|
<string name="open_sys_dir_picker_error">打开系统文件夹选择器出错,自动打开应用文件夹选择器</string>
|
||||||
<string name="expand_text_menu">展开文本选择菜单</string>
|
<string name="expand_text_menu">展开文本选择菜单</string>
|
||||||
|
<string name="book_tree_uri_t">书籍保存位置</string>
|
||||||
|
<string name="book_tree_uri_s">从其它应用打开的书籍保存位置</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -56,6 +56,11 @@
|
|||||||
android:key="userAgent"
|
android:key="userAgent"
|
||||||
android:title="UserAgent" />
|
android:title="UserAgent" />
|
||||||
|
|
||||||
|
<io.legado.app.ui.widget.prefs.Preference
|
||||||
|
android:key="defaultBookTreeUri"
|
||||||
|
android:title="@string/book_tree_uri_t"
|
||||||
|
android:summary="@string/book_tree_uri_s" />
|
||||||
|
|
||||||
<io.legado.app.ui.widget.prefs.Preference
|
<io.legado.app.ui.widget.prefs.Preference
|
||||||
android:key="uploadRule"
|
android:key="uploadRule"
|
||||||
android:title="@string/direct_link_upload_rule"
|
android:title="@string/direct_link_upload_rule"
|
||||||
|
|||||||
Reference in New Issue
Block a user