|
|
@ -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) { |
|
|
|