From 5b50ee6cce88fedaf9cd3242c99ab26f6f671a6b Mon Sep 17 00:00:00 2001 From: Horis <821938089@qq.com> Date: Thu, 13 Jul 2023 11:47:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../source/edit/BookSourceEditActivity.kt | 44 ++++++++++++++++++- .../app/ui/main/explore/ExploreAdapter.kt | 4 +- .../app/ui/main/explore/ExploreFragment.kt | 8 ++++ app/src/main/res/menu/explore_item.xml | 4 ++ app/src/main/res/menu/source_edit.xml | 11 +++-- 5 files changed, 66 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt index 82223e066f5c..5bf662caa13b 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt @@ -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 { 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 { @@ -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 { + 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( diff --git a/app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt b/app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt index 8a5e110fa52f..c6dc024713bf 100644 --- a/app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt @@ -164,6 +164,7 @@ class ExploreAdapter(context: Context, val callBack: CallBack) : when (it.itemId) { R.id.menu_edit -> callBack.editSource(source.bookSourceUrl) R.id.menu_top -> callBack.toTop(source) + R.id.menu_search -> callBack.searchBook(source) R.id.menu_login -> context.startActivity { putExtra("type", "bookSource") putExtra("key", source.bookSourceUrl) @@ -188,5 +189,6 @@ class ExploreAdapter(context: Context, val callBack: CallBack) : fun editSource(sourceUrl: String) fun toTop(source: BookSource) fun deleteSource(source: BookSource) + fun searchBook(bookSource: BookSource) } -} \ No newline at end of file +} diff --git a/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt b/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt index 9ed90d32b80a..6567fffee06c 100644 --- a/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt @@ -22,6 +22,8 @@ import io.legado.app.lib.dialogs.alert import io.legado.app.lib.theme.primaryColor import io.legado.app.lib.theme.primaryTextColor import io.legado.app.ui.book.explore.ExploreShowActivity +import io.legado.app.ui.book.search.SearchActivity +import io.legado.app.ui.book.search.SearchScope import io.legado.app.ui.book.source.edit.BookSourceEditActivity import io.legado.app.ui.main.MainActivity import io.legado.app.ui.main.MainFragmentInterface @@ -214,6 +216,12 @@ class ExploreFragment() : VMBaseFragment(R.layout.fragment_exp } } + override fun searchBook(bookSource: BookSource) { + startActivity { + putExtra("searchScope", SearchScope(bookSource).toString()) + } + } + fun compressExplore() { if (!adapter.compressExplore()) { if (AppConfig.isEInkMode) { diff --git a/app/src/main/res/menu/explore_item.xml b/app/src/main/res/menu/explore_item.xml index 2b69e6063935..d73e8a3ad5be 100644 --- a/app/src/main/res/menu/explore_item.xml +++ b/app/src/main/res/menu/explore_item.xml @@ -13,6 +13,10 @@ android:id="@+id/menu_login" android:title="@string/login" /> + + diff --git a/app/src/main/res/menu/source_edit.xml b/app/src/main/res/menu/source_edit.xml index 28690ffb5ff2..7953eba23e38 100644 --- a/app/src/main/res/menu/source_edit.xml +++ b/app/src/main/res/menu/source_edit.xml @@ -1,7 +1,7 @@ - + +