Merge remote-tracking branch 'origin/master'

pull/2368/head
kunfei 2 years ago
commit 4e92243413
  1. 2
      app/src/main/assets/storageHelp.md
  2. 2
      app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt
  3. 28
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt

@ -0,0 +1,2 @@
* 由于安卓的存储访问限制,阅读需要设置**公共目录下的子目录**来实现书籍拷贝、下载
* 如不设置,可能影响本地书籍、webDav书籍的正常阅读

@ -121,7 +121,7 @@ class FileAssociationActivity :
val treeUriStr = AppConfig.defaultBookTreeUri
if (treeUriStr.isNullOrEmpty()) {
localBookTreeSelect.launch {
title = "选择保存书籍的文件夹"
title = getString(R.string.select_book_folder)
mode = HandleFileContract.DIR_SYS
}
} else {

@ -31,6 +31,7 @@ import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.theme.elevation
import io.legado.app.lib.theme.primaryColor
import io.legado.app.service.BaseReadAloudService
import io.legado.app.ui.document.HandleFileContract
import io.legado.app.ui.main.bookshelf.BaseBookshelfFragment
import io.legado.app.ui.main.bookshelf.style1.BookshelfFragment1
import io.legado.app.ui.main.bookshelf.style2.BookshelfFragment2
@ -70,6 +71,12 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
private var bottomMenuCount = 4
private val realPositions = arrayOf(idBookshelf, idExplore, idRss, idMy)
private val localBookTreeSelect = registerForActivityResult(HandleFileContract()) {
it.uri?.let { treeUri ->
AppConfig.defaultBookTreeUri = treeUri.toString()
}
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
upBottomMenu()
binding.run {
@ -87,6 +94,8 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
super.onPostCreate(savedInstanceState)
upVersion()
privacyPolicy()
//请求设置书籍保存位置
setBookStorage()
//自动更新书籍
val isAutoRefreshedBook = savedInstanceState?.getBoolean("isAutoRefreshedBook") ?: false
if (AppConfig.autoRefreshBook && !isAutoRefreshedBook) {
@ -181,6 +190,25 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
}
}
/**
* 设置书籍保存位置
*/
private fun setBookStorage() {
//测试书籍保存位置是否设置
if (!AppConfig.defaultBookTreeUri.isNullOrBlank()) return
//测试读写??
val storageHelp = String(assets.open("storageHelp.md").readBytes())
alert("设置书籍保存位置", storageHelp) {
yesButton {
localBookTreeSelect.launch {
title = getString(R.string.select_book_folder)
mode = HandleFileContract.DIR_SYS
}
}
noButton()
}
}
override fun onKeyUp(keyCode: Int, event: KeyEvent?): Boolean {
event?.let {
when (keyCode) {

Loading…
Cancel
Save