From 89f4ebcecfda5b5a10f3330ce915f1a770b52101 Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Wed, 13 Apr 2022 09:59:23 +0800 Subject: [PATCH] feat:add js toast --- app/src/main/assets/help/jsHelp.md | 5 +++++ app/src/main/assets/updateLog.md | 7 ++++++- .../main/java/io/legado/app/help/JsExtensions.kt | 15 +++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/app/src/main/assets/help/jsHelp.md b/app/src/main/assets/help/jsHelp.md index 1d2ae5eaa..bbdd559ca 100644 --- a/app/src/main/assets/help/jsHelp.md +++ b/app/src/main/assets/help/jsHelp.md @@ -68,6 +68,11 @@ java.webView(html: String?, url: String?, js: String?): String java.log(msg) java.logType(var) ``` +* 弹窗提示 +``` +java.longToast(msg: Any?) +java.toast(msg: Any?) +``` * 从网络(由java.cacheFile实现)、本地导入JavaScript脚本 ``` {{java.importScript(url)}} diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index eb8d270e7..fbd1ccd18 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -11,7 +11,12 @@ * 正文出现缺字漏字、内容缺失、排版错乱等情况,有可能是净化规则或简繁转换出现问题。 * 漫画源看书显示乱码,**阅读与其他软件的源并不通用**,请导入阅读的支持的漫画源! -**2022/04/012** +**2022/04/13** + +* 修复解码正文图片报错,添加解码日志 +* js文档:java.toast java.longToast + +**2022/04/12** * 更新cronet: 100.0.4896.88 * 恢复epub加载方式 diff --git a/app/src/main/java/io/legado/app/help/JsExtensions.kt b/app/src/main/java/io/legado/app/help/JsExtensions.kt index 0e548a43b..4c9cf31fe 100644 --- a/app/src/main/java/io/legado/app/help/JsExtensions.kt +++ b/app/src/main/java/io/legado/app/help/JsExtensions.kt @@ -34,6 +34,7 @@ import java.util.zip.ZipInputStream /** * js扩展类, 在js中通过java变量调用 + * 添加方法,请更新文档/legado/app/src/main/assets/help/JsHelp.md * 所有对于文件的读写删操作都是相对路径,只能操作阅读缓存内的文件 * /android/data/{package}/cache/... */ @@ -526,6 +527,20 @@ interface JsExtensions { return contentArray.joinToString("") } + /** + * 弹窗提示 + */ + fun toast(msg: Any?) { + appCtx.toastOnUi(msg.toString()) + } + + /** + * 弹窗提示 停留时间较长 + */ + fun longToast(msg: Any?) { + appCtx.longToastOnUi(msg.toString()) + } + /** * 输出调试日志 */