From b8ecf3cc11b276cc9523d9c46eb7eb39b2b6b174 Mon Sep 17 00:00:00 2001 From: SuperMonster003 Date: Fri, 31 Oct 2025 09:58:59 +0800 Subject: [PATCH] =?UTF-8?q?6.7.0=20-=20Alpha10=20-=20=E4=BF=AE=E5=A4=8D=20?= =?UTF-8?q?console.build=20=E5=A4=9A=E6=AC=A1=E8=B0=83=E7=94=A8=E9=87=8D?= =?UTF-8?q?=E7=BD=AE=E9=97=AE=E9=A2=98=E5=8F=8A=20(title/content)Backgroun?= =?UTF-8?q?dColor=20=E5=AF=BC=E8=87=B4=E9=80=8F=E6=98=8E=E5=BA=A6=E6=88=96?= =?UTF-8?q?=E7=9D=80=E8=89=B2=E9=80=89=E9=A1=B9=E8=A2=AB=E8=A6=86=E7=9B=96?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(issue=20#458)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changelog/lang_zh-Hans.json | 2 + .../autojs/core/console/ConsoleFloaty.kt | 23 ++--- .../autojs/autojs/core/console/ConsoleImpl.kt | 92 +++++++++++++------ .../runtime/api/augment/console/Console.kt | 6 +- gradle/data/gradle-kotlin-compat.properties | 3 +- version.properties | 6 +- 6 files changed, 85 insertions(+), 47 deletions(-) diff --git a/.changelog/lang_zh-Hans.json b/.changelog/lang_zh-Hans.json index 842513d2..c68368c6 100644 --- a/.changelog/lang_zh-Hans.json +++ b/.changelog/lang_zh-Hans.json @@ -30,6 +30,8 @@ "floaty.window/rawWindow 方法无法接受字符串参数的问题", "util.class[Name]/getClass[Name] 可能返回错误结果的问题", "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 等方法显示 BigInt 数据类型的问题", "部分全局对象可能丢失 JavaScript 原型属性及方法的问题", diff --git a/app/src/main/java/org/autojs/autojs/core/console/ConsoleFloaty.kt b/app/src/main/java/org/autojs/autojs/core/console/ConsoleFloaty.kt index 3178af28..a2ba681a 100644 --- a/app/src/main/java/org/autojs/autojs/core/console/ConsoleFloaty.kt +++ b/app/src/main/java/org/autojs/autojs/core/console/ConsoleFloaty.kt @@ -12,10 +12,6 @@ import android.widget.LinearLayout import android.widget.TextView import androidx.annotation.ColorInt 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.ui.enhancedfloaty.FloatyService 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.FloatingWindowCollapseBinding import kotlin.math.roundToInt +import androidx.core.view.isVisible /** * Created by Stardust on Apr 20, 2017. @@ -124,7 +121,7 @@ class ConsoleFloaty(private val console: ConsoleImpl) : AbstractResizableExpanda expandedBinding.moveOrResize.let { it.setOnClickListener { mMoveCursor?.run { - if (visibility == View.VISIBLE) { + if (isVisible) { visibility = View.GONE mResizer?.visibility = View.GONE } else { @@ -167,17 +164,18 @@ class ConsoleFloaty(private val console: ConsoleImpl) : AbstractResizableExpanda fun getTitle(): String = mTitleText?.toString() ?: "" fun setTitleBackgroundColor(@ColorInt color: Int) { - console.configurator.titleBackgroundColor = color - titleBarView?.apply { post { setTitleViewBackgroundColor(this, color) } } + console.configurator.setTitleBackgroundColor(color) + titleBarView?.apply { post { setTitleViewBackgroundColor(this, console.configurator.titleBackgroundColor) } } } 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) { - val bg = console.configurator.titleBackgroundColor - setTitleBackgroundColor(Color.argb(parseAlpha(alpha), bg.red, bg.green, bg.blue)) + console.configurator.setTitleBackgroundAlpha(alpha) + titleBarView?.apply { post { setTitleViewBackgroundColor(this, console.configurator.titleBackgroundColor) } } } fun setTitleIconsTint(color: Int) { @@ -205,11 +203,6 @@ class ConsoleFloaty(private val console: ConsoleImpl) : AbstractResizableExpanda 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) { mCloseButton?.apply { post { setImageDrawable(ResourcesCompat.getDrawable(console.uiHandler.applicationContext.resources, resId, null)) } diff --git a/app/src/main/java/org/autojs/autojs/core/console/ConsoleImpl.kt b/app/src/main/java/org/autojs/autojs/core/console/ConsoleImpl.kt index 5f176de2..a4438e0e 100644 --- a/app/src/main/java/org/autojs/autojs/core/console/ConsoleImpl.kt +++ b/app/src/main/java/org/autojs/autojs/core/console/ConsoleImpl.kt @@ -388,15 +388,15 @@ open class ConsoleImpl(val uiHandler: UiHandler) : AbstractConsole() { isShowing = true configurator.title?.let { setTitle(it) } configurator.position?.run { setPosition(x, y, true) } - setGravity(configurator.gravity) + setGravity(getGravity()) configurator.titleTextSize?.let { setTitleTextSize(it) } configurator.titleTextColor?.let { setTitleTextColor(it) } - setTitleBackgroundColor(configurator.titleBackgroundColor) + setTitleBackgroundColor(getTitleBackgroundColor()) configurator.titleIconsTint?.let { setTitleIconsTint(it) } configurator.contentTextSize?.let { setContentTextSize(it) } configurator.contentTextColors?.let { setContentTextColors(it) } - setContentBackgroundColor(configurator.contentBackgroundColor) - setTouchable(configurator.isTouchable) + setContentBackgroundColor(getContentBackgroundColor()) + setTouchable(isTouchable()) mLockWindowCreated.wait(mDefaultSafeDelay) } } @@ -603,7 +603,7 @@ open class ConsoleImpl(val uiHandler: UiHandler) : AbstractConsole() { @ScriptInterface fun setTitleBackgroundColor(@ColorInt color: Int) = runWithWindow({ configurator.setTitleBackgroundColor(color) }) { - mConsoleFloaty.setTitleBackgroundColor(color) + mConsoleFloaty.setTitleBackgroundColor(getTitleBackgroundColor()) } @ScriptInterface @@ -647,7 +647,7 @@ open class ConsoleImpl(val uiHandler: UiHandler) : AbstractConsole() { @ScriptInterface fun setContentBackgroundColor(@ColorInt color: Int) = runWithWindow({ configurator.setContentBackgroundColor(color) }) { - setContentViewBackgroundColor(getFloatingConsoleView(), color) + setContentViewBackgroundColor(getFloatingConsoleView(), getContentBackgroundColor()) } @ScriptInterface @@ -655,18 +655,12 @@ open class ConsoleImpl(val uiHandler: UiHandler) : AbstractConsole() { @ScriptInterface fun setContentBackgroundTint(@ColorInt tint: Int) = runWithWindow({ configurator.setContentBackgroundTint(tint) }) { - val alpha = configurator.contentBackgroundColor.alpha - val niceAlpha = parseAlpha(alpha, R.color.floating_console_content_bg) - val color = Color.argb(niceAlpha, tint.red, tint.green, tint.blue) - setContentViewBackgroundColor(getFloatingConsoleView(), color) + setContentViewBackgroundColor(getFloatingConsoleView(), getContentBackgroundColor()) } @ScriptInterface fun setContentBackgroundAlpha(alpha: Int) = runWithWindow({ configurator.setContentBackgroundAlpha(alpha) }) { - val bg = configurator.contentBackgroundColor - val niceAlpha = parseAlpha(alpha, R.color.floating_console_content_bg) - val color = Color.argb(niceAlpha, bg.red, bg.green, bg.blue) - setContentViewBackgroundColor(getFloatingConsoleView(), color) + setContentViewBackgroundColor(getFloatingConsoleView(), getContentBackgroundColor()) } @ScriptInterface @@ -851,8 +845,17 @@ open class ConsoleImpl(val uiHandler: UiHandler) : AbstractConsole() { private set @Volatile - var titleBackgroundColor: Int = context.getColor(R.color.floating_console_title_bar_bg) - internal set + private var internalTitleBackgroundColor: Int? = null + + @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 var titleIconsTint: Int? = null @@ -867,8 +870,17 @@ open class ConsoleImpl(val uiHandler: UiHandler) : AbstractConsole() { private set @Volatile - var contentBackgroundColor: Int = context.getColor(R.color.floating_console_content_bg) - private set + private var internalContentBackgroundColor: Int? = null + + @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 var isTouchable: Boolean = true @@ -907,16 +919,15 @@ open class ConsoleImpl(val uiHandler: UiHandler) : AbstractConsole() { } fun setTitleBackgroundColor(color: Int) = also { - titleBackgroundColor = color + internalTitleBackgroundColor = color } fun setTitleBackgroundTint(tint: Int) = also { - titleBackgroundColor = titleBackgroundColor.run { Color.argb(alpha, tint.red, tint.green, tint.blue) } + internalTitleBackgroundTint = tint } fun setTitleBackgroundAlpha(alpha: Int) = also { - val niceAlpha = parseAlpha(alpha, R.color.floating_console_title_bar_bg) - titleBackgroundColor = titleBackgroundColor.run { Color.argb(niceAlpha, red, green, blue) } + internalTitleBackgroundAlpha = parseAlpha(alpha, R.color.floating_console_title_bar_bg) } fun setTitleIconsTint(color: Int) = also { @@ -932,16 +943,15 @@ open class ConsoleImpl(val uiHandler: UiHandler) : AbstractConsole() { } fun setContentBackgroundColor(color: Int) = also { - contentBackgroundColor = color + internalContentBackgroundColor = color } fun setContentBackgroundTint(tint: Int) { - contentBackgroundColor = contentBackgroundColor.run { Color.argb(alpha, tint.red, tint.green, tint.blue) } + internalContentBackgroundTint = tint } fun setContentBackgroundAlpha(alpha: Int) = also { - val niceAlpha = parseAlpha(alpha, R.color.floating_console_content_bg) - contentBackgroundColor = contentBackgroundColor.run { Color.argb(niceAlpha, red, green, blue) } + internalContentBackgroundAlpha = parseAlpha(alpha, R.color.floating_console_content_bg) } fun setTextSize(size: Float) = also { @@ -987,6 +997,27 @@ open class ConsoleImpl(val uiHandler: UiHandler) : AbstractConsole() { 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() { setExitOnClose(false) exitOnCloseTimeout = DEFAULT_EXIT_ON_CLOSE_TIMEOUT @@ -995,6 +1026,13 @@ open class ConsoleImpl(val uiHandler: UiHandler) : AbstractConsole() { @JvmOverloads 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 { @@ -1010,4 +1048,4 @@ open class ConsoleImpl(val uiHandler: UiHandler) : AbstractConsole() { } -} \ No newline at end of file +} diff --git a/app/src/main/java/org/autojs/autojs/runtime/api/augment/console/Console.kt b/app/src/main/java/org/autojs/autojs/runtime/api/augment/console/Console.kt index 30a415f3..c443ed46 100644 --- a/app/src/main/java/org/autojs/autojs/runtime/api/augment/console/Console.kt +++ b/app/src/main/java/org/autojs/autojs/runtime/api/augment/console/Console.kt @@ -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.jsBrief 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.prop import org.autojs.autojs.extension.ScriptableObjectExtensions.inquire @@ -300,7 +302,9 @@ class Console(scriptRuntime: ScriptRuntime) : AugmentableProxy(scriptRuntime) { @RhinoRuntimeFunctionInterface fun build(scriptRuntime: ScriptRuntime, args: Array): ConsoleImpl.Configurator = ensureArgumentsAtMost(args, 1) { val (options) = it - val configurator = scriptRuntime.console.configurator + val configurator = scriptRuntime.console.configurator.apply { + clearStates() + } val opt = coerceObject(options, newNativeObject()) opt.entries.forEach { entry -> diff --git a/gradle/data/gradle-kotlin-compat.properties b/gradle/data/gradle-kotlin-compat.properties index 9ba006ec..27851cb7 100644 --- a/gradle/data/gradle-kotlin-compat.properties +++ b/gradle/data/gradle-kotlin-compat.properties @@ -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 8.12=2.0.21 8.11=2.0.20 diff --git a/version.properties b/version.properties index d0127c42..0b883885 100644 --- a/version.properties +++ b/version.properties @@ -1,5 +1,5 @@ -#Wed Oct 29 20:13:49 CST 2025 -BUILD_TIME=1761740029614 +#Fri Oct 31 09:54:36 CST 2025 +BUILD_TIME=1761875676837 COMPILE_SDK_VERSION=36 IMAGE_QUANT_CMAKE_VERSION=3.22.1 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 TARGET_SDK_VERSION=36 TARGET_SDK_VERSION_INRT=29 -VERSION_BUILD=3452 +VERSION_BUILD=3455 VERSION_NAME=6.7.0 Alpha10 VSCODE_EXT_REQUIRED_VERSION=1.0.8