mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
4e92243413
2
app/src/main/assets/storageHelp.md
Normal file
2
app/src/main/assets/storageHelp.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
* 由于安卓的存储访问限制,阅读需要设置**公共目录下的子目录**来实现书籍拷贝、下载
|
||||||
|
* 如不设置,可能影响本地书籍、webDav书籍的正常阅读
|
@ -121,7 +121,7 @@ class FileAssociationActivity :
|
|||||||
val treeUriStr = AppConfig.defaultBookTreeUri
|
val treeUriStr = AppConfig.defaultBookTreeUri
|
||||||
if (treeUriStr.isNullOrEmpty()) {
|
if (treeUriStr.isNullOrEmpty()) {
|
||||||
localBookTreeSelect.launch {
|
localBookTreeSelect.launch {
|
||||||
title = "选择保存书籍的文件夹"
|
title = getString(R.string.select_book_folder)
|
||||||
mode = HandleFileContract.DIR_SYS
|
mode = HandleFileContract.DIR_SYS
|
||||||
}
|
}
|
||||||
} else {
|
} 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.elevation
|
||||||
import io.legado.app.lib.theme.primaryColor
|
import io.legado.app.lib.theme.primaryColor
|
||||||
import io.legado.app.service.BaseReadAloudService
|
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.BaseBookshelfFragment
|
||||||
import io.legado.app.ui.main.bookshelf.style1.BookshelfFragment1
|
import io.legado.app.ui.main.bookshelf.style1.BookshelfFragment1
|
||||||
import io.legado.app.ui.main.bookshelf.style2.BookshelfFragment2
|
import io.legado.app.ui.main.bookshelf.style2.BookshelfFragment2
|
||||||
@ -70,6 +71,12 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
|
|||||||
private var bottomMenuCount = 4
|
private var bottomMenuCount = 4
|
||||||
private val realPositions = arrayOf(idBookshelf, idExplore, idRss, idMy)
|
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?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
upBottomMenu()
|
upBottomMenu()
|
||||||
binding.run {
|
binding.run {
|
||||||
@ -87,6 +94,8 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
|
|||||||
super.onPostCreate(savedInstanceState)
|
super.onPostCreate(savedInstanceState)
|
||||||
upVersion()
|
upVersion()
|
||||||
privacyPolicy()
|
privacyPolicy()
|
||||||
|
//请求设置书籍保存位置
|
||||||
|
setBookStorage()
|
||||||
//自动更新书籍
|
//自动更新书籍
|
||||||
val isAutoRefreshedBook = savedInstanceState?.getBoolean("isAutoRefreshedBook") ?: false
|
val isAutoRefreshedBook = savedInstanceState?.getBoolean("isAutoRefreshedBook") ?: false
|
||||||
if (AppConfig.autoRefreshBook && !isAutoRefreshedBook) {
|
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 {
|
override fun onKeyUp(keyCode: Int, event: KeyEvent?): Boolean {
|
||||||
event?.let {
|
event?.let {
|
||||||
when (keyCode) {
|
when (keyCode) {
|
||||||
|
Loading…
Reference in New Issue
Block a user