6.7.0 - Alpha18 - 修复 dialogs.build 方法 "linkify" 选项功能失效的问题
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$data": {
|
"$data": {
|
||||||
"v6.7.0": {
|
"v6.7.0": {
|
||||||
"released_date": "2026/01/22",
|
"released_date": "2026/01/24",
|
||||||
"feature": [
|
"feature": [
|
||||||
"插件中心功能, 支持插件的安装/卸载/更新等操作 (入口: 主页抽屉按钮/主页标签页)",
|
"插件中心功能, 支持插件的安装/卸载/更新等操作 (入口: 主页抽屉按钮/主页标签页)",
|
||||||
"Paddle OCR (PP-OCRv5) 插件, 用于光学字符识别",
|
"Paddle OCR (PP-OCRv5) 插件, 用于光学字符识别",
|
||||||
@@ -61,6 +61,7 @@
|
|||||||
"无法使用 console/toast 等方法显示 BigInt 数据类型的问题",
|
"无法使用 console/toast 等方法显示 BigInt 数据类型的问题",
|
||||||
"部分全局对象可能丢失 JavaScript 原型属性及方法的问题",
|
"部分全局对象可能丢失 JavaScript 原型属性及方法的问题",
|
||||||
"使用 XML 语法将 JavaScript 表达式作为属性值时, this 对象可能出现指向错误的问题",
|
"使用 XML 语法将 JavaScript 表达式作为属性值时, this 对象可能出现指向错误的问题",
|
||||||
|
"dialogs.build 方法 linkify 选项参数功能失效的问题",
|
||||||
"dialogs.build 方法无法使用 MaterialDialog.Builder 原生选项参数的问题",
|
"dialogs.build 方法无法使用 MaterialDialog.Builder 原生选项参数的问题",
|
||||||
"dialogs.build 方法可能破坏对象参数原有数据的问题",
|
"dialogs.build 方法可能破坏对象参数原有数据的问题",
|
||||||
"canvas 元素控件 setMaxFps 方法内部帧率计算错误",
|
"canvas 元素控件 setMaxFps 方法内部帧率计算错误",
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ import org.autojs.autojs.util.RhinoUtils.isUiThread
|
|||||||
import org.autojs.autojs.util.RhinoUtils.js_eval
|
import org.autojs.autojs.util.RhinoUtils.js_eval
|
||||||
import org.autojs.autojs.util.RhinoUtils.newBaseFunction
|
import org.autojs.autojs.util.RhinoUtils.newBaseFunction
|
||||||
import org.autojs.autojs.util.RhinoUtils.newNativeObject
|
import org.autojs.autojs.util.RhinoUtils.newNativeObject
|
||||||
import org.autojs.autojs.util.StringUtils.uppercaseFirstChar
|
import org.autojs.autojs.util.StringUtils.looseMatches
|
||||||
import org.autojs.autojs6.R
|
import org.autojs.autojs6.R
|
||||||
import org.mozilla.javascript.BaseFunction
|
import org.mozilla.javascript.BaseFunction
|
||||||
import org.mozilla.javascript.Context
|
import org.mozilla.javascript.Context
|
||||||
@@ -93,9 +93,36 @@ class Dialogs(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime) {
|
|||||||
"alwaysCallMultiChoiceCallback" to PropertyConverter.BOOLEAN,
|
"alwaysCallMultiChoiceCallback" to PropertyConverter.BOOLEAN,
|
||||||
)
|
)
|
||||||
|
|
||||||
private val presetLinkifyMasks = listOf("all", "emailAddresses", "mapAddresses", "phoneNumbers", "webUrls")
|
@Suppress("DEPRECATION")
|
||||||
|
private val linkifyMasksMappings = listOf(
|
||||||
|
"webUrls" to Linkify.WEB_URLS,
|
||||||
|
"web" to Linkify.WEB_URLS,
|
||||||
|
"url" to Linkify.WEB_URLS,
|
||||||
|
"urls" to Linkify.WEB_URLS,
|
||||||
|
|
||||||
private val presetAnimations = listOf("default", "activity", "dialog", "inputMethod", "toast", "translucent")
|
"emailAddresses" to Linkify.EMAIL_ADDRESSES,
|
||||||
|
"email" to Linkify.EMAIL_ADDRESSES,
|
||||||
|
|
||||||
|
"phoneNumbers" to Linkify.PHONE_NUMBERS,
|
||||||
|
"phone" to Linkify.PHONE_NUMBERS,
|
||||||
|
"tel" to Linkify.PHONE_NUMBERS,
|
||||||
|
|
||||||
|
"mapAddresses" to Linkify.MAP_ADDRESSES,
|
||||||
|
"addresses" to Linkify.MAP_ADDRESSES,
|
||||||
|
"address" to Linkify.MAP_ADDRESSES,
|
||||||
|
"street" to Linkify.MAP_ADDRESSES,
|
||||||
|
|
||||||
|
"all" to Linkify.ALL,
|
||||||
|
)
|
||||||
|
|
||||||
|
private val animationMappings = listOf(
|
||||||
|
"default" to android.R.style.Animation,
|
||||||
|
"activity" to android.R.style.Animation_Activity,
|
||||||
|
"dialog" to android.R.style.Animation_Dialog,
|
||||||
|
"inputMethod" to android.R.style.Animation_InputMethod,
|
||||||
|
"toast" to android.R.style.Animation_Toast,
|
||||||
|
"translucent" to android.R.style.Animation_Translucent,
|
||||||
|
)
|
||||||
|
|
||||||
private val customJsPropertiesForBuild: Set<String> = setOf(
|
private val customJsPropertiesForBuild: Set<String> = setOf(
|
||||||
"animation",
|
"animation",
|
||||||
@@ -606,18 +633,19 @@ class Dialogs(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun applyBuiltDialogProperties(scriptRuntime: ScriptRuntime, dialog: JsDialog, properties: NativeObject) {
|
private fun applyBuiltDialogProperties(scriptRuntime: ScriptRuntime, dialog: JsDialog, properties: NativeObject) {
|
||||||
if (!properties.prop("linkify").isJsString() && Context.toBoolean(properties.prop("linkify"))) {
|
if (!properties.prop("linkify").isJsNullish() && Context.toBoolean(properties.prop("linkify"))) {
|
||||||
|
val linkifyRaw = when (properties.prop("linkify")) {
|
||||||
|
true -> "all"
|
||||||
|
else -> properties.inquire("linkify", transformer = ::coerceString)
|
||||||
|
}
|
||||||
val autoLinkMask = run {
|
val autoLinkMask = run {
|
||||||
var linkify = when (properties.prop("linkify")) {
|
linkifyRaw?.let {
|
||||||
true -> "all"
|
linkifyMasksMappings.firstOrNull {
|
||||||
else -> properties.inquire("linkify", ::coerceString, "all")
|
it.first.looseMatches(linkifyRaw)
|
||||||
}
|
}?.second
|
||||||
if (presetLinkifyMasks.contains(linkify)) {
|
} ?: throw IllegalArgumentException(
|
||||||
linkify = linkify.replace(Regex("[A-Z]"), "_$&").uppercase()
|
"Unknown property linkify ${linkifyRaw.jsBrief()} of argument properties for dialogs.build",
|
||||||
}
|
)
|
||||||
runCatching { Linkify::class.java.getDeclaredField(linkify).get(null) }.getOrElse { e ->
|
|
||||||
throw IllegalArgumentException("Unknown property linkify ${linkify.jsBrief()} of argument properties for dialogs.build", e)
|
|
||||||
}.let(::coerceIntNumber)
|
|
||||||
}
|
}
|
||||||
dialog.contentView?.let { view ->
|
dialog.contentView?.let { view ->
|
||||||
val text = view.text
|
val text = view.text
|
||||||
@@ -742,20 +770,18 @@ class Dialogs(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime) {
|
|||||||
// # }
|
// # }
|
||||||
|
|
||||||
if (!properties.prop("animation").isJsNullish() && Context.toBoolean(properties.prop("animation"))) {
|
if (!properties.prop("animation").isJsNullish() && Context.toBoolean(properties.prop("animation"))) {
|
||||||
val animation = when (properties.prop("animation")) {
|
val animationRaw = when (properties.prop("animation")) {
|
||||||
true -> "default"
|
true -> "default"
|
||||||
else -> properties.inquire("animation", ::coerceString, "default")
|
else -> properties.inquire("animation", ::coerceString, "default")
|
||||||
}
|
}
|
||||||
require(presetAnimations.contains(animation)) { "Unknown linkify: $animation" }
|
val animationStyle = animationMappings.firstOrNull {
|
||||||
|
it.first.looseMatches(animationRaw)
|
||||||
|
}?.second ?: throw IllegalArgumentException(
|
||||||
|
"Unknown property animation ${animationRaw.jsBrief()} of argument properties for dialogs.build",
|
||||||
|
)
|
||||||
dialog.window?.let { win ->
|
dialog.window?.let { win ->
|
||||||
UI.postRhinoRuntime(scriptRuntime, newBaseFunction("action", {
|
UI.postRhinoRuntime(scriptRuntime, newBaseFunction("action", {
|
||||||
if (animation == "default") {
|
win.setWindowAnimations(animationStyle)
|
||||||
win.setWindowAnimations(android.R.style.Animation)
|
|
||||||
} else {
|
|
||||||
val suffix = animation.replace('-', '_').uppercaseFirstChar()
|
|
||||||
val animationStyle = android.R.style::class.java.getDeclaredField("Animation_$suffix").getInt(null)
|
|
||||||
win.setWindowAnimations(animationStyle)
|
|
||||||
}
|
|
||||||
}, NOT_CONSTRUCTABLE))
|
}, NOT_CONSTRUCTABLE))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user