6.7.0 - Alpha10 - 修复 console.build 多次调用重置问题及 (title/content)BackgroundColor 导致透明度或着色选项被覆盖问题 (issue #458)

This commit is contained in:
SuperMonster003
2025-10-31 09:58:59 +08:00
parent 6221196950
commit b8ecf3cc11
6 changed files with 85 additions and 47 deletions

View File

@@ -30,6 +30,8 @@
"floaty.window/rawWindow 方法无法接受字符串参数的问题", "floaty.window/rawWindow 方法无法接受字符串参数的问题",
"util.class[Name]/getClass[Name] 可能返回错误结果的问题", "util.class[Name]/getClass[Name] 可能返回错误结果的问题",
"threads.disposable() 返回的对象在存取数据时可能被意外装箱的问题 _[`issue #435`](http://issues.autojs6.com/435)_", "threads.disposable() 返回的对象在存取数据时可能被意外装箱的问题 _[`issue #435`](http://issues.autojs6.com/435)_",
"console.build 方法多次调用时, 日志浮动窗口样式选项未能正常重置的问题",
"console.build 方法的 (title/content)BackgroundColor 选项导致透明度或着色选项被覆盖的问题 _[`issue #458`](http://issues.autojs6.com/458)_",
"console/toast 等方法显示 Java Double 时可能丢失末尾零的问题", "console/toast 等方法显示 Java Double 时可能丢失末尾零的问题",
"无法使用 console/toast 等方法显示 BigInt 数据类型的问题", "无法使用 console/toast 等方法显示 BigInt 数据类型的问题",
"部分全局对象可能丢失 JavaScript 原型属性及方法的问题", "部分全局对象可能丢失 JavaScript 原型属性及方法的问题",

View File

@@ -12,10 +12,6 @@ import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import androidx.annotation.ColorInt import androidx.annotation.ColorInt
import androidx.core.content.res.ResourcesCompat import androidx.core.content.res.ResourcesCompat
import androidx.core.graphics.alpha
import androidx.core.graphics.blue
import androidx.core.graphics.green
import androidx.core.graphics.red
import org.autojs.autojs.runtime.api.ScreenMetrics import org.autojs.autojs.runtime.api.ScreenMetrics
import org.autojs.autojs.ui.enhancedfloaty.FloatyService import org.autojs.autojs.ui.enhancedfloaty.FloatyService
import org.autojs.autojs.ui.enhancedfloaty.ResizableExpandableFloaty.AbstractResizableExpandableFloaty import org.autojs.autojs.ui.enhancedfloaty.ResizableExpandableFloaty.AbstractResizableExpandableFloaty
@@ -26,6 +22,7 @@ import org.autojs.autojs6.R
import org.autojs.autojs6.databinding.FloatingConsoleExpandBinding import org.autojs.autojs6.databinding.FloatingConsoleExpandBinding
import org.autojs.autojs6.databinding.FloatingWindowCollapseBinding import org.autojs.autojs6.databinding.FloatingWindowCollapseBinding
import kotlin.math.roundToInt import kotlin.math.roundToInt
import androidx.core.view.isVisible
/** /**
* Created by Stardust on Apr 20, 2017. * Created by Stardust on Apr 20, 2017.
@@ -124,7 +121,7 @@ class ConsoleFloaty(private val console: ConsoleImpl) : AbstractResizableExpanda
expandedBinding.moveOrResize.let { expandedBinding.moveOrResize.let {
it.setOnClickListener { it.setOnClickListener {
mMoveCursor?.run { mMoveCursor?.run {
if (visibility == View.VISIBLE) { if (isVisible) {
visibility = View.GONE visibility = View.GONE
mResizer?.visibility = View.GONE mResizer?.visibility = View.GONE
} else { } else {
@@ -167,17 +164,18 @@ class ConsoleFloaty(private val console: ConsoleImpl) : AbstractResizableExpanda
fun getTitle(): String = mTitleText?.toString() ?: "" fun getTitle(): String = mTitleText?.toString() ?: ""
fun setTitleBackgroundColor(@ColorInt color: Int) { fun setTitleBackgroundColor(@ColorInt color: Int) {
console.configurator.titleBackgroundColor = color console.configurator.setTitleBackgroundColor(color)
titleBarView?.apply { post { setTitleViewBackgroundColor(this, color) } } titleBarView?.apply { post { setTitleViewBackgroundColor(this, console.configurator.titleBackgroundColor) } }
} }
fun setTitleBackgroundTint(tint: Int) { fun setTitleBackgroundTint(tint: Int) {
setTitleBackgroundColor(Color.argb(console.configurator.titleBackgroundColor.alpha, tint.red, tint.green, tint.blue)) console.configurator.setTitleBackgroundTint(tint)
titleBarView?.apply { post { setTitleViewBackgroundColor(this, console.configurator.titleBackgroundColor) } }
} }
fun setTitleBackgroundAlpha(alpha: Int) { fun setTitleBackgroundAlpha(alpha: Int) {
val bg = console.configurator.titleBackgroundColor console.configurator.setTitleBackgroundAlpha(alpha)
setTitleBackgroundColor(Color.argb(parseAlpha(alpha), bg.red, bg.green, bg.blue)) titleBarView?.apply { post { setTitleViewBackgroundColor(this, console.configurator.titleBackgroundColor) } }
} }
fun setTitleIconsTint(color: Int) { fun setTitleIconsTint(color: Int) {
@@ -205,11 +203,6 @@ class ConsoleFloaty(private val console: ConsoleImpl) : AbstractResizableExpanda
view.background = DrawableUtils.setDrawableColorFilterSrc(view.background, color) view.background = DrawableUtils.setDrawableColorFilterSrc(view.background, color)
} }
private fun parseAlpha(alpha: Int) = when {
alpha < 0 -> console.configurator.titleBackgroundColor.alpha
else -> alpha
}
internal fun setCloseButton(resId: Int) { internal fun setCloseButton(resId: Int) {
mCloseButton?.apply { mCloseButton?.apply {
post { setImageDrawable(ResourcesCompat.getDrawable(console.uiHandler.applicationContext.resources, resId, null)) } post { setImageDrawable(ResourcesCompat.getDrawable(console.uiHandler.applicationContext.resources, resId, null)) }

View File

@@ -388,15 +388,15 @@ open class ConsoleImpl(val uiHandler: UiHandler) : AbstractConsole() {
isShowing = true isShowing = true
configurator.title?.let { setTitle(it) } configurator.title?.let { setTitle(it) }
configurator.position?.run { setPosition(x, y, true) } configurator.position?.run { setPosition(x, y, true) }
setGravity(configurator.gravity) setGravity(getGravity())
configurator.titleTextSize?.let { setTitleTextSize(it) } configurator.titleTextSize?.let { setTitleTextSize(it) }
configurator.titleTextColor?.let { setTitleTextColor(it) } configurator.titleTextColor?.let { setTitleTextColor(it) }
setTitleBackgroundColor(configurator.titleBackgroundColor) setTitleBackgroundColor(getTitleBackgroundColor())
configurator.titleIconsTint?.let { setTitleIconsTint(it) } configurator.titleIconsTint?.let { setTitleIconsTint(it) }
configurator.contentTextSize?.let { setContentTextSize(it) } configurator.contentTextSize?.let { setContentTextSize(it) }
configurator.contentTextColors?.let { setContentTextColors(it) } configurator.contentTextColors?.let { setContentTextColors(it) }
setContentBackgroundColor(configurator.contentBackgroundColor) setContentBackgroundColor(getContentBackgroundColor())
setTouchable(configurator.isTouchable) setTouchable(isTouchable())
mLockWindowCreated.wait(mDefaultSafeDelay) mLockWindowCreated.wait(mDefaultSafeDelay)
} }
} }
@@ -603,7 +603,7 @@ open class ConsoleImpl(val uiHandler: UiHandler) : AbstractConsole() {
@ScriptInterface @ScriptInterface
fun setTitleBackgroundColor(@ColorInt color: Int) = runWithWindow({ configurator.setTitleBackgroundColor(color) }) { fun setTitleBackgroundColor(@ColorInt color: Int) = runWithWindow({ configurator.setTitleBackgroundColor(color) }) {
mConsoleFloaty.setTitleBackgroundColor(color) mConsoleFloaty.setTitleBackgroundColor(getTitleBackgroundColor())
} }
@ScriptInterface @ScriptInterface
@@ -647,7 +647,7 @@ open class ConsoleImpl(val uiHandler: UiHandler) : AbstractConsole() {
@ScriptInterface @ScriptInterface
fun setContentBackgroundColor(@ColorInt color: Int) = runWithWindow({ configurator.setContentBackgroundColor(color) }) { fun setContentBackgroundColor(@ColorInt color: Int) = runWithWindow({ configurator.setContentBackgroundColor(color) }) {
setContentViewBackgroundColor(getFloatingConsoleView(), color) setContentViewBackgroundColor(getFloatingConsoleView(), getContentBackgroundColor())
} }
@ScriptInterface @ScriptInterface
@@ -655,18 +655,12 @@ open class ConsoleImpl(val uiHandler: UiHandler) : AbstractConsole() {
@ScriptInterface @ScriptInterface
fun setContentBackgroundTint(@ColorInt tint: Int) = runWithWindow({ configurator.setContentBackgroundTint(tint) }) { fun setContentBackgroundTint(@ColorInt tint: Int) = runWithWindow({ configurator.setContentBackgroundTint(tint) }) {
val alpha = configurator.contentBackgroundColor.alpha setContentViewBackgroundColor(getFloatingConsoleView(), getContentBackgroundColor())
val niceAlpha = parseAlpha(alpha, R.color.floating_console_content_bg)
val color = Color.argb(niceAlpha, tint.red, tint.green, tint.blue)
setContentViewBackgroundColor(getFloatingConsoleView(), color)
} }
@ScriptInterface @ScriptInterface
fun setContentBackgroundAlpha(alpha: Int) = runWithWindow({ configurator.setContentBackgroundAlpha(alpha) }) { fun setContentBackgroundAlpha(alpha: Int) = runWithWindow({ configurator.setContentBackgroundAlpha(alpha) }) {
val bg = configurator.contentBackgroundColor setContentViewBackgroundColor(getFloatingConsoleView(), getContentBackgroundColor())
val niceAlpha = parseAlpha(alpha, R.color.floating_console_content_bg)
val color = Color.argb(niceAlpha, bg.red, bg.green, bg.blue)
setContentViewBackgroundColor(getFloatingConsoleView(), color)
} }
@ScriptInterface @ScriptInterface
@@ -851,8 +845,17 @@ open class ConsoleImpl(val uiHandler: UiHandler) : AbstractConsole() {
private set private set
@Volatile @Volatile
var titleBackgroundColor: Int = context.getColor(R.color.floating_console_title_bar_bg) private var internalTitleBackgroundColor: Int? = null
internal set
@Volatile
private var internalTitleBackgroundAlpha: Int? = null
@Volatile
private var internalTitleBackgroundTint: Int? = null
val titleBackgroundColor: Int
get() = (internalTitleBackgroundColor ?: context.getColor(R.color.floating_console_title_bar_bg))
.calibrateWith(internalTitleBackgroundAlpha, internalTitleBackgroundTint)
@Volatile @Volatile
var titleIconsTint: Int? = null var titleIconsTint: Int? = null
@@ -867,8 +870,17 @@ open class ConsoleImpl(val uiHandler: UiHandler) : AbstractConsole() {
private set private set
@Volatile @Volatile
var contentBackgroundColor: Int = context.getColor(R.color.floating_console_content_bg) private var internalContentBackgroundColor: Int? = null
private set
@Volatile
private var internalContentBackgroundAlpha: Int? = null
@Volatile
private var internalContentBackgroundTint: Int? = null
val contentBackgroundColor: Int
get() = (internalContentBackgroundColor ?: context.getColor(R.color.floating_console_content_bg))
.calibrateWith(internalContentBackgroundAlpha, internalContentBackgroundTint)
@Volatile @Volatile
var isTouchable: Boolean = true var isTouchable: Boolean = true
@@ -907,16 +919,15 @@ open class ConsoleImpl(val uiHandler: UiHandler) : AbstractConsole() {
} }
fun setTitleBackgroundColor(color: Int) = also { fun setTitleBackgroundColor(color: Int) = also {
titleBackgroundColor = color internalTitleBackgroundColor = color
} }
fun setTitleBackgroundTint(tint: Int) = also { fun setTitleBackgroundTint(tint: Int) = also {
titleBackgroundColor = titleBackgroundColor.run { Color.argb(alpha, tint.red, tint.green, tint.blue) } internalTitleBackgroundTint = tint
} }
fun setTitleBackgroundAlpha(alpha: Int) = also { fun setTitleBackgroundAlpha(alpha: Int) = also {
val niceAlpha = parseAlpha(alpha, R.color.floating_console_title_bar_bg) internalTitleBackgroundAlpha = parseAlpha(alpha, R.color.floating_console_title_bar_bg)
titleBackgroundColor = titleBackgroundColor.run { Color.argb(niceAlpha, red, green, blue) }
} }
fun setTitleIconsTint(color: Int) = also { fun setTitleIconsTint(color: Int) = also {
@@ -932,16 +943,15 @@ open class ConsoleImpl(val uiHandler: UiHandler) : AbstractConsole() {
} }
fun setContentBackgroundColor(color: Int) = also { fun setContentBackgroundColor(color: Int) = also {
contentBackgroundColor = color internalContentBackgroundColor = color
} }
fun setContentBackgroundTint(tint: Int) { fun setContentBackgroundTint(tint: Int) {
contentBackgroundColor = contentBackgroundColor.run { Color.argb(alpha, tint.red, tint.green, tint.blue) } internalContentBackgroundTint = tint
} }
fun setContentBackgroundAlpha(alpha: Int) = also { fun setContentBackgroundAlpha(alpha: Int) = also {
val niceAlpha = parseAlpha(alpha, R.color.floating_console_content_bg) internalContentBackgroundAlpha = parseAlpha(alpha, R.color.floating_console_content_bg)
contentBackgroundColor = contentBackgroundColor.run { Color.argb(niceAlpha, red, green, blue) }
} }
fun setTextSize(size: Float) = also { fun setTextSize(size: Float) = also {
@@ -987,6 +997,27 @@ open class ConsoleImpl(val uiHandler: UiHandler) : AbstractConsole() {
isTouchable = !touchThrough isTouchable = !touchThrough
} }
fun clearStates() {
size = null
position = null
gravity = DEFAULT_GRAVITY
title = null
titleTextSize = null
titleTextColor = null
internalTitleBackgroundColor = null
internalTitleBackgroundAlpha = null
internalTitleBackgroundTint = null
internalContentBackgroundColor = null
internalContentBackgroundAlpha = null
internalContentBackgroundTint = null
titleIconsTint = null
contentTextSize = null
contentTextColors = null
isTouchable = true
isExitOnClose = false
exitOnCloseTimeout = DEFAULT_EXIT_ON_CLOSE_TIMEOUT
}
internal fun initExitOnClose() { internal fun initExitOnClose() {
setExitOnClose(false) setExitOnClose(false)
exitOnCloseTimeout = DEFAULT_EXIT_ON_CLOSE_TIMEOUT exitOnCloseTimeout = DEFAULT_EXIT_ON_CLOSE_TIMEOUT
@@ -995,6 +1026,13 @@ open class ConsoleImpl(val uiHandler: UiHandler) : AbstractConsole() {
@JvmOverloads @JvmOverloads
fun show(isReset: Boolean = false) = this@ConsoleImpl.show(isReset) fun show(isReset: Boolean = false) = this@ConsoleImpl.show(isReset)
private fun Int.calibrateWith(alpha: Int?, tint: Int?): Int {
var result = this
alpha?.let { desired -> result = Color.argb(desired, result.red, result.green, result.blue) }
tint?.let { desired -> result = Color.argb(result.alpha, desired.red, desired.green, desired.blue) }
return result
}
} }
companion object { companion object {

View File

@@ -10,6 +10,8 @@ import org.autojs.autojs.core.console.ConsoleImpl.Companion.DEFAULT_EXIT_ON_CLOS
import org.autojs.autojs.extension.AnyExtensions.isJsNullish import org.autojs.autojs.extension.AnyExtensions.isJsNullish
import org.autojs.autojs.extension.AnyExtensions.jsBrief import org.autojs.autojs.extension.AnyExtensions.jsBrief
import org.autojs.autojs.extension.FlexibleArray import org.autojs.autojs.extension.FlexibleArray
import org.autojs.autojs.extension.FlexibleArray.Companion.component1
import org.autojs.autojs.extension.FlexibleArray.Companion.component2
import org.autojs.autojs.extension.ScriptableExtensions.hasProp import org.autojs.autojs.extension.ScriptableExtensions.hasProp
import org.autojs.autojs.extension.ScriptableExtensions.prop import org.autojs.autojs.extension.ScriptableExtensions.prop
import org.autojs.autojs.extension.ScriptableObjectExtensions.inquire import org.autojs.autojs.extension.ScriptableObjectExtensions.inquire
@@ -300,7 +302,9 @@ class Console(scriptRuntime: ScriptRuntime) : AugmentableProxy(scriptRuntime) {
@RhinoRuntimeFunctionInterface @RhinoRuntimeFunctionInterface
fun build(scriptRuntime: ScriptRuntime, args: Array<out Any?>): ConsoleImpl.Configurator = ensureArgumentsAtMost(args, 1) { fun build(scriptRuntime: ScriptRuntime, args: Array<out Any?>): ConsoleImpl.Configurator = ensureArgumentsAtMost(args, 1) {
val (options) = it val (options) = it
val configurator = scriptRuntime.console.configurator val configurator = scriptRuntime.console.configurator.apply {
clearStates()
}
val opt = coerceObject(options, newNativeObject()) val opt = coerceObject(options, newNativeObject())
opt.entries.forEach { entry -> opt.entries.forEach { entry ->

View File

@@ -1,4 +1,5 @@
#Wed Oct 01 21:14:23 GMT+8 2025 #Thu Oct 30 10:26:35 GMT+8 2025
9.2.0=2.2.20
9.0.0=2.2.0 9.0.0=2.2.0
8.12=2.0.21 8.12=2.0.21
8.11=2.0.20 8.11=2.0.20

View File

@@ -1,5 +1,5 @@
#Wed Oct 29 20:13:49 CST 2025 #Fri Oct 31 09:54:36 CST 2025
BUILD_TIME=1761740029614 BUILD_TIME=1761875676837
COMPILE_SDK_VERSION=36 COMPILE_SDK_VERSION=36
IMAGE_QUANT_CMAKE_VERSION=3.22.1 IMAGE_QUANT_CMAKE_VERSION=3.22.1
IMAGE_QUANT_NDK_VERSION=26.1.10909125 IMAGE_QUANT_NDK_VERSION=26.1.10909125
@@ -27,6 +27,6 @@ RAPID_OCR_OPENCV_MOBILE_LABEL_VERSION=13
RAPID_OCR_OPENCV_MOBILE_VERSION=4.5.3 RAPID_OCR_OPENCV_MOBILE_VERSION=4.5.3
TARGET_SDK_VERSION=36 TARGET_SDK_VERSION=36
TARGET_SDK_VERSION_INRT=29 TARGET_SDK_VERSION_INRT=29
VERSION_BUILD=3452 VERSION_BUILD=3455
VERSION_NAME=6.7.0 Alpha10 VERSION_NAME=6.7.0 Alpha10
VSCODE_EXT_REQUIRED_VERSION=1.0.8 VSCODE_EXT_REQUIRED_VERSION=1.0.8