feat: 优化

pull/201/head
kunfei 5 years ago
parent f76d17f7d5
commit b32547ca92
  1. 19
      app/src/main/java/io/legado/app/constant/AppConst.kt
  2. 19
      app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt
  3. 20
      app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt

@ -41,7 +41,24 @@ object AppConst {
val keyboardToolChars: List<String> by lazy { val keyboardToolChars: List<String> by lazy {
arrayListOf( arrayListOf(
"@", "&", "|", "%", "/", ":", "[", "]", "{", "}", "<", ">", "\\", "$", "#", "!", ".", "",
"@",
"&",
"|",
"%",
"/",
":",
"[",
"]",
"{",
"}",
"<",
">",
"\\",
"$",
"#",
"!",
".",
"href", "src", "textNodes", "xpath", "json", "css", "id", "class", "tag" "href", "src", "textNodes", "xpath", "json", "css", "id", "class", "tag"
) )
} }

@ -350,7 +350,7 @@ class BookSourceEditActivity :
return true return true
} }
override fun sendText(text: String) { private fun insertText(text: String) {
if (text.isBlank()) return if (text.isBlank()) return
val view = window.decorView.findFocus() val view = window.decorView.findFocus()
if (view is EditText) { if (view is EditText) {
@ -365,6 +365,23 @@ class BookSourceEditActivity :
} }
} }
override fun sendText(text: String) {
if (text == AppConst.keyboardToolChars[0]) {
insertText(
"""
,{
"charset": "",
"method": "POST",
"body": "",
"headers": "{"User-Agent": ""}"
}
""".trimIndent()
)
} else {
insertText(text)
}
}
private fun showKeyboardTopPopupWindow() { private fun showKeyboardTopPopupWindow() {
mSoftKeyboardTool?.let { mSoftKeyboardTool?.let {
if (it.isShowing) return if (it.isShowing) return

@ -183,7 +183,7 @@ class RssSourceEditActivity :
return true return true
} }
override fun sendText(text: String) { private fun insertText(text: String) {
if (text.isBlank()) return if (text.isBlank()) return
val view = window.decorView.findFocus() val view = window.decorView.findFocus()
if (view is EditText) { if (view is EditText) {
@ -198,6 +198,24 @@ class RssSourceEditActivity :
} }
} }
override fun sendText(text: String) {
if (text == AppConst.keyboardToolChars[0]) {
insertText(
"""
,{
"charset": "",
"method": "POST",
"body": "",
"headers": "{"User-Agent": ""}"
}
""".trimIndent()
)
} else {
insertText(text)
}
}
private fun showKeyboardTopPopupWindow() { private fun showKeyboardTopPopupWindow() {
mSoftKeyboardTool?.let { mSoftKeyboardTool?.let {
if (it.isShowing) return if (it.isShowing) return

Loading…
Cancel
Save