优化payAction

pull/2213/head
Odomu 3 years ago
parent 0aa493f57c
commit 28b85e45c2
  1. 3
      app/src/main/assets/help/ruleHelp.md
  2. 18
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  3. 1
      app/src/main/res/values-es-rES/strings.xml
  4. 1
      app/src/main/res/values-ja-rJP/strings.xml
  5. 1
      app/src/main/res/values-pt-rBR/strings.xml
  6. 1
      app/src/main/res/values-zh-rHK/strings.xml
  7. 1
      app/src/main/res/values-zh/strings.xml
  8. 1
      app/src/main/res/values/strings.xml

@ -152,5 +152,4 @@ let options = {
``` ```
* 购买操作 * 购买操作
> 返回购买链接,可直接填写链接或者JavaScript > 返回购买链接(自动打开浏览器),可直接填写链接或者JavaScript
> 可用变量 book chapter java(不支持AnalyzeRule函数) source

@ -36,6 +36,7 @@ import io.legado.app.lib.dialogs.selector
import io.legado.app.lib.theme.accentColor import io.legado.app.lib.theme.accentColor
import io.legado.app.model.ReadAloud import io.legado.app.model.ReadAloud
import io.legado.app.model.ReadBook import io.legado.app.model.ReadBook
import io.legado.app.model.analyzeRule.AnalyzeRule
import io.legado.app.receiver.TimeBatteryReceiver import io.legado.app.receiver.TimeBatteryReceiver
import io.legado.app.service.BaseReadAloudService import io.legado.app.service.BaseReadAloudService
import io.legado.app.ui.about.AppLogDialog import io.legado.app.ui.about.AppLogDialog
@ -962,7 +963,6 @@ class ReadBookActivity : BaseReadBookActivity(),
} }
override fun payAction() { override fun payAction() {
Coroutine.async(this) {
val book = ReadBook.book ?: throw NoStackTraceException("no book") val book = ReadBook.book ?: throw NoStackTraceException("no book")
val chapter = appDb.bookChapterDao.getChapter(book.bookUrl, ReadBook.durChapterIndex) val chapter = appDb.bookChapterDao.getChapter(book.bookUrl, ReadBook.durChapterIndex)
?: throw NoStackTraceException("no chapter") ?: throw NoStackTraceException("no chapter")
@ -971,12 +971,13 @@ class ReadBookActivity : BaseReadBookActivity(),
if (payAction.isNullOrEmpty()) { if (payAction.isNullOrEmpty()) {
throw NoStackTraceException("no pay action") throw NoStackTraceException("no pay action")
} }
JsUtils.evalJs(payAction) { alert(R.string.pay_chapter) {
it["java"] = source setMessage(chapter.title)
it["source"] = source yesButton {
it["book"] = book Coroutine.async {
it["chapter"] = chapter val analyzeRule = AnalyzeRule(book, source).setBaseUrl(chapter.url)
} analyzeRule.chapter = chapter
analyzeRule.evalJS(payAction).toString()
}.onSuccess { }.onSuccess {
if (it.isNotBlank()) { if (it.isNotBlank()) {
startActivity<WebViewActivity> { startActivity<WebViewActivity> {
@ -989,6 +990,9 @@ class ReadBookActivity : BaseReadBookActivity(),
toastOnUi(it.localizedMessage) toastOnUi(it.localizedMessage)
} }
} }
noButton()
}
}
/** /**
* 朗读按钮 * 朗读按钮

@ -1010,4 +1010,5 @@
<string name="check_selected_interval">选中所选区间</string> <string name="check_selected_interval">选中所选区间</string>
<string name="show_add_to_shelf_alert_title">返回时提示放入书架</string> <string name="show_add_to_shelf_alert_title">返回时提示放入书架</string>
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string> <string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
<string name="pay_chapter">购买章节</string>
</resources> </resources>

@ -1013,4 +1013,5 @@
<string name="check_selected_interval">选中所选区间</string> <string name="check_selected_interval">选中所选区间</string>
<string name="show_add_to_shelf_alert_title">返回时提示放入书架</string> <string name="show_add_to_shelf_alert_title">返回时提示放入书架</string>
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string> <string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
<string name="pay_chapter">购买章节</string>
</resources> </resources>

@ -1013,4 +1013,5 @@
<string name="check_selected_interval">选中所选区间</string> <string name="check_selected_interval">选中所选区间</string>
<string name="show_add_to_shelf_alert_title">返回时提示放入书架</string> <string name="show_add_to_shelf_alert_title">返回时提示放入书架</string>
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string> <string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
<string name="pay_chapter">购买章节</string>
</resources> </resources>

@ -1010,4 +1010,5 @@
<string name="check_selected_interval">选中所选区间</string> <string name="check_selected_interval">选中所选区间</string>
<string name="show_add_to_shelf_alert_title">返回时提示放入书架</string> <string name="show_add_to_shelf_alert_title">返回时提示放入书架</string>
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string> <string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
<string name="pay_chapter">购买章节</string>
</resources> </resources>

@ -1012,4 +1012,5 @@
<string name="check_selected_interval">选中所选区间</string> <string name="check_selected_interval">选中所选区间</string>
<string name="show_add_to_shelf_alert_title">返回时提示放入书架</string> <string name="show_add_to_shelf_alert_title">返回时提示放入书架</string>
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string> <string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
<string name="pay_chapter">购买章节</string>
</resources> </resources>

@ -1013,4 +1013,5 @@
<string name="check_selected_interval">选中所选区间</string> <string name="check_selected_interval">选中所选区间</string>
<string name="show_add_to_shelf_alert_title">返回时提示放入书架</string> <string name="show_add_to_shelf_alert_title">返回时提示放入书架</string>
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string> <string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
<string name="pay_chapter">购买章节</string>
</resources> </resources>

Loading…
Cancel
Save