diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 5a4dde7bd..c16b1cfe4 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -203,7 +203,7 @@
android:screenOrientation="behind" />
diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
index 2445e39b1..2fba05c45 100644
--- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
+++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
@@ -57,7 +57,7 @@ import io.legado.app.ui.book.searchContent.SearchContentActivity
import io.legado.app.ui.book.searchContent.SearchResult
import io.legado.app.ui.book.source.edit.BookSourceEditActivity
import io.legado.app.ui.book.toc.TocActivityResult
-import io.legado.app.ui.book.toc.TxtTocRegexDialog
+import io.legado.app.ui.book.toc.rule.TxtTocRuleDialog
import io.legado.app.ui.browser.WebViewActivity
import io.legado.app.ui.dict.DictDialog
import io.legado.app.ui.document.HandleFileContract
@@ -87,7 +87,7 @@ class ReadBookActivity : BaseReadBookActivity(),
ChangeChapterSourceDialog.CallBack,
ReadBook.CallBack,
AutoReadDialog.CallBack,
- TxtTocRegexDialog.CallBack,
+ TxtTocRuleDialog.CallBack,
ColorPickerDialogListener {
private val tocActivity =
@@ -384,7 +384,7 @@ class ReadBookActivity : BaseReadBookActivity(),
}
R.id.menu_log -> showDialogFragment()
R.id.menu_toc_regex -> showDialogFragment(
- TxtTocRegexDialog(ReadBook.book?.tocUrl)
+ TxtTocRuleDialog(ReadBook.book?.tocUrl)
)
R.id.menu_reverse_content -> ReadBook.book?.let {
viewModel.reverseContent(it)
diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
index e0bb068d1..0863f4382 100644
--- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
+++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
@@ -28,11 +28,11 @@ import io.legado.app.lib.theme.primaryTextColor
import io.legado.app.model.CheckSource
import io.legado.app.model.Debug
import io.legado.app.ui.association.ImportBookSourceDialog
-import io.legado.app.ui.book.import.local.rule.TxtTocRuleActivity
import io.legado.app.ui.book.search.SearchActivity
import io.legado.app.ui.book.search.SearchScope
import io.legado.app.ui.book.source.debug.BookSourceDebugActivity
import io.legado.app.ui.book.source.edit.BookSourceEditActivity
+import io.legado.app.ui.book.toc.rule.TxtTocRuleActivity
import io.legado.app.ui.config.CheckSourceConfig
import io.legado.app.ui.document.HandleFileContract
import io.legado.app.ui.qrcode.QrCodeResult
diff --git a/app/src/main/java/io/legado/app/ui/book/toc/TocActivity.kt b/app/src/main/java/io/legado/app/ui/book/toc/TocActivity.kt
index 75d83f343..ed6c5e1b4 100644
--- a/app/src/main/java/io/legado/app/ui/book/toc/TocActivity.kt
+++ b/app/src/main/java/io/legado/app/ui/book/toc/TocActivity.kt
@@ -20,6 +20,7 @@ import io.legado.app.help.config.AppConfig
import io.legado.app.lib.theme.accentColor
import io.legado.app.lib.theme.primaryTextColor
import io.legado.app.ui.about.AppLogDialog
+import io.legado.app.ui.book.toc.rule.TxtTocRuleDialog
import io.legado.app.utils.applyTint
import io.legado.app.utils.gone
import io.legado.app.utils.showDialogFragment
@@ -96,7 +97,7 @@ class TocActivity : VMBaseActivity() {
override fun onCompatOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.menu_toc_regex -> showDialogFragment(
- TxtTocRegexDialog(viewModel.bookData.value?.tocUrl)
+ TxtTocRuleDialog(viewModel.bookData.value?.tocUrl)
)
R.id.menu_reverse_toc -> viewModel.reverseToc {
viewModel.chapterListCallBack?.upChapterList(searchView?.query?.toString())
diff --git a/app/src/main/java/io/legado/app/ui/book/toc/TxtTocRegexViewModel.kt b/app/src/main/java/io/legado/app/ui/book/toc/TxtTocRegexViewModel.kt
deleted file mode 100644
index bfc17111f..000000000
--- a/app/src/main/java/io/legado/app/ui/book/toc/TxtTocRegexViewModel.kt
+++ /dev/null
@@ -1,29 +0,0 @@
-package io.legado.app.ui.book.toc
-
-import android.app.Application
-import io.legado.app.base.BaseViewModel
-import io.legado.app.data.appDb
-import io.legado.app.data.entities.TxtTocRule
-import io.legado.app.help.DefaultData
-
-/**
- * txt目录规则
- */
-class TxtTocRegexViewModel(application: Application) : BaseViewModel(application) {
-
- fun saveRule(rule: TxtTocRule) {
- execute {
- if (rule.serialNumber < 0) {
- rule.serialNumber = appDb.txtTocRuleDao.maxOrder + 1
- }
- appDb.txtTocRuleDao.insert(rule)
- }
- }
-
- fun importDefault() {
- execute {
- DefaultData.importDefaultTocRules()
- }
- }
-
-}
\ No newline at end of file
diff --git a/app/src/main/java/io/legado/app/ui/book/import/local/rule/TxtTocRuleActivity.kt b/app/src/main/java/io/legado/app/ui/book/toc/rule/TxtTocRuleActivity.kt
similarity index 99%
rename from app/src/main/java/io/legado/app/ui/book/import/local/rule/TxtTocRuleActivity.kt
rename to app/src/main/java/io/legado/app/ui/book/toc/rule/TxtTocRuleActivity.kt
index a75478343..d58900d09 100644
--- a/app/src/main/java/io/legado/app/ui/book/import/local/rule/TxtTocRuleActivity.kt
+++ b/app/src/main/java/io/legado/app/ui/book/toc/rule/TxtTocRuleActivity.kt
@@ -1,4 +1,4 @@
-package io.legado.app.ui.book.import.local.rule
+package io.legado.app.ui.book.toc.rule
import android.annotation.SuppressLint
import android.os.Bundle
diff --git a/app/src/main/java/io/legado/app/ui/book/import/local/rule/TxtTocRuleAdapter.kt b/app/src/main/java/io/legado/app/ui/book/toc/rule/TxtTocRuleAdapter.kt
similarity index 99%
rename from app/src/main/java/io/legado/app/ui/book/import/local/rule/TxtTocRuleAdapter.kt
rename to app/src/main/java/io/legado/app/ui/book/toc/rule/TxtTocRuleAdapter.kt
index 76b014d5a..71da2bfdf 100644
--- a/app/src/main/java/io/legado/app/ui/book/import/local/rule/TxtTocRuleAdapter.kt
+++ b/app/src/main/java/io/legado/app/ui/book/toc/rule/TxtTocRuleAdapter.kt
@@ -1,4 +1,4 @@
-package io.legado.app.ui.book.import.local.rule
+package io.legado.app.ui.book.toc.rule
import android.content.Context
import android.os.Bundle
diff --git a/app/src/main/java/io/legado/app/ui/book/toc/TxtTocRegexDialog.kt b/app/src/main/java/io/legado/app/ui/book/toc/rule/TxtTocRuleDialog.kt
similarity index 97%
rename from app/src/main/java/io/legado/app/ui/book/toc/TxtTocRegexDialog.kt
rename to app/src/main/java/io/legado/app/ui/book/toc/rule/TxtTocRuleDialog.kt
index cc5eb1b24..474fb9fbc 100644
--- a/app/src/main/java/io/legado/app/ui/book/toc/TxtTocRegexDialog.kt
+++ b/app/src/main/java/io/legado/app/ui/book/toc/rule/TxtTocRuleDialog.kt
@@ -1,4 +1,4 @@
-package io.legado.app.ui.book.toc
+package io.legado.app.ui.book.toc.rule
import android.annotation.SuppressLint
import android.content.Context
@@ -36,7 +36,7 @@ import kotlinx.coroutines.launch
/**
* txt目录规则
*/
-class TxtTocRegexDialog() : BaseDialogFragment(R.layout.dialog_toc_regex),
+class TxtTocRuleDialog() : BaseDialogFragment(R.layout.dialog_toc_regex),
Toolbar.OnMenuItemClickListener {
constructor(tocRegex: String?) : this() {
@@ -46,7 +46,7 @@ class TxtTocRegexDialog() : BaseDialogFragment(R.layout.dialog_toc_regex),
}
private val importTocRuleKey = "tocRuleUrl"
- private val viewModel: TxtTocRegexViewModel by viewModels()
+ private val viewModel: TxtTocRuleViewModel by viewModels()
private val binding by viewBinding(DialogTocRegexBinding::bind)
private val adapter by lazy { TocRegexAdapter(requireContext()) }
var selectedName: String? = null
@@ -180,7 +180,7 @@ class TxtTocRegexDialog() : BaseDialogFragment(R.layout.dialog_toc_regex),
tocRule.name = tvRuleName.text.toString()
tocRule.rule = tvRuleRegex.text.toString()
tocRule.example = tvRuleExample.text.toString()
- viewModel.saveRule(tocRule)
+ viewModel.save(tocRule)
}
}
cancelButton()
diff --git a/app/src/main/java/io/legado/app/ui/book/import/local/rule/TxtTocRuleViewModel.kt b/app/src/main/java/io/legado/app/ui/book/toc/rule/TxtTocRuleViewModel.kt
similarity index 93%
rename from app/src/main/java/io/legado/app/ui/book/import/local/rule/TxtTocRuleViewModel.kt
rename to app/src/main/java/io/legado/app/ui/book/toc/rule/TxtTocRuleViewModel.kt
index edc29a395..e8cff3b72 100644
--- a/app/src/main/java/io/legado/app/ui/book/import/local/rule/TxtTocRuleViewModel.kt
+++ b/app/src/main/java/io/legado/app/ui/book/toc/rule/TxtTocRuleViewModel.kt
@@ -1,4 +1,4 @@
-package io.legado.app.ui.book.import.local.rule
+package io.legado.app.ui.book.toc.rule
import android.app.Application
import io.legado.app.base.BaseViewModel
@@ -15,6 +15,9 @@ class TxtTocRuleViewModel(app: Application) : BaseViewModel(app) {
fun save(txtTocRule: TxtTocRule) {
execute {
+ if (txtTocRule.serialNumber < 0) {
+ txtTocRule.serialNumber = appDb.txtTocRuleDao.maxOrder + 1
+ }
appDb.txtTocRuleDao.insert(txtTocRule)
}
}