|
|
@ -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,31 +963,41 @@ class ReadBookActivity : BaseReadBookActivity(), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun payAction() { |
|
|
|
override fun payAction() { |
|
|
|
Coroutine.async(this) { |
|
|
|
ReadBook.book?.let { book -> |
|
|
|
val book = ReadBook.book ?: throw NoStackTraceException("no book") |
|
|
|
if (book.isLocalBook()) return |
|
|
|
val chapter = appDb.bookChapterDao.getChapter(book.bookUrl, ReadBook.durChapterIndex) |
|
|
|
val chapter = appDb.bookChapterDao.getChapter(book.bookUrl, ReadBook.durChapterIndex) |
|
|
|
?: throw NoStackTraceException("no chapter") |
|
|
|
if (chapter == null) { |
|
|
|
val source = ReadBook.bookSource ?: throw NoStackTraceException("no book source") |
|
|
|
toastOnUi("no chapter") |
|
|
|
val payAction = source.getContentRule().payAction |
|
|
|
return |
|
|
|
if (payAction.isNullOrEmpty()) { |
|
|
|
} |
|
|
|
throw NoStackTraceException("no pay action") |
|
|
|
alert(R.string.chapter_pay) { |
|
|
|
} |
|
|
|
setMessage(chapter.title) |
|
|
|
JsUtils.evalJs(payAction) { |
|
|
|
yesButton { |
|
|
|
it["java"] = source |
|
|
|
Coroutine.async { |
|
|
|
it["source"] = source |
|
|
|
val source = ReadBook.bookSource ?: throw NoStackTraceException("no book source") |
|
|
|
it["book"] = book |
|
|
|
val payAction = source.getContentRule().payAction |
|
|
|
it["chapter"] = chapter |
|
|
|
if (payAction.isNullOrEmpty()) { |
|
|
|
} |
|
|
|
throw NoStackTraceException("no pay action") |
|
|
|
}.onSuccess { |
|
|
|
} |
|
|
|
if (it.isNotBlank()) { |
|
|
|
val analyzeRule = AnalyzeRule(book, source) |
|
|
|
startActivity<WebViewActivity> { |
|
|
|
analyzeRule.setBaseUrl(chapter.url) |
|
|
|
putExtra("title", getString(R.string.chapter_pay)) |
|
|
|
analyzeRule.chapter = chapter |
|
|
|
putExtra("url", it) |
|
|
|
analyzeRule.evalJS(payAction).toString() |
|
|
|
IntentData.put(it, ReadBook.bookSource?.getHeaderMap(true)) |
|
|
|
}.onSuccess { |
|
|
|
|
|
|
|
if (it.isNotBlank()) { |
|
|
|
|
|
|
|
startActivity<WebViewActivity> { |
|
|
|
|
|
|
|
putExtra("title", R.string.chapter_pay) |
|
|
|
|
|
|
|
putExtra("url", it) |
|
|
|
|
|
|
|
IntentData.put(it, ReadBook.bookSource?.getHeaderMap(true)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}.onError { |
|
|
|
|
|
|
|
AppLog.putDebug(it.localizedMessage) |
|
|
|
|
|
|
|
toastOnUi(it.localizedMessage) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
noButton() |
|
|
|
} |
|
|
|
} |
|
|
|
}.onError { |
|
|
|
|
|
|
|
toastOnUi(it.localizedMessage) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|