diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index d461e6c76..0f89a8673 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -201,7 +201,7 @@
android:screenOrientation="behind" />
@@ -241,11 +241,11 @@
android:launchMode="singleTop" />
localBookTreeSelect.launch {
- title = "选择保存书籍的文件夹"
+ title = getString(R.string.select_book_folder)
mode = HandleFileContract.DIR_SYS
}
else -> {
diff --git a/app/src/main/java/io/legado/app/ui/book/import/BaseImportBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/import/BaseImportBookActivity.kt
new file mode 100644
index 000000000..12219caf1
--- /dev/null
+++ b/app/src/main/java/io/legado/app/ui/book/import/BaseImportBookActivity.kt
@@ -0,0 +1,45 @@
+package io.legado.app.ui.book.import
+
+import androidx.lifecycle.ViewModel
+import androidx.viewbinding.ViewBinding
+import io.legado.app.R
+import io.legado.app.base.VMBaseActivity
+import io.legado.app.help.config.AppConfig
+import io.legado.app.lib.dialogs.alert
+import io.legado.app.ui.document.HandleFileContract
+
+abstract class BaseImportBookActivity(): VMBaseActivity() {
+
+ private val localBookTreeSelect = registerForActivityResult(HandleFileContract()) {
+ it.uri?.let { treeUri ->
+ AppConfig.defaultBookTreeUri = treeUri.toString()
+ }
+ }
+
+ /**
+ * 设置书籍保存位置
+ */
+ protected fun setBookStorage() {
+ //测试书籍保存位置是否设置
+ if (!AppConfig.defaultBookTreeUri.isNullOrBlank()) return
+ //测试读写??
+ val storageHelp = String(assets.open("storageHelp.md").readBytes())
+ val hint = getString(R.string.select_book_folder)
+ alert(hint, storageHelp) {
+ yesButton {
+ localBookTreeSelect.launch {
+ title = hint
+ mode = HandleFileContract.DIR_SYS
+ }
+ }
+ noButton {
+ finish()
+ }
+ onCancelled {
+ finish()
+ }
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/import/local/ImportBookActivity.kt
similarity index 97%
rename from app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt
rename to app/src/main/java/io/legado/app/ui/book/import/local/ImportBookActivity.kt
index 113fb5f25..4e9cbb1db 100644
--- a/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt
+++ b/app/src/main/java/io/legado/app/ui/book/import/local/ImportBookActivity.kt
@@ -1,4 +1,4 @@
-package io.legado.app.ui.book.local
+package io.legado.app.ui.book.import.local
import android.annotation.SuppressLint
import android.net.Uri
@@ -11,7 +11,6 @@ import androidx.appcompat.widget.PopupMenu
import androidx.documentfile.provider.DocumentFile
import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.R
-import io.legado.app.base.VMBaseActivity
import io.legado.app.constant.PreferKey
import io.legado.app.data.appDb
import io.legado.app.databinding.ActivityImportBookBinding
@@ -21,6 +20,7 @@ import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.permission.Permissions
import io.legado.app.lib.permission.PermissionsCompat
import io.legado.app.lib.theme.backgroundColor
+import io.legado.app.ui.book.import.BaseImportBookActivity
import io.legado.app.ui.document.HandleFileContract
import io.legado.app.ui.widget.SelectActionBar
import io.legado.app.utils.*
@@ -34,7 +34,7 @@ import java.io.File
/**
* 导入本地书籍界面
*/
-class ImportBookActivity : VMBaseActivity(),
+class ImportBookActivity : BaseImportBookActivity(),
PopupMenu.OnMenuItemClickListener,
ImportBookAdapter.CallBack,
SelectActionBar.CallBack {
@@ -61,6 +61,7 @@ class ImportBookActivity : VMBaseActivity(),
+class RemoteBookActivity : BaseImportBookActivity(),
RemoteBookAdapter.CallBack,
SelectActionBar.CallBack {
override val binding by viewBinding(ActivityImportBookBinding::inflate)
@@ -41,6 +41,7 @@ class RemoteBookActivity : VMBaseActivity(),
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 {
@@ -99,8 +92,6 @@ class MainActivity : VMBaseActivity(),
if (!privacyPolicy()) return@launch
//版本更新
upVersion()
- //请求设置书籍保存位置
- setBookStorage()
//自动更新书籍
val isAutoRefreshedBook = savedInstanceState?.getBoolean("isAutoRefreshedBook") ?: false
if (AppConfig.autoRefreshBook && !isAutoRefreshedBook) {
@@ -219,28 +210,6 @@ class MainActivity : VMBaseActivity(),
}
}
- /**
- * 设置书籍保存位置
- */
- 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
- }
- }
- neutralButton("不想设置") {
- AppConfig.defaultBookTreeUri = "null"
- }
- noButton()
- }
- }
-
override fun onKeyUp(keyCode: Int, event: KeyEvent?): Boolean {
event?.let {
when (keyCode) {
diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt
index 85f19c0e5..1e04585e9 100644
--- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt
+++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt
@@ -21,9 +21,9 @@ import io.legado.app.lib.dialogs.alert
import io.legado.app.ui.about.AppLogDialog
import io.legado.app.ui.book.cache.CacheActivity
import io.legado.app.ui.book.group.GroupManageDialog
-import io.legado.app.ui.book.local.ImportBookActivity
+import io.legado.app.ui.book.import.local.ImportBookActivity
+import io.legado.app.ui.book.import.remote.RemoteBookActivity
import io.legado.app.ui.book.manage.BookshelfManageActivity
-import io.legado.app.ui.book.remote.RemoteBookActivity
import io.legado.app.ui.book.search.SearchActivity
import io.legado.app.ui.document.HandleFileContract
import io.legado.app.ui.main.MainViewModel