pull/48/head
kunfei 5 years ago
parent 6149fbfdc9
commit 07fe3e027c
  1. 100
      app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt
  2. 4
      app/src/main/res/values/strings.xml

@ -159,88 +159,72 @@ class BookSourceEditActivity :
sourceEntities.apply { sourceEntities.apply {
add(EditEntity("bookSourceUrl", source?.bookSourceUrl, R.string.book_source_url)) add(EditEntity("bookSourceUrl", source?.bookSourceUrl, R.string.book_source_url))
add(EditEntity("bookSourceName", source?.bookSourceName, R.string.book_source_name)) add(EditEntity("bookSourceName", source?.bookSourceName, R.string.book_source_name))
add( add(EditEntity("bookSourceGroup", source?.bookSourceGroup, R.string.book_source_group))
EditEntity(
"bookSourceGroup",
source?.bookSourceGroup,
R.string.book_source_group
)
)
add(EditEntity("loginUrl", source?.loginUrl, R.string.book_source_login_url)) add(EditEntity("loginUrl", source?.loginUrl, R.string.book_source_login_url))
add(EditEntity("bookUrlPattern", source?.bookUrlPattern, R.string.book_url_pattern)) add(EditEntity("bookUrlPattern", source?.bookUrlPattern, R.string.book_url_pattern))
add(EditEntity("header", source?.header, R.string.source_http_header)) add(EditEntity("header", source?.header, R.string.source_http_header))
} }
//搜索 //搜索
(source?.getSearchRule()).let { searchRule -> val sr = source?.getSearchRule()
searchEntities.clear() searchEntities.clear()
searchEntities.apply { searchEntities.apply {
add(EditEntity("searchUrl", source?.searchUrl, R.string.rule_search_url)) add(EditEntity("searchUrl", source?.searchUrl, R.string.rule_search_url))
add(EditEntity("bookList", searchRule?.bookList, R.string.rule_book_list)) add(EditEntity("bookList", sr?.bookList, R.string.rule_book_list))
add(EditEntity("name", searchRule?.name, R.string.rule_book_name)) add(EditEntity("name", sr?.name, R.string.rule_book_name))
add(EditEntity("author", searchRule?.author, R.string.rule_book_author)) add(EditEntity("author", sr?.author, R.string.rule_book_author))
add(EditEntity("kind", searchRule?.kind, R.string.rule_book_kind)) add(EditEntity("kind", sr?.kind, R.string.rule_book_kind))
add(EditEntity("wordCount", searchRule?.wordCount, R.string.rule_word_count)) add(EditEntity("wordCount", sr?.wordCount, R.string.rule_word_count))
add(EditEntity("lastChapter", searchRule?.lastChapter, R.string.rule_last_chapter)) add(EditEntity("lastChapter", sr?.lastChapter, R.string.rule_last_chapter))
add(EditEntity("intro", searchRule?.intro, R.string.rule_book_intro)) add(EditEntity("intro", sr?.intro, R.string.rule_book_intro))
add(EditEntity("coverUrl", searchRule?.coverUrl, R.string.rule_cover_url)) add(EditEntity("coverUrl", sr?.coverUrl, R.string.rule_cover_url))
add(EditEntity("bookUrl", searchRule?.bookUrl, R.string.rule_book_url)) add(EditEntity("bookUrl", sr?.bookUrl, R.string.rule_book_url))
}
} }
//详情页 //详情页
(source?.getBookInfoRule()).let { infoRule -> val ir = source?.getBookInfoRule()
infoEntities.clear() infoEntities.clear()
infoEntities.apply { infoEntities.apply {
add(EditEntity("init", infoRule?.init, R.string.rule_book_info_init)) add(EditEntity("init", ir?.init, R.string.rule_book_info_init))
add(EditEntity("name", infoRule?.name, R.string.rule_book_name)) add(EditEntity("name", ir?.name, R.string.rule_book_name))
add(EditEntity("author", infoRule?.author, R.string.rule_book_author)) add(EditEntity("author", ir?.author, R.string.rule_book_author))
add(EditEntity("kind", infoRule?.kind, R.string.rule_book_kind)) add(EditEntity("kind", ir?.kind, R.string.rule_book_kind))
add(EditEntity("wordCount", infoRule?.wordCount, R.string.rule_word_count)) add(EditEntity("wordCount", ir?.wordCount, R.string.rule_word_count))
add(EditEntity("lastChapter", infoRule?.lastChapter, R.string.rule_last_chapter)) add(EditEntity("lastChapter", ir?.lastChapter, R.string.rule_last_chapter))
add(EditEntity("intro", infoRule?.intro, R.string.rule_book_intro)) add(EditEntity("intro", ir?.intro, R.string.rule_book_intro))
add(EditEntity("coverUrl", infoRule?.coverUrl, R.string.rule_cover_url)) add(EditEntity("coverUrl", ir?.coverUrl, R.string.rule_cover_url))
add(EditEntity("tocUrl", infoRule?.tocUrl, R.string.rule_toc_url)) add(EditEntity("tocUrl", ir?.tocUrl, R.string.rule_toc_url))
}
} }
//目录页 //目录页
(source?.getTocRule()).let { tocRule -> val tr = source?.getTocRule()
tocEntities.clear() tocEntities.clear()
tocEntities.apply { tocEntities.apply {
add(EditEntity("chapterList", tocRule?.chapterList, R.string.rule_chapter_list)) add(EditEntity("chapterList", tr?.chapterList, R.string.rule_chapter_list))
add(EditEntity("chapterName", tocRule?.chapterName, R.string.rule_chapter_name)) add(EditEntity("chapterName", tr?.chapterName, R.string.rule_chapter_name))
add(EditEntity("chapterUrl", tocRule?.chapterUrl, R.string.rule_chapter_url)) add(EditEntity("chapterUrl", tr?.chapterUrl, R.string.rule_chapter_url))
add(EditEntity("nextTocUrl", tocRule?.nextTocUrl, R.string.rule_next_toc_url)) add(EditEntity("nextTocUrl", tr?.nextTocUrl, R.string.rule_next_toc_url))
}
} }
//正文页 //正文页
(source?.getContentRule()).let { contentRule -> val cr = source?.getContentRule()
contentEntities.clear() contentEntities.clear()
contentEntities.apply { contentEntities.apply {
add(EditEntity("content", contentRule?.content, R.string.rule_book_content)) add(EditEntity("content", cr?.content, R.string.rule_book_content))
add( add(EditEntity("nextContentUrl", cr?.nextContentUrl, R.string.rule_next_content))
EditEntity( add(EditEntity("webJs", cr?.webJs, R.string.rule_web_js))
"nextContentUrl", add(EditEntity("sourceRegex", cr?.sourceRegex, R.string.rule_source_regex))
contentRule?.nextContentUrl,
R.string.rule_content_url_next
)
)
} }
}
//发现 //发现
(source?.getExploreRule()).let { exploreRule -> val er = source?.getExploreRule()
findEntities.clear() findEntities.clear()
findEntities.apply { findEntities.apply {
add(EditEntity("exploreUrl", source?.exploreUrl, R.string.rule_find_url)) add(EditEntity("exploreUrl", source?.exploreUrl, R.string.rule_find_url))
add(EditEntity("bookList", exploreRule?.bookList, R.string.rule_book_list)) add(EditEntity("bookList", er?.bookList, R.string.rule_book_list))
add(EditEntity("name", exploreRule?.name, R.string.rule_book_name)) add(EditEntity("name", er?.name, R.string.rule_book_name))
add(EditEntity("author", exploreRule?.author, R.string.rule_book_author)) add(EditEntity("author", er?.author, R.string.rule_book_author))
add(EditEntity("kind", exploreRule?.kind, R.string.rule_book_kind)) add(EditEntity("kind", er?.kind, R.string.rule_book_kind))
add(EditEntity("wordCount", exploreRule?.wordCount, R.string.rule_word_count)) add(EditEntity("wordCount", er?.wordCount, R.string.rule_word_count))
add(EditEntity("lastChapter", exploreRule?.lastChapter, R.string.rule_last_chapter)) add(EditEntity("lastChapter", er?.lastChapter, R.string.rule_last_chapter))
add(EditEntity("intro", exploreRule?.intro, R.string.rule_book_intro)) add(EditEntity("intro", er?.intro, R.string.rule_book_intro))
add(EditEntity("coverUrl", exploreRule?.coverUrl, R.string.rule_cover_url)) add(EditEntity("coverUrl", er?.coverUrl, R.string.rule_cover_url))
add(EditEntity("bookUrl", exploreRule?.bookUrl, R.string.rule_book_url)) add(EditEntity("bookUrl", er?.bookUrl, R.string.rule_book_url))
}
} }
setEditEntities(0) setEditEntities(0)
} }
@ -321,6 +305,8 @@ class BookSourceEditActivity :
when (it.key) { when (it.key) {
"content" -> contentRule.content = it.value "content" -> contentRule.content = it.value
"nextContentUrl" -> contentRule.nextContentUrl = it.value "nextContentUrl" -> contentRule.nextContentUrl = it.value
"webJs" -> contentRule.webJs = it.value
"sourceRegex" -> contentRule.sourceRegex = it.value
} }
} }
source.ruleSearch = GSON.toJson(searchRule) source.ruleSearch = GSON.toJson(searchRule)

@ -383,7 +383,9 @@
<string name="rule_chapter_name">章节名称规则(ruleChapterName)</string> <string name="rule_chapter_name">章节名称规则(ruleChapterName)</string>
<string name="rule_chapter_url">章节URL规则(chapterUrl)</string> <string name="rule_chapter_url">章节URL规则(chapterUrl)</string>
<string name="rule_book_content">正文规则(content)</string> <string name="rule_book_content">正文规则(content)</string>
<string name="rule_content_url_next">正文下一页URL规则(nextContentUrl)</string> <string name="rule_next_content">正文下一页URL规则(nextContentUrl)</string>
<string name="rule_web_js">webJs</string>
<string name="rule_source_regex">资源正则(sourceRegex)</string>
<!--book source end--> <!--book source end-->
<!-- rss source start--> <!-- rss source start-->

Loading…
Cancel
Save