6.6.2 - Alpha4 - 修复代码编辑器页面菜单项图标及文字的着色异常

This commit is contained in:
SuperMonster003
2025-03-11 20:49:07 +08:00
parent d355964591
commit 0487cf2a60
13 changed files with 72 additions and 36 deletions

View File

@@ -146,10 +146,16 @@ public class TinySign {
// ! Rhino 1.8.1-SNAPSHOT requires dynamically loading services during initialization (e.g., org.mozilla.javascript.RegExpLoader).
// ! When loading these services, it needs to read the service provider configuration files located in the META-INF/services/ directory.
// ! During signing, these configuration files need to be written into the ZipOutputStream.
// !
// ! Refer to: https://stackoverflow.com/questions/4544899/java-meta-inf-services
// !
// ! zh-CN:
// !
// ! Rhino 1.8.1-SNAPSHOT 在初始化时需要动态加载服务 (如 org.mozilla.javascript.RegExpLoader),
// ! 这些服务加载时, 需要读取位于 META-INF/services/ 目录下的服务提供者配置文件 (Service Provider Configuration Files).
// ! 签名时, 需要将这些配置文件写入 ZipOutputStream 中.
// !
// ! 参阅: https://stackoverflow.com/questions/4544899/java-meta-inf-services
private static void writeServices(File dir, ZipOutputStream zos) throws IOException {
File servicesDir = new File(dir, "META-INF/services");
if (!servicesDir.isDirectory()) {

View File

@@ -274,8 +274,12 @@ public class DebugToolbarFragment extends ToolbarFragment implements DebugCallba
}
String variable = findVariableOnCursor(line, ch);
Log.d(LOG_TAG, "onCursorChange: variable = " + variable + ", ch = " + ch + ", line = " + line);
String value = eval(variable);
mEditorView.debugBar.updateCurrentVariable(variable, value);
try {
String value = eval(variable);
mEditorView.debugBar.updateCurrentVariable(variable, value);
} catch (Exception e) {
e.printStackTrace();
}
}
private String findVariableOnCursor(String line, int ch) {

View File

@@ -3,6 +3,7 @@ package org.autojs.autojs.ui.main.scripts
import android.annotation.SuppressLint
import android.content.ClipData
import android.content.ClipboardManager
import android.content.res.ColorStateList
import android.os.Bundle
import android.text.SpannableStringBuilder
import android.util.TypedValue
@@ -10,16 +11,20 @@ import android.view.KeyEvent
import android.view.ScaleGestureDetector
import android.view.View
import android.widget.TextView
import com.google.android.material.floatingactionbutton.FloatingActionButton
import io.noties.markwon.syntax.Prism4jThemeBase
import io.noties.markwon.syntax.Prism4jThemeDarkula
import io.noties.markwon.syntax.Prism4jThemeDefault
import io.noties.prism4j.GrammarLocator
import io.noties.prism4j.Prism4j
import kotlinx.coroutines.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import org.autojs.autojs.theme.widget.ThemeColorFloatingActionButton
import org.autojs.autojs.ui.BaseActivity
import org.autojs.autojs.util.ColorUtils
import org.autojs.autojs.util.DisplayUtils
import org.autojs.autojs.util.ViewUtils
import org.autojs.autojs6.R
@@ -28,14 +33,18 @@ import kotlin.math.floor
abstract class BaseDisplayContentActivity : BaseActivity() {
override val handleStatusBarThemeColorAutomatically = false
abstract var internalMenuResource: Int
abstract var highlightGrammarLocator: GrammarLocator
abstract var highlightGrammarName: String
abstract var highlightThemeLanguage: String
open var themeColorDayNight = R.color.md_blue_grey_50 to R.color.md_blue_grey_900
private lateinit var internalTextView: TextView
private lateinit var internalFabView: ThemeColorFloatingActionButton
private lateinit var internalFabView: FloatingActionButton
protected val popMenuActionMap = mutableMapOf<Int, () -> Unit>()
@@ -126,6 +135,27 @@ abstract class BaseDisplayContentActivity : BaseActivity() {
}
}
override fun onStart() {
super.onStart()
val (themeColorDayRes, themeColorNightRes) = themeColorDayNight
val themeColorDay = getColor(themeColorDayRes)
val themeColorNight = getColor(themeColorNightRes)
if (ViewUtils.isNightModeYes(this)) {
internalFabView.backgroundTintList = ColorStateList.valueOf(themeColorNight)
internalFabView.imageTintList = ColorStateList.valueOf(if (ColorUtils.isLuminanceDark(themeColorNight)) getColor(R.color.night) else getColor(R.color.day))
ViewUtils.setStatusBarBackgroundColor(this, themeColorNight)
ViewUtils.setStatusBarIconLight(this, ColorUtils.isLuminanceDark(themeColorNight))
} else {
internalFabView.backgroundTintList = ColorStateList.valueOf(themeColorDay)
internalFabView.imageTintList = ColorStateList.valueOf(if (ColorUtils.isLuminanceDark(themeColorDay)) getColor(R.color.night) else getColor(R.color.day))
ViewUtils.setStatusBarBackgroundColor(this, themeColorDay)
ViewUtils.setStatusBarIconLight(this, ColorUtils.isLuminanceDark(themeColorDay))
}
}
protected abstract suspend fun loadAndDisplayContent()
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {

View File

@@ -1,13 +1,14 @@
package org.autojs.autojs.ui.widget
import android.content.Context
import android.graphics.Color
import android.content.res.ColorStateList
import android.graphics.drawable.Drawable
import android.util.AttributeSet
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.core.content.ContextCompat
import org.autojs.autojs.theme.ThemeColorManager
import org.autojs.autojs.util.DrawableUtils
import org.autojs.autojs6.R
@@ -16,8 +17,17 @@ import org.autojs.autojs6.R
*/
class ToolbarMenuItem : LinearLayout {
private val mColorDisabled: Int = ContextCompat.getColor(context, R.color.toolbar_disabled)
private val mColorEnabled: Int = ContextCompat.getColor(context, R.color.toolbar_text)
private val mColorDisabled: Int
get() = when (ThemeColorManager.isThemeColorLuminanceLight()) {
true -> ContextCompat.getColor(context, R.color.toolbar_menu_item_disabled_dark)
else -> ContextCompat.getColor(context, R.color.toolbar_menu_item_disabled_light)
}
private val mColorEnabled: Int
get() = when (ThemeColorManager.isThemeColorLuminanceLight()) {
true -> ContextCompat.getColor(context, R.color.toolbar_menu_item_enabled_dark)
else -> ContextCompat.getColor(context, R.color.toolbar_menu_item_enabled_light)
}
private var mImageView: ImageView
private var mTextView: TextView
private var mEnabledDrawable: Drawable? = null
@@ -30,15 +40,12 @@ class ToolbarMenuItem : LinearLayout {
val iconText = a.getString(R.styleable.ToolbarMenuItem_text)
val iconResId = a.getResourceId(R.styleable.ToolbarMenuItem_icon, 0)
val iconColor = a.getColor(R.styleable.ToolbarMenuItem_icon_color, Color.TRANSPARENT)
a.recycle()
mImageView = findViewById<ImageView?>(R.id.icon).apply {
setImageResource(iconResId)
if (iconColor != Color.TRANSPARENT) {
setImageDrawable(DrawableUtils.setDrawableColorFilterSrcIn(drawable, iconColor))
}
imageTintList = ColorStateList.valueOf(mColorEnabled)
}
mTextView = findViewById<TextView?>(R.id.text).apply {
@@ -57,6 +64,7 @@ class ToolbarMenuItem : LinearLayout {
ensureEnabledDrawable()
ensureDisabledDrawable()
mImageView.setImageDrawable(if (enabled) mEnabledDrawable else mDisabledDrawable)
mImageView.imageTintList = ColorStateList.valueOf(if (enabled) mColorEnabled else mColorDisabled)
mTextView.setTextColor(if (enabled) mColorEnabled else mColorDisabled)
}
}