[优化] 引导增加选择保存书籍文件夹
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package io.legado.app.ui.welcome
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import io.legado.app.R
|
||||
import io.legado.app.base.BaseFragment
|
||||
import io.legado.app.databinding.FragmentBookFolderBinding
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.ui.file.HandleFileContract
|
||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||
|
||||
class BookFolderFragment : BaseFragment(R.layout.fragment_book_folder) {
|
||||
|
||||
private val binding by viewBinding(FragmentBookFolderBinding::bind)
|
||||
|
||||
private val selectBookFolder = registerForActivityResult(HandleFileContract()) { result ->
|
||||
result.uri?.let { treeUri ->
|
||||
AppConfig.defaultBookTreeUri = treeUri.toString()
|
||||
updatePathText()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
||||
binding.btnSelectFolder.setOnClickListener {
|
||||
selectBookFolder.launch {
|
||||
title = getString(R.string.select_book_folder)
|
||||
mode = HandleFileContract.DIR_SYS
|
||||
}
|
||||
}
|
||||
updatePathText()
|
||||
}
|
||||
|
||||
private fun updatePathText() {
|
||||
binding.tvFolderPath.text =
|
||||
AppConfig.defaultBookTreeUri ?: getString(R.string.welcome_book_folder_not_selected)
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ class WelcomeActivity : BaseActivity<ActivityWelcomeBinding>() {
|
||||
private val pages = listOf(
|
||||
PrivacyFragment(),
|
||||
WebDavFragment(),
|
||||
BookFolderFragment(),
|
||||
ThemeFragment()
|
||||
)
|
||||
|
||||
@@ -54,11 +55,13 @@ class WelcomeActivity : BaseActivity<ActivityWelcomeBinding>() {
|
||||
binding.tvTitle.text = when (position) {
|
||||
0 -> "欢迎!" // PrivacyFragment
|
||||
1 -> "备份与恢复"
|
||||
2 -> "书籍文件夹"
|
||||
else -> "主题样式"
|
||||
}
|
||||
binding.tvSummary.text = when (position) {
|
||||
0 -> "请先阅读应用的服务条款与用户协议。"
|
||||
1 -> "此处可设置云同步与恢复应用备份。"
|
||||
2 -> "请选择保存本地书籍的文件夹。"
|
||||
else -> "在这里设置您喜爱的样式。"
|
||||
}
|
||||
updateProgress(position)
|
||||
|
||||
Reference in New Issue
Block a user