6.7.0 - Alpha - android.graphics.Paint#setColor 支持正常解析 ColorInt/ColorHex/ColorName 等颜色参数
This commit is contained in:
12
app/src/main/java/org/autojs/autojs/core/image/RhinoPaint.kt
Normal file
12
app/src/main/java/org/autojs/autojs/core/image/RhinoPaint.kt
Normal file
@@ -0,0 +1,12 @@
|
||||
package org.autojs.autojs.core.image
|
||||
|
||||
import android.graphics.Paint
|
||||
import org.autojs.autojs.runtime.api.augment.colors.Colors
|
||||
|
||||
class RhinoPaint(paint: Paint) : Paint(paint) {
|
||||
|
||||
override fun setColor(color: Long) = setColor(Colors.toIntRhino(color))
|
||||
|
||||
fun setColor(color: Any?) = setColor(Colors.toIntRhino(color))
|
||||
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package org.autojs.autojs.engine
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.graphics.Paint
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import org.autojs.autojs.core.image.RhinoPaint
|
||||
import org.autojs.autojs.core.ui.ViewExtras
|
||||
import org.autojs.autojs.engine.module.AssetAndUrlModuleSourceProvider
|
||||
import org.autojs.autojs.extension.AnyExtensions.isJsNullish
|
||||
@@ -207,6 +209,7 @@ open class RhinoJavaScriptEngine(private val scriptRuntime: ScriptRuntime, priva
|
||||
override fun wrapAsJavaObject(cx: Context?, scope: Scriptable, javaObject: Any?, staticType: Class<*>?): Scriptable? {
|
||||
return when (javaObject) {
|
||||
is View -> ViewExtras.getNativeView(scope, /* view = */ javaObject, staticType, runtime)
|
||||
is Paint -> super.wrapAsJavaObject(cx, scope, RhinoPaint(javaObject), staticType)
|
||||
else -> super.wrapAsJavaObject(cx, scope, javaObject, staticType)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user