添加帮助文档;减少代码
This commit is contained in:
@@ -77,7 +77,7 @@ class BookSourceEditActivity :
|
||||
override fun onPostCreate(savedInstanceState: Bundle?) {
|
||||
super.onPostCreate(savedInstanceState)
|
||||
if (!LocalConfig.ruleHelpVersionIsLast) {
|
||||
showRuleHelp()
|
||||
showHelp("ruleHelp")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ class BookSourceEditActivity :
|
||||
getString(R.string.share_book_source),
|
||||
ErrorCorrectionLevel.L
|
||||
)
|
||||
R.id.menu_help -> showRuleHelp()
|
||||
R.id.menu_help -> showHelp("ruleHelp")
|
||||
R.id.menu_login -> getSource().let { source ->
|
||||
if (checkSource(source)) {
|
||||
viewModel.save(source) {
|
||||
@@ -420,26 +420,23 @@ class BookSourceEditActivity :
|
||||
}
|
||||
|
||||
private fun showHelpDialog() {
|
||||
val items = arrayListOf("插入URL参数", "书源教程", "正则教程", "选择文件")
|
||||
val items = arrayListOf("插入URL参数", "书源教程", "js教程", "正则教程", "选择文件")
|
||||
selector(getString(R.string.help), items) { _, index ->
|
||||
when (index) {
|
||||
0 -> insertText(AppConst.urlOption)
|
||||
1 -> showRuleHelp()
|
||||
2 -> showRegexHelp()
|
||||
3 -> selectDoc.launch {
|
||||
1 -> showHelp("ruleHelp")
|
||||
2 -> showHelp("jsHelp")
|
||||
3 -> showHelp("regexHelp")
|
||||
4 -> selectDoc.launch {
|
||||
mode = HandleFileContract.FILE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showRuleHelp() {
|
||||
val mdText = String(assets.open("help/ruleHelp.md").readBytes())
|
||||
showDialogFragment(TextDialog(mdText, TextDialog.Mode.MD))
|
||||
}
|
||||
|
||||
private fun showRegexHelp() {
|
||||
val mdText = String(assets.open("help/regexHelp.md").readBytes())
|
||||
private fun showHelp(fileName: String) {
|
||||
//显示目录help下的帮助文档
|
||||
val mdText = String(assets.open("help/${fileName}.md").readBytes())
|
||||
showDialogFragment(TextDialog(mdText, TextDialog.Mode.MD))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user