|
|
@@ -28,6 +28,8 @@ import io.legado.app.lib.dialogs.selector
|
|
|
import io.legado.app.lib.theme.accentColor
|
|
|
import io.legado.app.lib.theme.backgroundColor
|
|
|
import io.legado.app.lib.theme.primaryColor
|
|
|
+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.file.HandleFileContract
|
|
|
import io.legado.app.ui.login.SourceLoginActivity
|
|
|
@@ -119,11 +121,13 @@ class BookSourceEditActivity :
|
|
|
setResult(Activity.RESULT_OK)
|
|
|
finish()
|
|
|
}
|
|
|
+
|
|
|
R.id.menu_debug_source -> viewModel.save(getSource()) { source ->
|
|
|
startActivity<BookSourceDebugActivity> {
|
|
|
putExtra("key", source.bookSourceUrl)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
R.id.menu_clear_cookie -> viewModel.clearCookie(getSource().bookSourceUrl)
|
|
|
R.id.menu_auto_complete -> viewModel.autoComplete = !viewModel.autoComplete
|
|
|
R.id.menu_copy_source -> sendToClip(GSON.toJson(getSource()))
|
|
|
@@ -135,6 +139,7 @@ class BookSourceEditActivity :
|
|
|
getString(R.string.share_book_source),
|
|
|
ErrorCorrectionLevel.L
|
|
|
)
|
|
|
+
|
|
|
R.id.menu_help -> showHelp("ruleHelp")
|
|
|
R.id.menu_login -> viewModel.save(getSource()) { source ->
|
|
|
startActivity<SourceLoginActivity> {
|
|
|
@@ -142,7 +147,14 @@ class BookSourceEditActivity :
|
|
|
putExtra("key", source.bookSourceUrl)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
R.id.menu_set_source_variable -> setSourceVariable()
|
|
|
+ R.id.menu_search -> viewModel.save(getSource()) { source ->
|
|
|
+ startActivity<SearchActivity> {
|
|
|
+ putExtra("searchScope", SearchScope(source).toString())
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
return super.onCompatOptionsItemSelected(item)
|
|
|
}
|
|
|
@@ -387,20 +399,28 @@ class BookSourceEditActivity :
|
|
|
"bookList" -> searchRule.bookList = it.value
|
|
|
"name" -> searchRule.name =
|
|
|
viewModel.ruleComplete(it.value, searchRule.bookList)
|
|
|
+
|
|
|
"author" -> searchRule.author =
|
|
|
viewModel.ruleComplete(it.value, searchRule.bookList)
|
|
|
+
|
|
|
"kind" -> searchRule.kind =
|
|
|
viewModel.ruleComplete(it.value, searchRule.bookList)
|
|
|
+
|
|
|
"intro" -> searchRule.intro =
|
|
|
viewModel.ruleComplete(it.value, searchRule.bookList)
|
|
|
+
|
|
|
"updateTime" -> searchRule.updateTime =
|
|
|
viewModel.ruleComplete(it.value, searchRule.bookList)
|
|
|
+
|
|
|
"wordCount" -> searchRule.wordCount =
|
|
|
viewModel.ruleComplete(it.value, searchRule.bookList)
|
|
|
+
|
|
|
"lastChapter" -> searchRule.lastChapter =
|
|
|
viewModel.ruleComplete(it.value, searchRule.bookList)
|
|
|
+
|
|
|
"coverUrl" -> searchRule.coverUrl =
|
|
|
viewModel.ruleComplete(it.value, searchRule.bookList, 3)
|
|
|
+
|
|
|
"bookUrl" -> searchRule.bookUrl =
|
|
|
viewModel.ruleComplete(it.value, searchRule.bookList, 2)
|
|
|
}
|
|
|
@@ -411,20 +431,28 @@ class BookSourceEditActivity :
|
|
|
"bookList" -> exploreRule.bookList = it.value
|
|
|
"name" -> exploreRule.name =
|
|
|
viewModel.ruleComplete(it.value, exploreRule.bookList)
|
|
|
+
|
|
|
"author" -> exploreRule.author =
|
|
|
viewModel.ruleComplete(it.value, exploreRule.bookList)
|
|
|
+
|
|
|
"kind" -> exploreRule.kind =
|
|
|
viewModel.ruleComplete(it.value, exploreRule.bookList)
|
|
|
+
|
|
|
"intro" -> exploreRule.intro =
|
|
|
viewModel.ruleComplete(it.value, exploreRule.bookList)
|
|
|
+
|
|
|
"updateTime" -> exploreRule.updateTime =
|
|
|
viewModel.ruleComplete(it.value, exploreRule.bookList)
|
|
|
+
|
|
|
"wordCount" -> exploreRule.wordCount =
|
|
|
viewModel.ruleComplete(it.value, exploreRule.bookList)
|
|
|
+
|
|
|
"lastChapter" -> exploreRule.lastChapter =
|
|
|
viewModel.ruleComplete(it.value, exploreRule.bookList)
|
|
|
+
|
|
|
"coverUrl" -> exploreRule.coverUrl =
|
|
|
viewModel.ruleComplete(it.value, exploreRule.bookList, 3)
|
|
|
+
|
|
|
"bookUrl" -> exploreRule.bookUrl =
|
|
|
viewModel.ruleComplete(it.value, exploreRule.bookList, 2)
|
|
|
}
|
|
|
@@ -435,20 +463,28 @@ class BookSourceEditActivity :
|
|
|
"name" -> bookInfoRule.name = viewModel.ruleComplete(it.value, bookInfoRule.init)
|
|
|
"author" -> bookInfoRule.author =
|
|
|
viewModel.ruleComplete(it.value, bookInfoRule.init)
|
|
|
+
|
|
|
"kind" -> bookInfoRule.kind =
|
|
|
viewModel.ruleComplete(it.value, bookInfoRule.init)
|
|
|
+
|
|
|
"intro" -> bookInfoRule.intro =
|
|
|
viewModel.ruleComplete(it.value, bookInfoRule.init)
|
|
|
+
|
|
|
"updateTime" -> bookInfoRule.updateTime =
|
|
|
viewModel.ruleComplete(it.value, bookInfoRule.init)
|
|
|
+
|
|
|
"wordCount" -> bookInfoRule.wordCount =
|
|
|
viewModel.ruleComplete(it.value, bookInfoRule.init)
|
|
|
+
|
|
|
"lastChapter" -> bookInfoRule.lastChapter =
|
|
|
viewModel.ruleComplete(it.value, bookInfoRule.init)
|
|
|
+
|
|
|
"coverUrl" -> bookInfoRule.coverUrl =
|
|
|
viewModel.ruleComplete(it.value, bookInfoRule.init, 3)
|
|
|
+
|
|
|
"tocUrl" -> bookInfoRule.tocUrl =
|
|
|
viewModel.ruleComplete(it.value, bookInfoRule.init, 2)
|
|
|
+
|
|
|
"canReName" -> bookInfoRule.canReName = it.value
|
|
|
"downloadUrls" -> bookInfoRule.downloadUrls =
|
|
|
viewModel.ruleComplete(it.value, bookInfoRule.init)
|
|
|
@@ -493,12 +529,16 @@ class BookSourceEditActivity :
|
|
|
"reviewUrl" -> reviewRule.reviewUrl = it.value
|
|
|
"avatarRule" -> reviewRule.avatarRule =
|
|
|
viewModel.ruleComplete(it.value, reviewRule.reviewUrl, 3)
|
|
|
+
|
|
|
"contentRule" -> reviewRule.contentRule =
|
|
|
viewModel.ruleComplete(it.value, reviewRule.reviewUrl)
|
|
|
+
|
|
|
"postTimeRule" -> reviewRule.postTimeRule =
|
|
|
viewModel.ruleComplete(it.value, reviewRule.reviewUrl)
|
|
|
+
|
|
|
"reviewQuoteUrl" -> reviewRule.reviewQuoteUrl =
|
|
|
viewModel.ruleComplete(it.value, reviewRule.reviewUrl, 2)
|
|
|
+
|
|
|
"voteUpUrl" -> reviewRule.voteUpUrl = it.value
|
|
|
"voteDownUrl" -> reviewRule.voteDownUrl = it.value
|
|
|
"postReviewUrl" -> reviewRule.postReviewUrl = it.value
|
|
|
@@ -541,6 +581,7 @@ class BookSourceEditActivity :
|
|
|
SelectItem("插入分组", "addGroup")
|
|
|
)
|
|
|
}
|
|
|
+
|
|
|
else -> {
|
|
|
helpActions.add(
|
|
|
SelectItem("选择文件", "selectFile")
|
|
|
@@ -588,7 +629,8 @@ class BookSourceEditActivity :
|
|
|
private fun setSourceVariable() {
|
|
|
viewModel.save(getSource()) { source ->
|
|
|
launch {
|
|
|
- val comment = source.getDisplayVariableComment("源变量可在js中通过source.getVariable()获取")
|
|
|
+ val comment =
|
|
|
+ source.getDisplayVariableComment("源变量可在js中通过source.getVariable()获取")
|
|
|
val variable = withContext(IO) { source.getVariable() }
|
|
|
showDialogFragment(
|
|
|
VariableDialog(
|