6.6.2 - Alpha5 - 主题色设置页面新布局支持搜索功能
@@ -1,4 +1,3 @@
|
||||
package org.autojs.autojs.annotation;
|
||||
package org.autojs.autojs.annotation
|
||||
|
||||
public @interface ReservedForCompatibility {
|
||||
}
|
||||
annotation class ReservedForCompatibility
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.autojs.autojs.extension
|
||||
|
||||
import org.autojs.autojs.extension.AnyExtensions.jsBrief
|
||||
import org.autojs.autojs.util.RhinoUtils.UNDEFINED
|
||||
import org.autojs.autojs.util.RhinoUtils.newNativeObject
|
||||
import org.autojs.autojs.util.RhinoUtils.withRhinoContext
|
||||
@@ -84,4 +85,9 @@ object ArrayExtensions {
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> Array<T>.jsArrayBrief(separator: String = ", ", appendPaddingSpace: Boolean = true) = when (appendPaddingSpace) {
|
||||
true -> "[ ${this.joinToString(separator) { it.jsBrief() }} ]"
|
||||
else -> "[${this.joinToString(separator) { it.jsBrief() }}]"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package org.autojs.autojs.extension
|
||||
|
||||
import java.math.RoundingMode
|
||||
|
||||
object NumberExtensions {
|
||||
|
||||
val Number.string
|
||||
val Number.jsString
|
||||
get() = when (this) {
|
||||
is Double -> when {
|
||||
this % 1.0 == 0.0 -> "%.0f".format(this)
|
||||
@@ -15,4 +17,23 @@ object NumberExtensions {
|
||||
else -> this.toString()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun Double.roundToString(scale: Int, stripTrailingZeros: Boolean = true): String {
|
||||
return toBigDecimal()
|
||||
.setScale(scale, RoundingMode.HALF_UP)
|
||||
.let { if (stripTrailingZeros) it.stripTrailingZeros() else it }
|
||||
.toPlainString()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun Double.roundToAlphaString(scale: Int = 2, keepTrailingZeroForFullAlpha: Boolean = true): String {
|
||||
return toBigDecimal()
|
||||
.setScale(scale, RoundingMode.HALF_UP)
|
||||
.stripTrailingZeros()
|
||||
.toPlainString()
|
||||
.let { if (keepTrailingZeroForFullAlpha && it == "1") "1.0" else it }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,22 @@ import java.text.Normalizer
|
||||
|
||||
object StringExtensions {
|
||||
|
||||
val String.estimateVisualWidth: Int
|
||||
get() {
|
||||
var width = 0
|
||||
var i = 0
|
||||
while (i < length) {
|
||||
// 取 code point (可能是两位 surrogates 拼成一个 code point)
|
||||
val cp = codePointAt(i)
|
||||
// 移动下标, 跳过组合过的 surrogate
|
||||
i += Character.charCount(cp)
|
||||
|
||||
// 简易判断: 东亚全宽/Emoji 等
|
||||
width += if (isLikelyFullwidth(cp)) 2 else 1
|
||||
}
|
||||
return width
|
||||
}
|
||||
|
||||
fun String.toDoubleOrNaN() = this.toDoubleOrNull() ?: Double.NaN
|
||||
|
||||
fun String.padStart(length: Int, padStr: String) = when {
|
||||
@@ -34,4 +50,14 @@ object StringExtensions {
|
||||
.lowercase()
|
||||
}
|
||||
|
||||
private fun isLikelyFullwidth(codePoint: Int) = when (codePoint) {
|
||||
// CJK 中日韩统一表意文字
|
||||
in 0x4E00..0x9FFF -> true
|
||||
// 常见的 Emoji 起始, 又或者判断 Character.getType(cp)
|
||||
in 0x1F300..0x1FAFF -> true
|
||||
// East Asian Fullwidth, Wide 等范围, 可参考 EastAsianWidth.txt
|
||||
else -> false
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.autojs.autojs.runtime
|
||||
|
||||
import android.os.SystemClock
|
||||
import org.autojs.autojs.extension.NumberExtensions.string
|
||||
import org.autojs.autojs.extension.NumberExtensions.jsString
|
||||
import org.autojs.autojs.runtime.api.augment.console.Console
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
@@ -17,7 +17,7 @@ class ConsoleTimeTable(private val scriptRuntime: ScriptRuntime) {
|
||||
@Synchronized
|
||||
fun print(label: String? = null) {
|
||||
val gap = SystemClock.uptimeMillis() - (mData[parseLabel(label)] ?: Double.NaN)
|
||||
Console.log(scriptRuntime, arrayOf("${parseLabel(label)}: ${gap.string}ms"))
|
||||
Console.log(scriptRuntime, arrayOf("${parseLabel(label)}: ${gap.jsString}ms"))
|
||||
mData.remove(parseLabel(label))
|
||||
}
|
||||
|
||||
|
||||
@@ -14,17 +14,23 @@ import org.autojs.autojs.core.image.ColorDetector
|
||||
import org.autojs.autojs.core.image.ColorTable
|
||||
import org.autojs.autojs.extension.AnyExtensions.isJsNullish
|
||||
import org.autojs.autojs.extension.AnyExtensions.jsSpecies
|
||||
import org.autojs.autojs.extension.ArrayExtensions.jsArrayBrief
|
||||
import org.autojs.autojs.extension.ArrayExtensions.toNativeArray
|
||||
import org.autojs.autojs.extension.ArrayExtensions.toNativeObject
|
||||
import org.autojs.autojs.extension.NumberExtensions.string
|
||||
import org.autojs.autojs.extension.FlexibleArray.Companion.component1
|
||||
import org.autojs.autojs.extension.FlexibleArray.Companion.component2
|
||||
import org.autojs.autojs.extension.NumberExtensions.jsString
|
||||
import org.autojs.autojs.extension.NumberExtensions.roundToAlphaString
|
||||
import org.autojs.autojs.extension.ScriptableExtensions.prop
|
||||
import org.autojs.autojs.extension.ScriptableObjectExtensions.inquire
|
||||
import org.autojs.autojs.runtime.api.augment.Augmentable
|
||||
import org.autojs.autojs.runtime.api.augment.SimpleGetterProxy
|
||||
import org.autojs.autojs.runtime.api.augment.jsox.Numberx
|
||||
import org.autojs.autojs.runtime.exception.WrappedIllegalArgumentException
|
||||
import org.autojs.autojs.runtime.exception.ShouldNeverHappenException
|
||||
import org.autojs.autojs.runtime.exception.WrappedIllegalArgumentException
|
||||
import org.autojs.autojs.theme.ThemeColor
|
||||
import org.autojs.autojs.util.ColorUtils
|
||||
import org.autojs.autojs.util.RhinoUtils.coerceBoolean
|
||||
import org.autojs.autojs.util.RhinoUtils.ensureNativeArrayLength
|
||||
import org.autojs.autojs.util.RhinoUtils.newNativeObject
|
||||
import org.mozilla.javascript.Context
|
||||
@@ -32,7 +38,6 @@ import org.mozilla.javascript.NativeArray
|
||||
import org.mozilla.javascript.NativeObject
|
||||
import org.mozilla.javascript.Scriptable
|
||||
import org.mozilla.javascript.Scriptable.NOT_FOUND
|
||||
import java.math.RoundingMode
|
||||
import java.util.function.Supplier
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.roundToInt
|
||||
@@ -122,6 +127,13 @@ object Colors : Augmentable(), SimpleGetterProxy {
|
||||
::toHsva.name,
|
||||
::toHsl.name,
|
||||
::toHsla.name,
|
||||
::toRgbString.name,
|
||||
::toRgbaString.name,
|
||||
// ::toArgbString.name,
|
||||
// ::toHsvString.name,
|
||||
// ::toHsvaString.name,
|
||||
// ::toHslString.name,
|
||||
// ::toHslaString.name,
|
||||
::isSimilar.name,
|
||||
::isEqual.name,
|
||||
::toColorStateList.name,
|
||||
@@ -609,7 +621,7 @@ object Colors : Augmentable(), SimpleGetterProxy {
|
||||
when (it.size) {
|
||||
1 -> rgbRhino(it[0])
|
||||
3 -> rgbRhino(it[0], it[1], it[2])
|
||||
else -> throw WrappedIllegalArgumentException("Invalid arguments \"[$it]\" for colors.rgb")
|
||||
else -> throw WrappedIllegalArgumentException("Invalid arguments ${it.jsArrayBrief()} for colors.rgb")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -647,7 +659,7 @@ object Colors : Augmentable(), SimpleGetterProxy {
|
||||
when (it.size) {
|
||||
1 -> argbRhino(it[0])
|
||||
4 -> argbRhino(it[0], it[1], it[2], it[3])
|
||||
else -> throw WrappedIllegalArgumentException("Invalid arguments \"[$it]\" for colors.argb")
|
||||
else -> throw WrappedIllegalArgumentException("Invalid arguments ${it.jsArrayBrief()} for colors.argb")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -687,7 +699,7 @@ object Colors : Augmentable(), SimpleGetterProxy {
|
||||
1 -> rgbaRhino(it[0])
|
||||
2 -> rgbaRhino(it[0], it[1])
|
||||
4 -> rgbaRhino(it[0], it[1], it[2], it[3])
|
||||
else -> throw WrappedIllegalArgumentException("Invalid arguments \"[$it]\" for colors.rgba")
|
||||
else -> throw WrappedIllegalArgumentException("Invalid arguments ${it.jsArrayBrief()} for colors.rgba")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -744,7 +756,7 @@ object Colors : Augmentable(), SimpleGetterProxy {
|
||||
when (it.size) {
|
||||
1 -> hsvRhino(it[0])
|
||||
3 -> hsvRhino(it[0], it[1], it[2])
|
||||
else -> throw WrappedIllegalArgumentException("Invalid arguments \"[$it]\" for colors.hsv")
|
||||
else -> throw WrappedIllegalArgumentException("Invalid arguments ${it.jsArrayBrief()} for colors.hsv")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -780,7 +792,7 @@ object Colors : Augmentable(), SimpleGetterProxy {
|
||||
1 -> hsvaRhino(it[0])
|
||||
2 -> hsvaRhino(it[0], it[1])
|
||||
4 -> hsvaRhino(it[0], it[1], it[2], it[3])
|
||||
else -> throw WrappedIllegalArgumentException("Invalid arguments \"[$it]\" for colors.hsva")
|
||||
else -> throw WrappedIllegalArgumentException("Invalid arguments ${it.jsArrayBrief()} for colors.hsva")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -829,7 +841,7 @@ object Colors : Augmentable(), SimpleGetterProxy {
|
||||
when (it.size) {
|
||||
1 -> hslRhino(it[0])
|
||||
3 -> hslRhino(it[0], it[1], it[2])
|
||||
else -> throw WrappedIllegalArgumentException("Invalid arguments \"[$it]\" for colors.hsl")
|
||||
else -> throw WrappedIllegalArgumentException("Invalid arguments ${it.jsArrayBrief()} for colors.hsl")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -865,7 +877,7 @@ object Colors : Augmentable(), SimpleGetterProxy {
|
||||
1 -> hslaRhino(it[0])
|
||||
2 -> hslaRhino(it[0], it[1])
|
||||
4 -> hslaRhino(it[0], it[1], it[2], it[3])
|
||||
else -> throw WrappedIllegalArgumentException("Invalid arguments \"[$it]\" for colors.hsla")
|
||||
else -> throw WrappedIllegalArgumentException("Invalid arguments ${it.jsArrayBrief()} for colors.hsla")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -914,7 +926,7 @@ object Colors : Augmentable(), SimpleGetterProxy {
|
||||
when (it.size) {
|
||||
1 -> toRgbRhino(it[0])
|
||||
3 -> toRgbRhino(it[0], it[1], it[2])
|
||||
else -> throw WrappedIllegalArgumentException("Invalid arguments \"[$it]\" for colors.rgb")
|
||||
else -> throw WrappedIllegalArgumentException("Invalid arguments ${it.jsArrayBrief()} for colors.rgb")
|
||||
}.toNativeArray()
|
||||
}
|
||||
|
||||
@@ -949,9 +961,9 @@ object Colors : Augmentable(), SimpleGetterProxy {
|
||||
|
||||
@JvmStatic
|
||||
@RhinoSingletonFunctionInterface
|
||||
fun toArgb(args: Array<out Any?>): List<Double> = ensureArgumentsLengthInRange(args, 1..2) {
|
||||
fun toArgb(args: Array<out Any?>): NativeArray = ensureArgumentsLengthInRange(args, 1..2) {
|
||||
val (colorArg, optionsArg) = it
|
||||
toArgbRhino(colorArg, optionsArg)
|
||||
toArgbRhino(colorArg, optionsArg).toNativeArray()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@@ -964,14 +976,14 @@ object Colors : Augmentable(), SimpleGetterProxy {
|
||||
|
||||
@JvmStatic
|
||||
@RhinoSingletonFunctionInterface
|
||||
fun toHsv(args: Array<out Any?>) = ensureArgumentsLengthInRange(args, 1..4) {
|
||||
fun toHsv(args: Array<out Any?>): NativeArray = ensureArgumentsLengthInRange(args, 1..4) {
|
||||
when (it.size) {
|
||||
1 -> toHsvRhino(it[0])
|
||||
2 -> toHsvRhino(it[0], it[1])
|
||||
3 -> toHsvRhino(it[0], it[1], it[2])
|
||||
4 -> toHsvRhino(it[0], it[1], it[2], it[3])
|
||||
else -> ShouldNeverHappenException()
|
||||
}
|
||||
else -> throw ShouldNeverHappenException()
|
||||
}.toNativeArray()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1030,14 +1042,14 @@ object Colors : Augmentable(), SimpleGetterProxy {
|
||||
|
||||
@JvmStatic
|
||||
@RhinoSingletonFunctionInterface
|
||||
fun toHsva(args: Array<out Any?>) = ensureArgumentsLengthInRange(args, 1..5) {
|
||||
fun toHsva(args: Array<out Any?>): NativeArray = ensureArgumentsLengthInRange(args, 1..5) {
|
||||
when (it.size) {
|
||||
1 -> toHsvaRhino(it[0])
|
||||
2 -> toHsvaRhino(it[0], it[1])
|
||||
4 -> toHsvaRhino(it[0], it[1], it[2], it[3])
|
||||
5 -> toHsvaRhino(it[0], it[1], it[2], it[3], it[4])
|
||||
else -> throw WrappedIllegalArgumentException("Invalid arguments \"[$it]\" for colors.toHsva")
|
||||
}
|
||||
else -> throw WrappedIllegalArgumentException("Invalid arguments ${it.jsArrayBrief()} for colors.toHsva")
|
||||
}.toNativeArray()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1100,14 +1112,14 @@ object Colors : Augmentable(), SimpleGetterProxy {
|
||||
|
||||
@JvmStatic
|
||||
@RhinoSingletonFunctionInterface
|
||||
fun toHsl(args: Array<out Any?>) = ensureArgumentsLengthInRange(args, 1..4) {
|
||||
fun toHsl(args: Array<out Any?>): NativeArray = ensureArgumentsLengthInRange(args, 1..4) {
|
||||
when (it.size) {
|
||||
1 -> toHslRhino(it[0])
|
||||
2 -> toHslRhino(it[0], it[1])
|
||||
3 -> toHslRhino(it[0], it[1], it[2])
|
||||
4 -> toHslRhino(it[0], it[1], it[2], it[3])
|
||||
else -> ShouldNeverHappenException()
|
||||
}
|
||||
else -> throw ShouldNeverHappenException()
|
||||
}.toNativeArray()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1166,12 +1178,12 @@ object Colors : Augmentable(), SimpleGetterProxy {
|
||||
|
||||
@JvmStatic
|
||||
@RhinoSingletonFunctionInterface
|
||||
fun toHsla(args: Array<out Any?>) = ensureArgumentsLengthInRange(args, 1..4) {
|
||||
fun toHsla(args: Array<out Any?>): NativeArray = ensureArgumentsLengthInRange(args, 1..4) {
|
||||
when (it.size) {
|
||||
1 -> toHslaRhino(it[0])
|
||||
4 -> toHslaRhino(it[0], it[1], it[2], it[3])
|
||||
else -> throw WrappedIllegalArgumentException("Invalid arguments \"[$it]\" for colors.toHsla")
|
||||
}
|
||||
else -> throw WrappedIllegalArgumentException("Invalid arguments ${it.jsArrayBrief()} for colors.toHsla")
|
||||
}.toNativeArray()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1205,7 +1217,7 @@ object Colors : Augmentable(), SimpleGetterProxy {
|
||||
2 -> isSimilarRhino(it[0], it[1])
|
||||
3 -> isSimilarRhino(it[0], it[1], it[2])
|
||||
4 -> isSimilarRhino(it[0], it[1], it[2], it[3])
|
||||
else -> throw WrappedIllegalArgumentException("Invalid arguments \"[$it]\" for colors.isSimilar")
|
||||
else -> throw WrappedIllegalArgumentException("Invalid arguments ${it.jsArrayBrief()} for colors.isSimilar")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1268,7 +1280,7 @@ object Colors : Augmentable(), SimpleGetterProxy {
|
||||
when (it.size) {
|
||||
2 -> isSimilarRhino(it[0], it[1])
|
||||
3 -> isSimilarRhino(it[0], it[1], it[2])
|
||||
else -> throw WrappedIllegalArgumentException("Invalid arguments \"[$it]\" for colors.isEqual")
|
||||
else -> throw WrappedIllegalArgumentException("Invalid arguments ${it.jsArrayBrief()} for colors.isEqual")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1342,12 +1354,11 @@ object Colors : Augmentable(), SimpleGetterProxy {
|
||||
@JvmStatic
|
||||
@RhinoFunctionBody
|
||||
fun summaryRhino(color: Any?): String {
|
||||
val (r, g, b, a) = toRgbaRhino(color)
|
||||
val niceA = when (val doubleA = toDoubleComponent(a)) {
|
||||
1.0 -> "1.0"
|
||||
else -> doubleA.toBigDecimal().setScale(2, RoundingMode.HALF_EVEN).stripTrailingZeros().toPlainString()
|
||||
var (r, g, b, a) = toRgbaRhino(color)
|
||||
return when (val doubleA = toDoubleComponent(a)) {
|
||||
1.0 -> "Color { ${toHexRhino(color)} | rgb(${r.jsString}, ${g.jsString}, ${b.jsString}) | int(${toIntRhino(color)}) }"
|
||||
else -> "Color { ${toHexRhino(color)} | rgba(${r.jsString}, ${g.jsString}, ${b.jsString}, ${doubleA.roundToAlphaString()}) | int(${toIntRhino(color)}) }"
|
||||
}
|
||||
return "Color { hex(${toHexRhino(color)}), rgba(${r.string},${g.string},${b.string}/$niceA), int(${toIntRhino(color)}) }"
|
||||
}
|
||||
|
||||
internal fun parseRelativePercentage(percentage: Any?): Double {
|
||||
@@ -1432,4 +1443,106 @@ object Colors : Augmentable(), SimpleGetterProxy {
|
||||
return Numberx.clampToRhino(x, listOf(0, 360), 360).toFloat()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@RhinoSingletonFunctionInterface
|
||||
fun toRgbString(args: Array<out Any?>): String = ensureArgumentsLengthInRange(args, 1..3) {
|
||||
when (it.size) {
|
||||
1 -> toRgbStringRhino(it[0])
|
||||
3 -> toRgbStringRhino(it[0], it[1], it[2])
|
||||
else -> throw WrappedIllegalArgumentException("Invalid arguments ${it.jsArrayBrief()} for colors.toRgbString")
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@RhinoFunctionBody
|
||||
fun toRgbStringRhino(color: Any?): String {
|
||||
return toRgbRhino(color).joinToString(", ", prefix = "rgb(", postfix = ")") {
|
||||
it.roundToInt().coerceIn(0..255).toString()
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@RhinoFunctionBody
|
||||
fun toRgbStringRhino(r: Any?, g: Any?, b: Any?): String {
|
||||
return toRgbRhino(r, g, b).joinToString(", ", prefix = "rgb(", postfix = ")") {
|
||||
it.roundToInt().coerceIn(0..255).toString()
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@RhinoSingletonFunctionInterface
|
||||
fun toRgbaString(args: Array<out Any?>): String = ensureArgumentsAtMost(args, 2) { argList ->
|
||||
val (color, options) = argList
|
||||
|
||||
var keepTrailingZeroForFullAlpha = true
|
||||
|
||||
when (options) {
|
||||
is NativeObject -> {
|
||||
options.inquire<Boolean>("keepTrailingZeroForFullAlpha", ::coerceBoolean)?.let {
|
||||
keepTrailingZeroForFullAlpha = it
|
||||
}
|
||||
}
|
||||
is Boolean -> {
|
||||
keepTrailingZeroForFullAlpha = options
|
||||
}
|
||||
}
|
||||
|
||||
val list = listOf(redRhino(color), greenRhino(color), blueRhino(color)).map {
|
||||
it.roundToInt().coerceIn(0..255).toString()
|
||||
} + alphaDoubleRhino(color).roundToAlphaString(2, keepTrailingZeroForFullAlpha)
|
||||
list.joinToString(", ", prefix = "rgba(", postfix = ")")
|
||||
}
|
||||
|
||||
// // 格式化 argb 格式为 "argb(a, r, g, b)"
|
||||
// fun toArgbString(color: Int): String {
|
||||
// val arr = rawToArgb(color)
|
||||
// return "argb(${arr[0]}, ${arr[1]}, ${arr[2]}, ${arr[3]})"
|
||||
// }
|
||||
//
|
||||
// // 格式化 hsv 格式为 "hsv(h, s%, v%)",其中 h 取整,s 和 v 转换为百分比(整数)
|
||||
// fun toHsvString(color: Int): String {
|
||||
// val arr = rawToHsv(color)
|
||||
// val h = arr[0].roundToInt()
|
||||
// val s = (arr[1] * 100).roundToInt()
|
||||
// val v = (arr[2] * 100).roundToInt()
|
||||
// return "hsv($h, ${s}%, ${v}%)"
|
||||
// }
|
||||
//
|
||||
// // 格式化 hsva 格式为 "hsva(h, s%, v%, a)",其中 a 保留两位小数(或整数)
|
||||
// fun toHsvaString(color: Int): String {
|
||||
// val arr = rawToHsva(color)
|
||||
// val h = arr[0].roundToInt()
|
||||
// val s = (arr[1] * 100).roundToInt()
|
||||
// val v = (arr[2] * 100).roundToInt()
|
||||
// val a = arr[3]
|
||||
// val aStr = if (a % 1.0 == 0.0)
|
||||
// a.roundToInt().toString()
|
||||
// else
|
||||
// String.format("%.2f", a)
|
||||
// return "hsva($h, ${s}%, ${v}%, $aStr)"
|
||||
// }
|
||||
//
|
||||
// // 格式化 hsl 格式为 "hsl(h, s%, l%)"
|
||||
// fun toHslString(color: Int): String {
|
||||
// val arr = rawToHsl(color)
|
||||
// val h = arr[0].roundToInt()
|
||||
// val s = (arr[1] * 100).roundToInt()
|
||||
// val l = (arr[2] * 100).roundToInt()
|
||||
// return "hsl($h, ${s}%, ${l}%)"
|
||||
// }
|
||||
//
|
||||
// // 格式化 hsla 格式为 "hsla(h, s%, l%, a)"
|
||||
// fun toHslaString(color: Int): String {
|
||||
// val arr = rawToHsla(color)
|
||||
// val h = arr[0].roundToInt()
|
||||
// val s = (arr[1] * 100).roundToInt()
|
||||
// val l = (arr[2] * 100).roundToInt()
|
||||
// val a = arr[3]
|
||||
// val aStr = if (a % 1.0 == 0.0)
|
||||
// a.roundToInt().toString()
|
||||
// else
|
||||
// String.format("%.2f", a)
|
||||
// return "hsla($h, ${s}%, ${l}%, $aStr)"
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import org.autojs.autojs.annotation.RhinoRuntimeFunctionInterface
|
||||
import org.autojs.autojs.core.automator.UiObject
|
||||
import org.autojs.autojs.extension.AnyExtensions.isJsNullish
|
||||
import org.autojs.autojs.extension.AnyExtensions.jsBrief
|
||||
import org.autojs.autojs.extension.NumberExtensions.string
|
||||
import org.autojs.autojs.extension.NumberExtensions.jsString
|
||||
import org.autojs.autojs.extension.ScriptableExtensions.defineProp
|
||||
import org.autojs.autojs.extension.ScriptableExtensions.prop
|
||||
import org.autojs.autojs.extension.ScriptableObjectExtensions.inquire
|
||||
@@ -500,7 +500,7 @@ class Global(private val scriptRuntime: ScriptRuntime) : Augmentable(scriptRunti
|
||||
"指定的 AutoJs6 应用版本号需大于 461"
|
||||
}
|
||||
require(BuildConfig.VERSION_CODE >= num.toInt()) {
|
||||
"AutoJs6 应用版本号需不低于 ${num.string}"
|
||||
"AutoJs6 应用版本号需不低于 ${num.jsString}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.autojs.autojs.extension.AnyExtensions.jsBrief
|
||||
import org.autojs.autojs.extension.ArrayExtensions.toNativeArray
|
||||
import org.autojs.autojs.extension.ArrayExtensions.unshiftWith
|
||||
import org.autojs.autojs.extension.FlexibleArray
|
||||
import org.autojs.autojs.extension.NumberExtensions.string
|
||||
import org.autojs.autojs.extension.NumberExtensions.jsString
|
||||
import org.autojs.autojs.extension.StringExtensions.padEnd
|
||||
import org.autojs.autojs.extension.StringExtensions.padStart
|
||||
import org.autojs.autojs.extension.StringExtensions.toDoubleOrNaN
|
||||
@@ -276,10 +276,10 @@ class Numberx(private val scriptRuntime: ScriptRuntime) : Augmentable(scriptRunt
|
||||
require(!niceTargetLength.isNaN() && niceTargetLength.isFinite()) { "Argument \"targetLength\" for Numberx.padStart must be a number" }
|
||||
val nicePad: String = when {
|
||||
pad.isJsNullish() -> DEFAULT_PADDING_STRING
|
||||
pad is Number -> pad.toDouble().string
|
||||
pad is Number -> pad.toDouble().jsString
|
||||
else -> pad.toString()
|
||||
}
|
||||
return parseAnyRhino(num).string.padStart(niceTargetLength.roundToInt(), nicePad)
|
||||
return parseAnyRhino(num).jsString.padStart(niceTargetLength.roundToInt(), nicePad)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@@ -297,10 +297,10 @@ class Numberx(private val scriptRuntime: ScriptRuntime) : Augmentable(scriptRunt
|
||||
require(!niceTargetLength.isNaN() && niceTargetLength.isFinite()) { "Argument \"targetLength\" for Numberx.padEnd must be a number" }
|
||||
val nicePad: String = when {
|
||||
pad.isJsNullish() -> DEFAULT_PADDING_STRING
|
||||
pad is Number -> pad.toDouble().string
|
||||
pad is Number -> pad.toDouble().jsString
|
||||
else -> pad.toString()
|
||||
}
|
||||
return parseAnyRhino(num).string.padEnd(niceTargetLength.roundToInt(), nicePad)
|
||||
return parseAnyRhino(num).jsString.padEnd(niceTargetLength.roundToInt(), nicePad)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.autojs.autojs.extension.AnyExtensions.isJsNullish
|
||||
import org.autojs.autojs.extension.ArrayExtensions.toNativeObject
|
||||
import org.autojs.autojs.extension.FlexibleArray.Companion.component1
|
||||
import org.autojs.autojs.extension.FlexibleArray.Companion.component2
|
||||
import org.autojs.autojs.extension.NumberExtensions.string
|
||||
import org.autojs.autojs.extension.NumberExtensions.jsString
|
||||
import org.autojs.autojs.extension.ScriptableExtensions.prop
|
||||
import org.autojs.autojs.rhino.ProxyObject.Companion.PROXY_GETTER_KEY
|
||||
import org.autojs.autojs.rhino.ProxyObject.Companion.PROXY_SETTER_KEY
|
||||
@@ -542,7 +542,7 @@ object Inspect : Augmentable(), Invokable {
|
||||
ctx.stylize(content, "string")
|
||||
}
|
||||
value is Number -> {
|
||||
ctx.stylize(value.string, "number")
|
||||
ctx.stylize(value.jsString, "number")
|
||||
}
|
||||
value is Boolean -> {
|
||||
ctx.stylize(Context.toString(value), "boolean")
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.autojs.autojs.extension.AnyExtensions.isJsSymbol
|
||||
import org.autojs.autojs.extension.AnyExtensions.isJsUndefined
|
||||
import org.autojs.autojs.extension.AnyExtensions.jsBrief
|
||||
import org.autojs.autojs.extension.FlexibleArray
|
||||
import org.autojs.autojs.extension.NumberExtensions.string
|
||||
import org.autojs.autojs.extension.NumberExtensions.jsString
|
||||
import org.autojs.autojs.extension.ScriptableExtensions.prop
|
||||
import org.autojs.autojs.extension.ScriptableExtensions.defineProp
|
||||
import org.autojs.autojs.runtime.api.augment.Augmentable
|
||||
@@ -352,7 +352,7 @@ object Util : Augmentable() {
|
||||
|
||||
when (matchResult.value) {
|
||||
"%s" -> Context.toString(args[index++])
|
||||
"%d" -> Context.toNumber(args[index++]).string
|
||||
"%d" -> Context.toNumber(args[index++]).jsString
|
||||
"%j" -> try {
|
||||
Context.toString(js_json_stringify(args[index++]))
|
||||
} catch (e: Exception) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.autojs.autojs.annotation.RhinoStandardFunctionInterface
|
||||
import org.autojs.autojs.extension.AnyExtensions.isJsNullish
|
||||
import org.autojs.autojs.extension.ArrayExtensions.toNativeArray
|
||||
import org.autojs.autojs.extension.FlexibleArray
|
||||
import org.autojs.autojs.extension.NumberExtensions.string
|
||||
import org.autojs.autojs.extension.NumberExtensions.jsString
|
||||
import org.autojs.autojs.extension.ScriptableExtensions.prop
|
||||
import org.autojs.autojs.runtime.api.augment.Augmentable
|
||||
import org.autojs.autojs.runtime.exception.WrappedIllegalArgumentException
|
||||
@@ -81,7 +81,7 @@ object VersionCodes : Augmentable() {
|
||||
val releaseDate: String,
|
||||
) {
|
||||
private val releaseTimestampLong = parseTimestamp(releaseDate)
|
||||
val releaseTimestamp = releaseTimestampLong.string
|
||||
val releaseTimestamp = releaseTimestampLong.jsString
|
||||
|
||||
fun toNativeObject() = newNativeObject().also {
|
||||
it.put("versionCode", it, versionCode)
|
||||
@@ -171,7 +171,7 @@ object VersionCodes : Augmentable() {
|
||||
|
||||
private fun normalizeSearcherSource(o: Any) = when (o) {
|
||||
is NativeDate -> wrapNumber(o.date).toString()
|
||||
is Number -> o.string
|
||||
is Number -> o.jsString
|
||||
is String -> o
|
||||
else -> throw WrappedIllegalArgumentException("Invalid argument type: $o for versionCodes.search")
|
||||
}
|
||||
|
||||
@@ -94,6 +94,11 @@ object ThemeColorManager {
|
||||
ViewUtils.setStatusBarBackgroundColor(activity, colorPrimary)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun setStatusBarAppearanceLight(activity: Activity) {
|
||||
ViewUtils.setStatusBarAppearanceLight(activity, isLuminanceDark())
|
||||
}
|
||||
|
||||
private object BackgroundColorManager {
|
||||
|
||||
private val views: MutableList<WeakReference<View>> = LinkedList()
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
package org.autojs.autojs.theme.app
|
||||
|
||||
import android.animation.ValueAnimator
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.autojs.autojs.core.image.ColorItems
|
||||
import org.autojs.autojs.core.pref.Pref
|
||||
import org.autojs.autojs.theme.ThemeChangeNotifier
|
||||
import org.autojs.autojs.theme.ThemeColorManager
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.COLOR_LIBRARY_ID_DEFAULT
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.COLOR_LIBRARY_ID_MATERIAL
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.PresetColorItem
|
||||
import org.autojs.autojs.theme.app.ColorSelectBaseActivity.Companion.KEY_LEGACY_SELECTED_COLOR_INDEX
|
||||
import org.autojs.autojs.theme.app.ColorSelectBaseActivity.Companion.KEY_SELECTED_COLOR_LIBRARY_ID
|
||||
import org.autojs.autojs.theme.app.ColorSelectBaseActivity.Companion.KEY_SELECTED_COLOR_LIBRARY_ITEM_ID
|
||||
import org.autojs.autojs.theme.app.ColorSelectBaseActivity.Companion.SELECT_NONE
|
||||
import org.autojs.autojs.theme.app.ColorSelectBaseActivity.Companion.customColorPosition
|
||||
import org.autojs.autojs.theme.app.ColorSelectBaseActivity.Companion.defaultColorPosition
|
||||
import org.autojs.autojs6.R
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
class ColorItemAdapter(
|
||||
var items: List<PresetColorItem>,
|
||||
var isLibraryIdentifierAppendedToDesc: Boolean = false,
|
||||
private val onItemClick: ((PresetColorItem, View) -> Unit)? = null,
|
||||
) : RecyclerView.Adapter<ColorItemViewHolder>() {
|
||||
|
||||
var selectedItemId = SELECT_NONE
|
||||
var selectedLibraryId = SELECT_NONE
|
||||
|
||||
fun updateData(newItems: List<PresetColorItem>) {
|
||||
items = newItems
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
fun items() = items
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ColorItemViewHolder {
|
||||
val view = LayoutInflater.from(parent.context)
|
||||
.inflate(R.layout.mt_color_library_recycler_view_item, parent, false)
|
||||
return ColorItemViewHolder(view)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ColorItemViewHolder, position: Int) {
|
||||
val itemView = holder.itemView
|
||||
val context = itemView.context
|
||||
val item = items[position]
|
||||
|
||||
when (val tag = itemView.tag) {
|
||||
is ValueAnimator -> {
|
||||
tag.cancel()
|
||||
itemView.tag = null
|
||||
itemView.setBackgroundColor(context.getColor(R.color.window_background))
|
||||
}
|
||||
}
|
||||
|
||||
holder.bind(item, selectedLibraryId, selectedItemId, isLibraryIdentifierAppendedToDesc)
|
||||
|
||||
itemView.setOnClickListener {
|
||||
savePrefsForLibraries(item)
|
||||
savePrefsForLegacy(context, item)
|
||||
|
||||
when (selectedItemId) {
|
||||
SELECT_NONE -> {
|
||||
selectedLibraryId = item.libraryId
|
||||
selectedItemId = item.itemId
|
||||
notifyItemChanged(holder.bindingAdapterPosition)
|
||||
}
|
||||
else -> {
|
||||
val positionBeforeSelection = items().indexOfFirst {
|
||||
it.libraryId == selectedLibraryId && it.itemId == selectedItemId
|
||||
}
|
||||
val positionOfCurrentSelection = holder.bindingAdapterPosition
|
||||
if (positionBeforeSelection != positionOfCurrentSelection && positionBeforeSelection >= 0) {
|
||||
notifyItemChanged(positionBeforeSelection)
|
||||
}
|
||||
selectedLibraryId = item.libraryId
|
||||
selectedItemId = item.itemId
|
||||
notifyItemChanged(positionOfCurrentSelection)
|
||||
}
|
||||
}
|
||||
|
||||
ThemeColorManager.setThemeColor(context.getColor(item.colorRes))
|
||||
ThemeChangeNotifier.notifyThemeChanged()
|
||||
|
||||
onItemClick?.let { it(item, itemView) }
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount() = items.size
|
||||
|
||||
private fun savePrefsForLibraries(colorItem: PresetColorItem) {
|
||||
Pref.putInt(KEY_SELECTED_COLOR_LIBRARY_ID, colorItem.libraryId)
|
||||
Pref.putInt(KEY_SELECTED_COLOR_LIBRARY_ITEM_ID, colorItem.itemId)
|
||||
}
|
||||
|
||||
private fun savePrefsForLegacy(context: Context, colorItem: PresetColorItem) {
|
||||
when (colorItem.libraryId) {
|
||||
COLOR_LIBRARY_ID_DEFAULT -> {
|
||||
if (context.getColor(colorItem.colorRes) == context.getColor(R.color.theme_color_default)) {
|
||||
Pref.putInt(KEY_LEGACY_SELECTED_COLOR_INDEX, defaultColorPosition)
|
||||
} else {
|
||||
Pref.putInt(KEY_LEGACY_SELECTED_COLOR_INDEX, SELECT_NONE)
|
||||
}
|
||||
}
|
||||
COLOR_LIBRARY_ID_MATERIAL -> {
|
||||
val index = colorItem.itemId
|
||||
if (index !in ColorItems.MATERIAL_COLORS.indices) {
|
||||
Pref.putInt(KEY_LEGACY_SELECTED_COLOR_INDEX, SELECT_NONE)
|
||||
} else {
|
||||
val fixedIndex = maxOf(
|
||||
defaultColorPosition,
|
||||
customColorPosition,
|
||||
) + 1 + index
|
||||
Pref.putInt(KEY_LEGACY_SELECTED_COLOR_INDEX, fixedIndex)
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
Pref.putInt(KEY_LEGACY_SELECTED_COLOR_INDEX, SELECT_NONE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package org.autojs.autojs.theme.app
|
||||
|
||||
import android.content.res.ColorStateList
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.autojs.autojs.theme.ThemeColorHelper
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.PresetColorItem
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.presetColorLibraries
|
||||
import org.autojs.autojs.util.ViewUtils
|
||||
import org.autojs.autojs6.R
|
||||
|
||||
class ColorItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
|
||||
private val context = itemView.context
|
||||
|
||||
private val colorView: ImageView = itemView.findViewById(R.id.color)
|
||||
private val nameView: TextView = itemView.findViewById(R.id.name)
|
||||
private val descView: TextView = itemView.findViewById(R.id.description)
|
||||
|
||||
fun bind(item: PresetColorItem, selectedLibraryId: Int, selectedItemId: Int, isLibraryIdentifierAppendedToDesc: Boolean) {
|
||||
val color = context.getColor(item.colorRes)
|
||||
val colorName = context.getString(item.nameRes)
|
||||
val colorDesc = String.format("#%06X", 0xFFFFFF and color)
|
||||
|
||||
ThemeColorHelper.setBackgroundColor(colorView, color)
|
||||
nameView.text = colorName
|
||||
descView.text = when {
|
||||
isLibraryIdentifierAppendedToDesc -> {
|
||||
presetColorLibraries.find { it.id == item.libraryId }?.let {
|
||||
"${context.getString(it.identifierRes)} | $colorDesc"
|
||||
} ?: colorDesc
|
||||
}
|
||||
else -> colorDesc
|
||||
}
|
||||
setChecked(color, selectedLibraryId == item.libraryId && selectedItemId == item.itemId)
|
||||
}
|
||||
|
||||
fun setChecked(@ColorInt color: Int, checked: Boolean) {
|
||||
if (checked) {
|
||||
colorView.setImageResource(R.drawable.mt_ic_check_white_36dp)
|
||||
val tintRes = if (ViewUtils.isLuminanceLight(color)) R.color.day else R.color.night
|
||||
colorView.imageTintList = ColorStateList.valueOf(context.getColor(tintRes))
|
||||
} else {
|
||||
colorView.setImageDrawable(null)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,26 +2,18 @@ package org.autojs.autojs.theme.app
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.content.res.ColorStateList
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.core.view.forEach
|
||||
import androidx.recyclerview.widget.DividerItemDecoration
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.RecyclerView.VERTICAL
|
||||
import com.jaredrummler.android.colorpicker.ColorPickerDialog
|
||||
import androidx.recyclerview.widget.ThemeColorRecyclerView
|
||||
import org.autojs.autojs.core.image.ColorItems
|
||||
import org.autojs.autojs.core.pref.Pref
|
||||
import org.autojs.autojs.theme.ThemeChangeNotifier
|
||||
import org.autojs.autojs.theme.ThemeColorManager
|
||||
import org.autojs.autojs.util.ColorUtils
|
||||
import org.autojs.autojs.util.ViewUtils
|
||||
import org.autojs.autojs.util.ViewUtils.setMenuIconsColorByColorLuminance
|
||||
import org.autojs.autojs6.R
|
||||
@@ -32,17 +24,27 @@ class ColorLibrariesActivity : ColorSelectBaseActivity() {
|
||||
|
||||
private lateinit var binding: MtActivityColorLibrariesBinding
|
||||
|
||||
private lateinit var mAdapter: ColorLibraryAdapter
|
||||
private lateinit var mRecyclerView: ThemeColorRecyclerView
|
||||
|
||||
private val customColor: Int
|
||||
get() = Pref.getInt(KEY_CUSTOM_COLOR, getColor(R.color.custom_color_default))
|
||||
private val libraryAdapter: ColorLibraryAdapter by lazy {
|
||||
ColorLibraryAdapter(presetColorLibraries) { library ->
|
||||
val intent = Intent(this, ColorLibraryActivity::class.java)
|
||||
intent.putExtra(INTENT_IDENTIFIER_LIBRARY_ID, library.id)
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
private val colorItemAdapter: ColorItemAdapter by lazy {
|
||||
ColorItemAdapter(presetColorItems, isLibraryIdentifierAppendedToDesc = true)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
ThemeChangeNotifier.themeChanged.observe(this) {
|
||||
setColor(ThemeColorManager.colorPrimary)
|
||||
mAdapter.notifyDataSetChanged()
|
||||
updateAppBarColorContent(ThemeColorManager.colorPrimary)
|
||||
libraryAdapter.notifyDataSetChanged()
|
||||
colorItemAdapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
MtActivityColorLibrariesBinding.inflate(layoutInflater).let {
|
||||
@@ -53,12 +55,9 @@ class ColorLibrariesActivity : ColorSelectBaseActivity() {
|
||||
}
|
||||
|
||||
binding.colorLibrariesRecyclerView.let {
|
||||
mRecyclerView = it
|
||||
it.layoutManager = LinearLayoutManager(this)
|
||||
it.adapter = ColorLibraryAdapter(colorLibraries) { library ->
|
||||
val intent = Intent(this, ColorLibraryActivity::class.java)
|
||||
intent.putExtra(INTENT_IDENTIFIER_LIBRARY_ID, library.id)
|
||||
startActivity(intent)
|
||||
}.also { mAdapter = it }
|
||||
it.adapter = libraryAdapter
|
||||
it.addItemDecoration(DividerItemDecoration(this, VERTICAL))
|
||||
ViewUtils.excludePaddingClippableViewFromNavigationBar(it)
|
||||
}
|
||||
@@ -69,32 +68,50 @@ class ColorLibrariesActivity : ColorSelectBaseActivity() {
|
||||
|
||||
binding.toolbar.setMenuIconsColorByColorLuminance(this, currentColor)
|
||||
|
||||
val searchItem = menu.findItem(R.id.action_search_color)
|
||||
val searchView = searchItem.actionView as? SearchView
|
||||
searchView?.queryHint = "搜索颜色库"
|
||||
searchView?.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
||||
override fun onQueryTextSubmit(query: String?): Boolean {
|
||||
filterLibraries(query)
|
||||
return true
|
||||
setUpSearchMenu(
|
||||
menu,
|
||||
onQueryTextSimpleListener = { query ->
|
||||
filterColorsFromColorItems(query, presetColorItems, colorItemAdapter)
|
||||
},
|
||||
onMenuItemActionExpand = {
|
||||
mRecyclerView.adapter = colorItemAdapter
|
||||
setUpSelectedPosition(colorItemAdapter)
|
||||
menu.forEach { it.isVisible = it.isVisible.not() }
|
||||
},
|
||||
onMenuItemActionCollapse = {
|
||||
mRecyclerView.adapter = libraryAdapter
|
||||
menu.forEach { it.isVisible = it.isVisible.not() }
|
||||
}
|
||||
)?.apply { queryHint = getString(R.string.text_search_all_colors) }
|
||||
|
||||
override fun onQueryTextChange(newText: String?): Boolean {
|
||||
filterLibraries(newText)
|
||||
return true
|
||||
}
|
||||
})
|
||||
return true
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
}
|
||||
|
||||
private fun filterLibraries(query: String?) {
|
||||
val filteredLibraries = when {
|
||||
query.isNullOrBlank() -> colorLibraries
|
||||
else -> colorLibraries.filter {
|
||||
val name = it.nameString ?: getString(it.nameRes)
|
||||
name.contains(query, ignoreCase = true)
|
||||
private fun setUpSelectedPosition(adapter: ColorItemAdapter) {
|
||||
when (Pref.getInt(KEY_SELECTED_COLOR_LIBRARY_ID, SELECT_NONE)) {
|
||||
SELECT_NONE -> when (val legacyIndex = Pref.getInt(KEY_LEGACY_SELECTED_COLOR_INDEX, SELECT_NONE)) {
|
||||
customColorPosition -> Unit
|
||||
SELECT_NONE, defaultColorPosition -> {
|
||||
adapter.selectedLibraryId = COLOR_LIBRARY_ID_DEFAULT
|
||||
adapter.selectedItemId = adapter.items.firstOrNull {
|
||||
it.libraryId == COLOR_LIBRARY_ID_DEFAULT && getColor(it.colorRes) == getColor(R.color.theme_color_default)
|
||||
}?.itemId ?: SELECT_NONE
|
||||
}
|
||||
else -> when (val calculatedIndex = legacyIndex - maxOf(customColorPosition, defaultColorPosition) - 1) {
|
||||
in ColorItems.MATERIAL_COLORS.indices -> {
|
||||
val (colorRes, _) = ColorItems.MATERIAL_COLORS[calculatedIndex]
|
||||
adapter.selectedLibraryId = COLOR_LIBRARY_ID_MATERIAL
|
||||
adapter.selectedItemId = adapter.items.firstOrNull {
|
||||
it.libraryId == COLOR_LIBRARY_ID_MATERIAL && it.colorRes == colorRes
|
||||
}?.itemId ?: SELECT_NONE
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
adapter.selectedLibraryId = Pref.getInt(KEY_SELECTED_COLOR_LIBRARY_ID, SELECT_NONE)
|
||||
adapter.selectedItemId = Pref.getInt(KEY_SELECTED_COLOR_LIBRARY_ITEM_ID, SELECT_NONE)
|
||||
}
|
||||
}
|
||||
mAdapter.updateData(filteredLibraries)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
|
||||
@@ -102,11 +119,15 @@ class ColorLibrariesActivity : ColorSelectBaseActivity() {
|
||||
showColorPicker()
|
||||
true
|
||||
}
|
||||
R.id.action_search_color -> {
|
||||
R.id.action_new_color_library -> {
|
||||
ViewUtils.showToast(this, R.string.text_under_development_title)
|
||||
true
|
||||
}
|
||||
R.id.action_new_color_library -> {
|
||||
R.id.action_import_color_library -> {
|
||||
ViewUtils.showToast(this, R.string.text_under_development_title)
|
||||
true
|
||||
}
|
||||
R.id.action_clone_color_library -> {
|
||||
ViewUtils.showToast(this, R.string.text_under_development_title)
|
||||
true
|
||||
}
|
||||
@@ -122,39 +143,6 @@ class ColorLibrariesActivity : ColorSelectBaseActivity() {
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
private fun showColorPicker() {
|
||||
ColorPickerDialog.newBuilder()
|
||||
.setAllowCustom(true)
|
||||
.setAllowPresets(true)
|
||||
.setDialogType(ColorPickerDialog.TYPE_CUSTOM)
|
||||
.setShowAlphaSlider(false)
|
||||
.setDialogTitle(R.string.dialog_title_color_palette)
|
||||
.setColor(customColor)
|
||||
.create()
|
||||
.setColorPickerDialogListener { dialogId: Int, color: Int ->
|
||||
savePrefsForLibraries()
|
||||
savePrefsForLegacy(color)
|
||||
|
||||
binding.toolbar.post { binding.toolbar.subtitle = getCurrentColorSummary(this, true) }
|
||||
|
||||
setColorWithAnimation(color)
|
||||
|
||||
ThemeColorManager.setThemeColor(color)
|
||||
ThemeChangeNotifier.notifyThemeChanged()
|
||||
}
|
||||
.show(supportFragmentManager, "ColorPickerTagForColorLibraries")
|
||||
}
|
||||
|
||||
private fun savePrefsForLibraries() {
|
||||
Pref.putInt(KEY_SELECTED_COLOR_LIBRARY_ID, COLOR_LIBRARY_CUSTOM_COLOR_ID)
|
||||
Pref.putInt(KEY_SELECTED_COLOR_LIBRARY_ITEM_ID, 0)
|
||||
}
|
||||
|
||||
private fun savePrefsForLegacy(color: Int) {
|
||||
Pref.putInt(KEY_CUSTOM_COLOR, color or -0x1000000)
|
||||
Pref.putInt(KEY_LEGACY_SELECTED_COLOR_INDEX, customColorPosition)
|
||||
}
|
||||
|
||||
private fun locateCurrentThemeColor() {
|
||||
checkAndGetTargetInfoForThemeColorLocate()?.let { target ->
|
||||
Intent(this, ColorLibraryActivity::class.java).apply {
|
||||
@@ -166,73 +154,24 @@ class ColorLibrariesActivity : ColorSelectBaseActivity() {
|
||||
|
||||
override fun getSubtitle() = getCurrentColorSummary(this)
|
||||
|
||||
inner class ColorLibraryAdapter(
|
||||
private var libraries: List<ColorLibrary>,
|
||||
private val onItemClick: (ColorLibrary) -> Unit,
|
||||
) : RecyclerView.Adapter<LibraryViewHolder>() {
|
||||
|
||||
// 当上层需要搜索过滤时调用该方法更新数据
|
||||
fun updateData(newLibraries: List<ColorLibrary>) {
|
||||
libraries = newLibraries
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): LibraryViewHolder {
|
||||
val view = LayoutInflater.from(parent.context)
|
||||
.inflate(R.layout.mt_color_libraries_recycler_view_item, parent, false)
|
||||
return LibraryViewHolder(view)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: LibraryViewHolder, position: Int) {
|
||||
val library = libraries[position]
|
||||
holder.bind(library)
|
||||
holder.itemView.setOnClickListener { onItemClick(library) }
|
||||
}
|
||||
|
||||
override fun getItemCount() = libraries.size
|
||||
|
||||
}
|
||||
|
||||
inner class LibraryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
|
||||
private val colorItemView: ImageView = itemView.findViewById(R.id.library_item)
|
||||
private val libraryName: TextView = itemView.findViewById(R.id.name)
|
||||
private val description: TextView = itemView.findViewById(R.id.description)
|
||||
|
||||
fun bind(library: ColorLibrary) {
|
||||
libraryName.text = library.nameString ?: getString(library.nameRes)
|
||||
|
||||
val size = library.colors.size
|
||||
description.text = resources.getQuantityString(R.plurals.text_items_total_sum, size, size)
|
||||
|
||||
val adjustedContrastColor = ColorUtils.adjustColorForContrast(getColor(R.color.window_background), ThemeColorManager.colorPrimary, 2.3)
|
||||
when {
|
||||
library.id == COLOR_LIBRARY_DEFAULT_COLORS_ID -> {
|
||||
colorItemView.setImageResource(R.drawable.ic_color_library_default)
|
||||
}
|
||||
!library.isUserDefined -> {
|
||||
colorItemView.setImageResource(R.drawable.ic_color_library_preset)
|
||||
}
|
||||
}
|
||||
colorItemView.imageTintList = ColorStateList.valueOf(adjustedContrastColor)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
const val COLOR_LIBRARY_CUSTOM_COLOR_ID = 0x10001
|
||||
const val COLOR_LIBRARY_ID_PALETTE = 0x10001
|
||||
const val COLOR_LIBRARY_ID_INTELLIGENT = 0x10002
|
||||
const val COLOR_LIBRARY_ID_CREATED = 0x10003
|
||||
const val COLOR_LIBRARY_ID_IMPORTED = 0x10004
|
||||
const val COLOR_LIBRARY_ID_CLONED = 0x10005
|
||||
|
||||
const val COLOR_LIBRARY_DEFAULT_COLORS_ID = 0x20001
|
||||
const val COLOR_LIBRARY_MATERIAL_COLORS_ID = 0x20002
|
||||
const val COLOR_LIBRARY_ANDROID_COLORS_ID = 0x20003
|
||||
const val COLOR_LIBRARY_CSS_COLORS_ID = 0x20004
|
||||
const val COLOR_LIBRARY_WEB_COLORS_ID = 0x20005
|
||||
const val COLOR_LIBRARY_ID_DEFAULT = 0x20001
|
||||
const val COLOR_LIBRARY_ID_MATERIAL = 0x20002
|
||||
const val COLOR_LIBRARY_ID_ANDROID = 0x20003
|
||||
const val COLOR_LIBRARY_ID_CSS = 0x20004
|
||||
const val COLOR_LIBRARY_ID_WEB = 0x20005
|
||||
|
||||
val colorLibraries by lazy {
|
||||
val presetColorLibraries by lazy {
|
||||
listOf(
|
||||
ColorLibrary(
|
||||
id = COLOR_LIBRARY_DEFAULT_COLORS_ID,
|
||||
PresetColorLibrary(
|
||||
id = COLOR_LIBRARY_ID_DEFAULT,
|
||||
nameRes = R.string.color_library_default_colors,
|
||||
titleRes = R.string.color_library_title_default_colors,
|
||||
identifierRes = R.string.color_library_identifier_default_colors,
|
||||
@@ -242,66 +181,80 @@ class ColorLibrariesActivity : ColorSelectBaseActivity() {
|
||||
R.color.window_background_light to R.string.window_background_light,
|
||||
R.color.window_background_night to R.string.window_background_night,
|
||||
).mapIndexed { index, (colorRes, nameRes) ->
|
||||
ColorItem(index, colorRes, nameRes)
|
||||
PresetColorItem(index, COLOR_LIBRARY_ID_DEFAULT, colorRes, nameRes)
|
||||
},
|
||||
),
|
||||
ColorLibrary(
|
||||
id = COLOR_LIBRARY_MATERIAL_COLORS_ID,
|
||||
PresetColorLibrary(
|
||||
id = COLOR_LIBRARY_ID_INTELLIGENT,
|
||||
nameRes = R.string.color_library_intelligent_colors,
|
||||
titleRes = R.string.color_library_title_intelligent_colors,
|
||||
identifierRes = R.string.color_library_identifier_intelligent_colors,
|
||||
colors = emptyList<PresetColorItem>(),
|
||||
),
|
||||
PresetColorLibrary(
|
||||
id = COLOR_LIBRARY_ID_MATERIAL,
|
||||
nameRes = R.string.color_library_material_design_colors,
|
||||
titleRes = R.string.color_library_title_material_design_colors,
|
||||
identifierRes = R.string.color_library_identifier_material_design_colors,
|
||||
colors = ColorItems.MATERIAL_COLORS.mapIndexed { index, (colorRes, nameRes) ->
|
||||
ColorItem(index, colorRes, nameRes)
|
||||
PresetColorItem(index, COLOR_LIBRARY_ID_MATERIAL, colorRes, nameRes)
|
||||
},
|
||||
),
|
||||
ColorLibrary(
|
||||
id = COLOR_LIBRARY_ANDROID_COLORS_ID,
|
||||
PresetColorLibrary(
|
||||
id = COLOR_LIBRARY_ID_ANDROID,
|
||||
nameRes = R.string.color_library_android_colors,
|
||||
titleRes = R.string.color_library_title_android_colors,
|
||||
identifierRes = R.string.color_library_identifier_android_colors,
|
||||
colors = ColorItems.ANDROID_COLORS.mapIndexed { index, (colorRes, nameRes) ->
|
||||
ColorItem(index, colorRes, nameRes)
|
||||
PresetColorItem(index, COLOR_LIBRARY_ID_ANDROID, colorRes, nameRes)
|
||||
},
|
||||
),
|
||||
ColorLibrary(
|
||||
id = COLOR_LIBRARY_CSS_COLORS_ID,
|
||||
PresetColorLibrary(
|
||||
id = COLOR_LIBRARY_ID_CSS,
|
||||
nameRes = R.string.color_library_css_colors,
|
||||
titleRes = R.string.color_library_title_css_colors,
|
||||
identifierRes = R.string.color_library_identifier_css_colors,
|
||||
colors = ColorItems.CSS_COLORS.mapIndexed { index, (colorRes, nameRes) ->
|
||||
ColorItem(index, colorRes, nameRes)
|
||||
PresetColorItem(index, COLOR_LIBRARY_ID_CSS, colorRes, nameRes)
|
||||
},
|
||||
),
|
||||
ColorLibrary(
|
||||
id = COLOR_LIBRARY_WEB_COLORS_ID,
|
||||
PresetColorLibrary(
|
||||
id = COLOR_LIBRARY_ID_WEB,
|
||||
nameRes = R.string.color_library_web_colors,
|
||||
titleRes = R.string.color_library_title_web_colors,
|
||||
identifierRes = R.string.color_library_identifier_web_colors,
|
||||
colors = ColorItems.WEB_COLORS.mapIndexed { index, (colorRes, nameRes) ->
|
||||
ColorItem(index, colorRes, nameRes)
|
||||
PresetColorItem(index, COLOR_LIBRARY_ID_WEB, colorRes, nameRes)
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
data class ColorItem(
|
||||
val id: Int,
|
||||
val colorRes: Int = R.color.md_black_1000,
|
||||
val nameRes: Int = R.string.text_unknown,
|
||||
val colorInt: Int? = null,
|
||||
val nameString: String? = null,
|
||||
val presetColorItems by lazy {
|
||||
presetColorLibraries.flatMap { it.colors }
|
||||
}
|
||||
|
||||
data class PresetColorItem(
|
||||
val itemId: Int,
|
||||
val libraryId: Int,
|
||||
val colorRes: Int,
|
||||
val nameRes: Int,
|
||||
)
|
||||
|
||||
data class ColorLibrary(
|
||||
data class PresetColorLibrary(
|
||||
val id: Int,
|
||||
val nameRes: Int = R.string.text_color_library,
|
||||
val titleRes: Int? = null,
|
||||
val identifierRes: Int? = null,
|
||||
val nameString: String? = null,
|
||||
val titleString: String? = null,
|
||||
val colors: List<ColorItem> = emptyList(),
|
||||
var isUserDefined: Boolean = false,
|
||||
)
|
||||
val nameRes: Int,
|
||||
val titleRes: Int,
|
||||
val identifierRes: Int,
|
||||
val colors: List<PresetColorItem> = emptyList(),
|
||||
) {
|
||||
val isIntelligent get() = id == COLOR_LIBRARY_ID_INTELLIGENT
|
||||
val isCreated get() = id == COLOR_LIBRARY_ID_CREATED
|
||||
val isImported get() = id == COLOR_LIBRARY_ID_IMPORTED
|
||||
val isCloned get() = id == COLOR_LIBRARY_ID_CLONED
|
||||
val isDefault get() = id == COLOR_LIBRARY_ID_DEFAULT
|
||||
val isMaterial get() = id == COLOR_LIBRARY_ID_MATERIAL
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -6,18 +6,12 @@ import android.animation.ArgbEvaluator
|
||||
import android.animation.ValueAnimator
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.core.view.forEach
|
||||
import androidx.recyclerview.widget.DividerItemDecoration
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.LinearSmoothScroller
|
||||
@@ -26,14 +20,11 @@ import androidx.recyclerview.widget.RecyclerView.VERTICAL
|
||||
import androidx.recyclerview.widget.ThemeColorRecyclerView
|
||||
import org.autojs.autojs.core.image.ColorItems
|
||||
import org.autojs.autojs.core.pref.Pref
|
||||
import org.autojs.autojs.theme.ThemeChangeNotifier
|
||||
import org.autojs.autojs.theme.ThemeColorHelper
|
||||
import org.autojs.autojs.theme.ThemeColorManager
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.COLOR_LIBRARY_DEFAULT_COLORS_ID
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.COLOR_LIBRARY_MATERIAL_COLORS_ID
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.ColorItem
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.ColorLibrary
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.colorLibraries
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.COLOR_LIBRARY_ID_DEFAULT
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.COLOR_LIBRARY_ID_MATERIAL
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.PresetColorItem
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.PresetColorLibrary
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.presetColorLibraries
|
||||
import org.autojs.autojs.util.ColorUtils
|
||||
import org.autojs.autojs.util.ViewUtils
|
||||
import org.autojs.autojs.util.ViewUtils.onceGlobalLayout
|
||||
@@ -49,69 +40,39 @@ class ColorLibraryActivity : ColorSelectBaseActivity() {
|
||||
private lateinit var binding: MtActivityColorLibraryBinding
|
||||
|
||||
private lateinit var mAdapter: ColorItemAdapter
|
||||
private lateinit var mLibrary: ColorLibrary
|
||||
private lateinit var mLibrary: PresetColorLibrary
|
||||
|
||||
private var mInitiallyIdScrollTo by Delegates.notNull<Int>()
|
||||
|
||||
private var mSelectedPosition = SELECT_NONE
|
||||
private var mSelectedColor: Int? = null
|
||||
private var mInitiallyItemIdScrollTo by Delegates.notNull<Int>()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
val libraryId = intent.getIntExtra(INTENT_IDENTIFIER_LIBRARY_ID, -1)
|
||||
val library = colorLibraries.find { it.id == libraryId }?.also { lib ->
|
||||
val library = presetColorLibraries.find { it.id == libraryId }?.also { lib ->
|
||||
mLibrary = lib
|
||||
} ?: throw RuntimeException("Unknown library id: $libraryId")
|
||||
|
||||
mInitiallyIdScrollTo = intent.getIntExtra(INTENT_IDENTIFIER_COLOR_ITEM_ID_SCROLL_TO, -1)
|
||||
mInitiallyItemIdScrollTo = intent.getIntExtra(INTENT_IDENTIFIER_COLOR_ITEM_ID_SCROLL_TO, -1)
|
||||
|
||||
MtActivityColorLibraryBinding.inflate(layoutInflater).let {
|
||||
binding = it
|
||||
setContentView(it.root)
|
||||
setUpToolbar(it.toolbar)
|
||||
setUpAppBar(it.appBar, it.appBarContainer)
|
||||
it.toolbar.title = library.let {
|
||||
it.titleString
|
||||
?: it.titleRes?.let { resId -> getString(resId) }
|
||||
?: it.nameString
|
||||
?: getString(it.nameRes)
|
||||
}
|
||||
if (library.id == Pref.getInt(KEY_SELECTED_COLOR_LIBRARY_ID, SELECT_NONE)) {
|
||||
it.toolbar.subtitle = getCurrentColorSummary(this, true)
|
||||
}
|
||||
it.toolbar.title = getString(library.titleRes)
|
||||
updateSubtitle()
|
||||
}
|
||||
|
||||
binding.colorLibraryRecyclerView.let { it ->
|
||||
it.layoutManager = LinearLayoutManager(this)
|
||||
it.adapter = ColorItemAdapter(library.colors) { colorItem, itemView ->
|
||||
savePrefsForLibraries(library, colorItem)
|
||||
savePrefsForLegacy(library, colorItem)
|
||||
|
||||
it.post { binding.toolbar.subtitle = getCurrentColorSummary(this, true) }
|
||||
|
||||
val selectedColor = getColor(colorItem.colorRes).also { mSelectedColor = it }
|
||||
setColorWithAnimation(selectedColor)
|
||||
|
||||
val adapter = it.adapter as ColorItemAdapter
|
||||
val currentPosition = it.getChildViewHolder(itemView).bindingAdapterPosition
|
||||
if (mSelectedPosition != SELECT_NONE) {
|
||||
adapter.notifyItemChanged(mSelectedPosition)
|
||||
mSelectedPosition = currentPosition
|
||||
adapter.notifyItemChanged(currentPosition)
|
||||
} else {
|
||||
mSelectedPosition = currentPosition
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
ThemeColorManager.setThemeColor(selectedColor)
|
||||
ThemeChangeNotifier.notifyThemeChanged()
|
||||
updateAppBarColorContent(getColor(colorItem.colorRes))
|
||||
}.also { mAdapter = it }
|
||||
|
||||
it.addItemDecoration(DividerItemDecoration(this, VERTICAL))
|
||||
ViewUtils.excludePaddingClippableViewFromNavigationBar(it)
|
||||
|
||||
setUpSelectedPosition()
|
||||
setUpSelectedPosition(mAdapter)
|
||||
|
||||
it.onceGlobalLayout {
|
||||
scrollToPositionOnceIfNeeded(it)
|
||||
@@ -119,36 +80,43 @@ class ColorLibraryActivity : ColorSelectBaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun setUpSelectedPosition() {
|
||||
override fun getSubtitle(): String? = when (mLibrary.id) {
|
||||
Pref.getInt(KEY_SELECTED_COLOR_LIBRARY_ID, SELECT_NONE) -> {
|
||||
getCurrentColorSummary(this, true)
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
|
||||
private fun setUpSelectedPosition(adapter: ColorItemAdapter) {
|
||||
when (Pref.getInt(KEY_SELECTED_COLOR_LIBRARY_ID, SELECT_NONE)) {
|
||||
SELECT_NONE -> when (val legacyIndex = Pref.getInt(KEY_LEGACY_SELECTED_COLOR_INDEX, SELECT_NONE)) {
|
||||
customColorPosition -> Unit
|
||||
SELECT_NONE, defaultColorPosition -> when (mLibrary.id) {
|
||||
COLOR_LIBRARY_DEFAULT_COLORS_ID -> {
|
||||
val index = mLibrary.colors.indexOfFirst { getColor(it.colorRes) == getColor(R.color.theme_color_default) }
|
||||
if (index >= 0) mSelectedPosition = index
|
||||
COLOR_LIBRARY_ID_DEFAULT -> {
|
||||
adapter.selectedLibraryId = COLOR_LIBRARY_ID_DEFAULT
|
||||
adapter.selectedItemId = mLibrary.colors.firstOrNull { getColor(it.colorRes) == getColor(R.color.theme_color_default) }?.itemId ?: SELECT_NONE
|
||||
}
|
||||
}
|
||||
else -> when (val calculatedIndex = legacyIndex - maxOf(customColorPosition, defaultColorPosition) - 1) {
|
||||
in ColorItems.MATERIAL_COLORS.indices -> {
|
||||
val (colorRes, _) = ColorItems.MATERIAL_COLORS[calculatedIndex]
|
||||
val index = mLibrary.colors.indexOfFirst { it.colorRes == colorRes }
|
||||
if (index >= 0) mSelectedPosition = index
|
||||
adapter.selectedLibraryId = COLOR_LIBRARY_ID_MATERIAL
|
||||
adapter.selectedItemId = mLibrary.colors.firstOrNull { it.colorRes == colorRes }?.itemId ?: SELECT_NONE
|
||||
}
|
||||
}
|
||||
}
|
||||
mLibrary.id -> {
|
||||
val libraryItemId = Pref.getInt(KEY_SELECTED_COLOR_LIBRARY_ITEM_ID, SELECT_NONE)
|
||||
mSelectedPosition = mLibrary.colors.indexOfFirst { it.id == libraryItemId }.takeIf { it != SELECT_NONE } ?: SELECT_NONE
|
||||
adapter.selectedLibraryId = mLibrary.id
|
||||
adapter.selectedItemId = Pref.getInt(KEY_SELECTED_COLOR_LIBRARY_ITEM_ID, SELECT_NONE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun scrollToPositionOnceIfNeeded(recyclerView: ThemeColorRecyclerView) {
|
||||
if (mInitiallyIdScrollTo < 0) return
|
||||
val targetPosition = mLibrary.colors.indexOfFirst { it.id == mInitiallyIdScrollTo }
|
||||
if (mInitiallyItemIdScrollTo < 0) return
|
||||
val targetPosition = mLibrary.colors.indexOfFirst { it.itemId == mInitiallyItemIdScrollTo }
|
||||
if (targetPosition < 0) {
|
||||
mInitiallyIdScrollTo = -1
|
||||
mInitiallyItemIdScrollTo = -1
|
||||
return
|
||||
}
|
||||
val targetItem = mLibrary.colors[targetPosition]
|
||||
@@ -174,10 +142,10 @@ class ColorLibraryActivity : ColorSelectBaseActivity() {
|
||||
manager.startSmoothScroll(smoothScroller)
|
||||
} ?: recyclerView.smoothScrollToPosition(targetPosition)
|
||||
|
||||
mInitiallyIdScrollTo = -1
|
||||
mInitiallyItemIdScrollTo = -1
|
||||
}
|
||||
|
||||
private fun highlightColorItem(recyclerView: RecyclerView, targetPosition: Int, targetItem: ColorItem) {
|
||||
private fun highlightColorItem(recyclerView: RecyclerView, targetPosition: Int, targetItem: PresetColorItem) {
|
||||
val viewHolder = recyclerView.findViewHolderForAdapterPosition(targetPosition)
|
||||
viewHolder?.itemView?.let { itemView ->
|
||||
val originalColor = (itemView.background as? ColorDrawable)?.color ?: getColor(R.color.window_background)
|
||||
@@ -229,79 +197,22 @@ class ColorLibraryActivity : ColorSelectBaseActivity() {
|
||||
animator.start()
|
||||
}
|
||||
|
||||
private fun savePrefsForLibraries(library: ColorLibrary?, colorItem: ColorItem) {
|
||||
Pref.putInt(KEY_SELECTED_COLOR_LIBRARY_ID, library?.id ?: -1)
|
||||
Pref.putInt(KEY_SELECTED_COLOR_LIBRARY_ITEM_ID, colorItem.id)
|
||||
}
|
||||
|
||||
private fun savePrefsForLegacy(library: ColorLibrary?, colorItem: ColorItem) {
|
||||
when (library?.id) {
|
||||
COLOR_LIBRARY_DEFAULT_COLORS_ID -> {
|
||||
if (getColor(colorItem.colorRes) == getColor(R.color.theme_color_default)) {
|
||||
Pref.putInt(KEY_LEGACY_SELECTED_COLOR_INDEX, defaultColorPosition)
|
||||
} else {
|
||||
Pref.putInt(KEY_LEGACY_SELECTED_COLOR_INDEX, SELECT_NONE)
|
||||
}
|
||||
}
|
||||
COLOR_LIBRARY_MATERIAL_COLORS_ID -> {
|
||||
val index = colorItem.id
|
||||
if (index !in ColorItems.MATERIAL_COLORS.indices) {
|
||||
Pref.putInt(KEY_LEGACY_SELECTED_COLOR_INDEX, SELECT_NONE)
|
||||
} else {
|
||||
val fixedIndex = maxOf(
|
||||
defaultColorPosition,
|
||||
customColorPosition,
|
||||
) + 1 + index
|
||||
Pref.putInt(KEY_LEGACY_SELECTED_COLOR_INDEX, fixedIndex)
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
Pref.putInt(KEY_LEGACY_SELECTED_COLOR_INDEX, SELECT_NONE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.menu_color_library, menu)
|
||||
|
||||
binding.toolbar.setMenuIconsColorByColorLuminance(this, currentColor)
|
||||
|
||||
val searchItem = menu.findItem(R.id.action_search_color)
|
||||
val searchView = searchItem.actionView as? SearchView
|
||||
searchView?.queryHint = "搜索颜色"
|
||||
searchView?.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
||||
override fun onQueryTextSubmit(query: String?): Boolean {
|
||||
filterColors(query)
|
||||
return true
|
||||
}
|
||||
setUpSearchMenu(
|
||||
menu,
|
||||
onQueryTextSimpleListener = { query -> filterColorsFromColorItems(query, mLibrary.colors, mAdapter) },
|
||||
onMenuItemActionExpand = { menu.forEach { it.isVisible = it.isVisible.not() } },
|
||||
onMenuItemActionCollapse = { menu.forEach { it.isVisible = it.isVisible.not() } },
|
||||
)
|
||||
|
||||
override fun onQueryTextChange(newText: String?): Boolean {
|
||||
filterColors(newText)
|
||||
return true
|
||||
}
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
||||
private fun filterColors(@Suppress("unused") query: String?) {
|
||||
// if (library == null) return
|
||||
// val filteredColors = if (query.isNullOrBlank()) {
|
||||
// library!!.colors
|
||||
// } else {
|
||||
// library!!.colors.filter { colorItem ->
|
||||
// // 假设可以通过资源 id 获取对应的字符串显示,再做匹配
|
||||
// val name = getString(colorItem.nameRes)
|
||||
// name.contains(query, ignoreCase = true)
|
||||
// }
|
||||
// }
|
||||
// adapter.updateData(filteredColors)
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
|
||||
R.id.action_search_color -> {
|
||||
ViewUtils.showToast(this, R.string.text_under_development_title)
|
||||
true
|
||||
}
|
||||
R.id.action_locate_current_theme_color -> {
|
||||
locateCurrentThemeColor()
|
||||
true
|
||||
@@ -323,7 +234,7 @@ class ColorLibraryActivity : ColorSelectBaseActivity() {
|
||||
itemView.setBackgroundColor(getColor(R.color.window_background))
|
||||
}
|
||||
|
||||
mInitiallyIdScrollTo = targetIndex
|
||||
mInitiallyItemIdScrollTo = targetIndex
|
||||
scrollToPositionOnceIfNeeded(recyclerView)
|
||||
}
|
||||
else -> {
|
||||
@@ -337,65 +248,4 @@ class ColorLibraryActivity : ColorSelectBaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
inner class ColorItemAdapter(
|
||||
private var items: List<ColorItem>,
|
||||
private val onItemClick: (ColorItem, View) -> Unit,
|
||||
) : RecyclerView.Adapter<ColorViewHolder>() {
|
||||
|
||||
fun updateData(newItems: List<ColorItem>) {
|
||||
items = newItems
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ColorViewHolder {
|
||||
val view = LayoutInflater.from(parent.context)
|
||||
.inflate(R.layout.mt_color_library_recycler_view_item, parent, false)
|
||||
return ColorViewHolder(view)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ColorViewHolder, position: Int) {
|
||||
val item = items[position]
|
||||
|
||||
when (val tag = holder.itemView.tag) {
|
||||
is ValueAnimator -> {
|
||||
tag.cancel()
|
||||
holder.itemView.tag = null
|
||||
holder.itemView.setBackgroundColor(getColor(R.color.window_background))
|
||||
}
|
||||
}
|
||||
|
||||
holder.bind(item, position)
|
||||
holder.itemView.setOnClickListener { onItemClick(item, holder.itemView) }
|
||||
}
|
||||
|
||||
override fun getItemCount() = items.size
|
||||
|
||||
}
|
||||
|
||||
inner class ColorViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
|
||||
private val colorView: ImageView = itemView.findViewById(R.id.color)
|
||||
private val nameView: TextView = itemView.findViewById(R.id.name)
|
||||
private val descView: TextView = itemView.findViewById(R.id.description)
|
||||
|
||||
fun bind(item: ColorItem, position: Int) {
|
||||
val color = getColor(item.colorRes)
|
||||
ThemeColorHelper.setBackgroundColor(colorView, color)
|
||||
nameView.text = item.nameString ?: getString(item.nameRes)
|
||||
descView.text = String.format("#%06X", 0xFFFFFF and color)
|
||||
setChecked(color, mSelectedPosition == position)
|
||||
}
|
||||
|
||||
fun setChecked(@ColorInt color: Int, checked: Boolean) {
|
||||
if (checked) {
|
||||
colorView.setImageResource(R.drawable.mt_ic_check_white_36dp)
|
||||
val tintRes = if (ViewUtils.isLuminanceLight(color)) R.color.day else R.color.night
|
||||
colorView.imageTintList = ColorStateList.valueOf(getColor(tintRes))
|
||||
} else {
|
||||
colorView.setImageDrawable(null)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.autojs.autojs.theme.app
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.autojs.autojs6.R
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
class ColorLibraryAdapter(
|
||||
private var libraries: List<ColorLibrariesActivity.Companion.PresetColorLibrary>,
|
||||
private val onItemClick: (ColorLibrariesActivity.Companion.PresetColorLibrary) -> Unit,
|
||||
) : RecyclerView.Adapter<ColorLibraryViewHolder>() {
|
||||
|
||||
fun updateData(newLibraries: List<ColorLibrariesActivity.Companion.PresetColorLibrary>) {
|
||||
libraries = newLibraries
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ColorLibraryViewHolder {
|
||||
val view = LayoutInflater.from(parent.context)
|
||||
.inflate(R.layout.mt_color_libraries_recycler_view_item, parent, false)
|
||||
return ColorLibraryViewHolder(view)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ColorLibraryViewHolder, position: Int) {
|
||||
val library = libraries[position]
|
||||
holder.bind(library)
|
||||
holder.itemView.setOnClickListener { onItemClick(library) }
|
||||
}
|
||||
|
||||
override fun getItemCount() = libraries.size
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.autojs.autojs.theme.app
|
||||
|
||||
import android.content.res.ColorStateList
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.autojs.autojs.theme.ThemeColorManager
|
||||
import org.autojs.autojs.util.ColorUtils
|
||||
import org.autojs.autojs6.R
|
||||
|
||||
class ColorLibraryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
|
||||
private val context = itemView.context
|
||||
private val resources = itemView.resources
|
||||
|
||||
private val colorItemView: ImageView = itemView.findViewById(R.id.library_item)
|
||||
private val libraryName: TextView = itemView.findViewById(R.id.name)
|
||||
private val description: TextView = itemView.findViewById(R.id.description)
|
||||
|
||||
fun bind(library: ColorLibrariesActivity.Companion.PresetColorLibrary) {
|
||||
libraryName.text = context.getString(library.nameRes)
|
||||
|
||||
val size = library.colors.size
|
||||
description.text = resources.getQuantityString(R.plurals.text_items_total_sum, size, size)
|
||||
|
||||
val adjustedContrastColor = ColorUtils.adjustColorForContrast(context.getColor(R.color.window_background), ThemeColorManager.colorPrimary, 2.3)
|
||||
when {
|
||||
library.isDefault -> colorItemView.setImageResource(R.drawable.ic_color_library_default)
|
||||
library.isIntelligent -> colorItemView.setImageResource(R.drawable.ic_color_library_intelligent)
|
||||
library.isCreated -> colorItemView.setImageResource(R.drawable.ic_color_library_created)
|
||||
library.isImported -> colorItemView.setImageResource(R.drawable.ic_color_library_imported)
|
||||
library.isCloned -> colorItemView.setImageResource(R.drawable.ic_color_library_cloned)
|
||||
else -> colorItemView.setImageResource(R.drawable.ic_color_library_preset)
|
||||
}
|
||||
colorItemView.imageTintList = ColorStateList.valueOf(adjustedContrastColor)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,7 +23,7 @@ class ColorSelectActivity : ColorSelectBaseActivity() {
|
||||
override fun onItemClick(v: View?, position: Int) {
|
||||
mColorSettingRecyclerView.selectedThemeColor?.let {
|
||||
mSelectedPosition = position
|
||||
setColorWithAnimation(it.colorPrimary)
|
||||
updateAppBarColorContent(it.colorPrimary)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,26 +2,43 @@ package org.autojs.autojs.theme.app
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.res.Configuration
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewAnimationUtils
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
import com.jaredrummler.android.colorpicker.ColorPickerDialog
|
||||
import io.codetail.widget.RevealFrameLayout
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.autojs.autojs.annotation.ReservedForCompatibility
|
||||
import org.autojs.autojs.core.image.ColorItems
|
||||
import org.autojs.autojs.core.pref.Pref
|
||||
import org.autojs.autojs.theme.ThemeChangeNotifier
|
||||
import org.autojs.autojs.theme.ThemeColorManager
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.COLOR_LIBRARY_CUSTOM_COLOR_ID
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.colorLibraries
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.COLOR_LIBRARY_ID_PALETTE
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.PresetColorItem
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.PresetColorLibrary
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.presetColorLibraries
|
||||
import org.autojs.autojs.ui.BaseActivity
|
||||
import org.autojs.autojs.util.ColorUtils
|
||||
import org.autojs.autojs.util.ViewUtils
|
||||
import org.autojs.autojs.util.ViewUtils.onceGlobalLayout
|
||||
import org.autojs.autojs.util.ViewUtils.setColorsByColorLuminance
|
||||
import org.autojs.autojs.util.ViewUtils.setMenuIconsColorByColorLuminance
|
||||
import org.autojs.autojs.util.ViewUtils.setNavigationIconColorByColorLuminance
|
||||
import org.autojs.autojs.util.ViewUtils.setTitlesTextColorByColorLuminance
|
||||
import org.autojs.autojs6.R
|
||||
import java.util.*
|
||||
import kotlin.math.hypot
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
@@ -40,6 +57,12 @@ abstract class ColorSelectBaseActivity : BaseActivity() {
|
||||
|
||||
private lateinit var mTitle: String
|
||||
|
||||
private var mSearchJob: Job? = null
|
||||
private var mSearchView: SearchView? = null
|
||||
|
||||
private val customColor: Int
|
||||
get() = Pref.getInt(KEY_CUSTOM_COLOR, getColor(R.color.custom_color_default))
|
||||
|
||||
protected var currentColor by Delegates.notNull<Int>()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -61,27 +84,76 @@ abstract class ColorSelectBaseActivity : BaseActivity() {
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
}
|
||||
|
||||
protected fun setUpSearchMenu(menu: Menu, onQueryTextSimpleListener: (text: String?) -> Unit, onMenuItemActionExpand: (item: MenuItem) -> Unit = {}, onMenuItemActionCollapse: (item: MenuItem) -> Unit = {}): SearchView? {
|
||||
val menuItem = menu.findItem(R.id.action_search_color) ?: return null
|
||||
menuItem.setOnActionExpandListener(object : MenuItem.OnActionExpandListener {
|
||||
override fun onMenuItemActionExpand(item: MenuItem) = true.also {
|
||||
mToolbar.onceGlobalLayout { updateToolbarColors() }
|
||||
onMenuItemActionExpand(item)
|
||||
}
|
||||
|
||||
override fun onMenuItemActionCollapse(item: MenuItem) = true.also {
|
||||
onQueryTextSimpleListener(null)
|
||||
onMenuItemActionCollapse(item)
|
||||
}
|
||||
})
|
||||
return setUpSearchMenu(menuItem.actionView, onQueryTextSimpleListener)
|
||||
}
|
||||
|
||||
private fun setUpSearchMenu(searchView: View?, onQueryTextSimpleListener: (text: String?) -> Unit): SearchView? {
|
||||
return setUpSearchMenu(searchView, object : SearchView.OnQueryTextListener {
|
||||
override fun onQueryTextSubmit(query: String?) = true.also { onQueryTextSimpleListener(query) }
|
||||
override fun onQueryTextChange(newText: String?) = true.also { onQueryTextSimpleListener(newText) }
|
||||
})
|
||||
}
|
||||
|
||||
protected fun setUpSearchMenu(menu: Menu, onQueryTextListener: SearchView.OnQueryTextListener? = null, onMenuItemActionExpand: (item: MenuItem) -> Unit = {}, onMenuItemActionCollapse: (item: MenuItem) -> Unit = {}): SearchView? {
|
||||
val menuItem = menu.findItem(R.id.action_search_color) ?: return null
|
||||
menuItem.setOnActionExpandListener(object : MenuItem.OnActionExpandListener {
|
||||
override fun onMenuItemActionExpand(item: MenuItem) = true.also { onMenuItemActionExpand(item) }
|
||||
override fun onMenuItemActionCollapse(item: MenuItem) = true.also { onMenuItemActionCollapse(item) }
|
||||
})
|
||||
return setUpSearchMenu(menuItem.actionView, onQueryTextListener)
|
||||
}
|
||||
|
||||
private fun setUpSearchMenu(searchView: View?, onQueryTextListener: SearchView.OnQueryTextListener? = null): SearchView? {
|
||||
if (searchView !is SearchView) return null
|
||||
return searchView.apply {
|
||||
mSearchView = this
|
||||
queryHint = context.getString(R.string.text_search_color)
|
||||
setOnQueryTextListener(onQueryTextListener)
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun getSubtitle(): String? = null
|
||||
|
||||
override fun initThemeColors() {
|
||||
super.initThemeColors()
|
||||
mToolbar.setTitlesTextColorByColorLuminance(this, currentColor)
|
||||
mToolbar.setNavigationIconColorByColorLuminance(this, currentColor)
|
||||
updateToolbarColors()
|
||||
updateSearchViewColors()
|
||||
ViewUtils.setStatusBarAppearanceLightByColorLuminance(this, currentColor)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
updateToolbarIconsColor()
|
||||
updateToolbarColors()
|
||||
updateSearchViewColors()
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
}
|
||||
|
||||
private fun updateToolbarIconsColor() {
|
||||
private fun updateToolbarColors() {
|
||||
mToolbar.setMenuIconsColorByColorLuminance(this, currentColor)
|
||||
mToolbar.setNavigationIconColorByColorLuminance(this, currentColor)
|
||||
mToolbar.setTitlesTextColorByColorLuminance(this, currentColor)
|
||||
}
|
||||
|
||||
protected fun setColorWithAnimation(colorTo: Int) {
|
||||
setColor(colorTo)
|
||||
ViewAnimationUtils.createCircularReveal(
|
||||
private fun updateSearchViewColors() {
|
||||
mSearchView?.setColorsByColorLuminance(this, currentColor)
|
||||
}
|
||||
|
||||
protected fun updateAppBarColorContent(colorTo: Int) {
|
||||
setColors(colorTo)
|
||||
updateSubtitle()
|
||||
if (hasWindowFocus()) ViewAnimationUtils.createCircularReveal(
|
||||
/* view = */ mAppBarLayout,
|
||||
/* centerX = */ mAppBarLayout.left,
|
||||
/* centerY = */ mAppBarLayout.bottom,
|
||||
@@ -93,14 +165,15 @@ abstract class ColorSelectBaseActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
protected fun setColor(colorTo: Int) {
|
||||
protected fun updateSubtitle() {
|
||||
mToolbar.post { mToolbar.subtitle = getSubtitle() }
|
||||
}
|
||||
|
||||
private fun setColors(colorTo: Int) {
|
||||
mAppBarContainer.setBackgroundColor(currentColor)
|
||||
mAppBarLayout.setBackgroundColor(colorTo)
|
||||
currentColor = colorTo
|
||||
|
||||
initThemeColors()
|
||||
updateToolbarIconsColor()
|
||||
mToolbar.subtitle = getSubtitle()
|
||||
}
|
||||
|
||||
protected fun setUpAppBar(appBar: AppBarLayout, appBarContainer: RevealFrameLayout) {
|
||||
@@ -110,42 +183,135 @@ abstract class ColorSelectBaseActivity : BaseActivity() {
|
||||
|
||||
protected fun checkAndGetTargetInfoForThemeColorLocate(): TargetInfoForLocate? {
|
||||
val targetLibraryId = Pref.getInt(KEY_SELECTED_COLOR_LIBRARY_ID, -1)
|
||||
if (targetLibraryId == COLOR_LIBRARY_CUSTOM_COLOR_ID) {
|
||||
ViewUtils.showToast(this, "当前主题色为自定义颜色", true)
|
||||
// 提示
|
||||
// 当前主题色为自定义颜色
|
||||
//
|
||||
// HEX: #FF3300
|
||||
// RGB: 255, 0, 0
|
||||
// HSL: 0, 0, 0.14
|
||||
//
|
||||
// 使用调色盘可查看或修改自定义主题颜色
|
||||
// 调色盘 关闭
|
||||
if (targetLibraryId == COLOR_LIBRARY_ID_PALETTE) {
|
||||
MaterialDialog.Builder(this)
|
||||
.title(R.string.text_prompt)
|
||||
.content(R.string.content_current_theme_color_configured_by_palette, ColorUtils.toHex(currentColor, 6))
|
||||
.neutralText(R.string.dialog_button_open_color_palette)
|
||||
.neutralColorRes(R.color.dialog_button_hint)
|
||||
.onNeutral { _, _ -> showColorPicker() }
|
||||
.negativeText(R.string.dialog_button_dismiss)
|
||||
.negativeColorRes(R.color.dialog_button_default)
|
||||
.show()
|
||||
return null
|
||||
}
|
||||
val targetLibrary = colorLibraries.find { it.id == targetLibraryId }
|
||||
val targetLibrary = presetColorLibraries.find { it.id == targetLibraryId }
|
||||
if (targetLibrary == null) {
|
||||
ViewUtils.showToast(this, "主题色库定位失败", true)
|
||||
// 定位失败
|
||||
// 无法定位主题色所在颜色库
|
||||
//
|
||||
// Target lib ID: targetLibraryId
|
||||
// Color libs IDs: [ colorLibraries.sorted().joinToString(", ") { "${it.id}" } ]
|
||||
// 复制信息 关闭
|
||||
MaterialDialog.Builder(this)
|
||||
.title(R.string.text_failed_to_locate)
|
||||
.content(
|
||||
getString(R.string.content_failed_to_locate_library_for_theme_color) + "\n" +
|
||||
"\n" +
|
||||
"Target library ID: 0x${targetLibraryId.toString(16)}" + "\n" +
|
||||
"Color library IDs: [ ${presetColorLibraries.sortedBy { it.id }.joinToString(", ") { "0x${it.id.toString(16)}" }} ]"
|
||||
)
|
||||
.negativeText(R.string.dialog_button_dismiss)
|
||||
.negativeColorRes(R.color.dialog_button_default)
|
||||
.show()
|
||||
return null
|
||||
}
|
||||
val targetIndex = Pref.getInt(KEY_SELECTED_COLOR_LIBRARY_ITEM_ID, -1)
|
||||
if (targetIndex !in targetLibrary.colors.indices) {
|
||||
ViewUtils.showToast(this, "主题色条目定位失败", true)
|
||||
// 定位失败
|
||||
// 无法确定主题色条目的索引值
|
||||
//
|
||||
// Target index: targetLibraryId
|
||||
// Color indicies: [ 0..90 ] (注意 90 为 size - 1)
|
||||
// 复制信息 关闭
|
||||
val targetItemIndex = Pref.getInt(KEY_SELECTED_COLOR_LIBRARY_ITEM_ID, -1)
|
||||
if (targetItemIndex !in targetLibrary.colors.indices) {
|
||||
MaterialDialog.Builder(this)
|
||||
.title(R.string.text_failed_to_locate)
|
||||
.content(
|
||||
getString(R.string.content_failed_to_determine_index_of_theme_color_item) + "\n" +
|
||||
"\n" +
|
||||
"Target item index: $targetItemIndex" + "\n" +
|
||||
"Item indicies: [ 0..${targetLibrary.colors.size - 1} ]"
|
||||
)
|
||||
.negativeText(R.string.dialog_button_dismiss)
|
||||
.negativeColorRes(R.color.dialog_button_default)
|
||||
.show()
|
||||
return null
|
||||
}
|
||||
return TargetInfoForLocate(targetLibraryId, targetIndex)
|
||||
return TargetInfoForLocate(targetLibraryId, targetItemIndex)
|
||||
}
|
||||
|
||||
protected fun showColorPicker() {
|
||||
ColorPickerDialog.newBuilder()
|
||||
.setAllowCustom(true)
|
||||
.setAllowPresets(true)
|
||||
.setDialogType(ColorPickerDialog.TYPE_CUSTOM)
|
||||
.setShowAlphaSlider(false)
|
||||
.setDialogTitle(R.string.dialog_title_color_palette)
|
||||
.setColor(customColor)
|
||||
.create()
|
||||
.setColorPickerDialogListener { dialogId: Int, color: Int ->
|
||||
savePrefsForLibraries()
|
||||
savePrefsForLegacy(color)
|
||||
|
||||
updateAppBarColorContent(color)
|
||||
|
||||
ThemeColorManager.setThemeColor(color)
|
||||
ThemeChangeNotifier.notifyThemeChanged()
|
||||
}
|
||||
.show(supportFragmentManager, "ColorPickerTagForColorLibraries")
|
||||
}
|
||||
|
||||
private fun savePrefsForLibraries() {
|
||||
Pref.putInt(KEY_SELECTED_COLOR_LIBRARY_ID, COLOR_LIBRARY_ID_PALETTE)
|
||||
Pref.putInt(KEY_SELECTED_COLOR_LIBRARY_ITEM_ID, 0)
|
||||
}
|
||||
|
||||
private fun savePrefsForLegacy(color: Int) {
|
||||
Pref.putInt(KEY_CUSTOM_COLOR, color or -0x1000000)
|
||||
Pref.putInt(KEY_LEGACY_SELECTED_COLOR_INDEX, customColorPosition)
|
||||
}
|
||||
|
||||
protected fun filterColorsFromColorItems(query: String?, colorItems: List<PresetColorItem>, colorItemAdapter: ColorItemAdapter) {
|
||||
mSearchJob?.cancel()
|
||||
mSearchJob = lifecycleScope.launch {
|
||||
withContext(Dispatchers.Default) {
|
||||
if (query.isNullOrBlank()) return@withContext colorItems
|
||||
val normalizedQuery = normalizeForMatching(query)
|
||||
colorItems.filter { colorItem ->
|
||||
val colorHex = String.format("#%06X", 0xFFFFFF and getColor(colorItem.colorRes))
|
||||
if (query.startsWith("#")) {
|
||||
if (isRegexSearch(query.drop(1))) {
|
||||
val regex = compileRegexOrNull(extractPatternFromQuery(query.drop(1))) ?: return@filter false
|
||||
return@filter regex.containsMatchIn(colorHex)
|
||||
}
|
||||
return@filter colorHex.contains(query, ignoreCase = true)
|
||||
}
|
||||
val localName = getString(colorItem.nameRes)
|
||||
val enName = getLocalizedString(this@ColorSelectBaseActivity, colorItem.nameRes, Locale("en"))
|
||||
if (isRegexSearch(query)) {
|
||||
val regex = compileRegexOrNull(extractPatternFromQuery(query)) ?: return@filter false
|
||||
return@filter regex.containsMatchIn(localName) || regex.containsMatchIn(enName)
|
||||
}
|
||||
return@filter normalizeForMatching(localName).contains(normalizedQuery, ignoreCase = true)
|
||||
|| normalizeForMatching(enName).contains(normalizedQuery, ignoreCase = true)
|
||||
}
|
||||
}.let { filteredResult -> colorItemAdapter.updateData(filteredResult) }
|
||||
}
|
||||
}
|
||||
|
||||
private fun normalizeForMatching(input: String): String {
|
||||
// 去掉所有非字母或数字字符 (例如空格/括号/斜线等).
|
||||
// \p{L} 表示任何语言的字母字符, \p{N} 表示数字.
|
||||
return input.replace("[^\\p{L}\\p{N}]+".toRegex(), "")
|
||||
}
|
||||
|
||||
private fun getLocalizedString(context: Context, @StringRes resId: Int, locale: Locale): String {
|
||||
val config = Configuration(context.resources.configuration).apply { setLocale(locale) }
|
||||
val localizedContext = context.createConfigurationContext(config)
|
||||
return localizedContext.getString(resId)
|
||||
}
|
||||
|
||||
private fun isRegexSearch(query: String?): Boolean {
|
||||
if (query.isNullOrBlank()) return false
|
||||
return query.length > 2 && query.startsWith("/") && query.endsWith("/")
|
||||
}
|
||||
|
||||
private fun extractPatternFromQuery(query: String): String {
|
||||
// 假设已检查过 isRegexSearch() == true
|
||||
// 去掉最前和最后的斜杠
|
||||
return query.substring(1, query.length - 1)
|
||||
}
|
||||
|
||||
private fun compileRegexOrNull(pattern: String): Regex? {
|
||||
return runCatching { Regex(pattern, RegexOption.IGNORE_CASE) }.getOrNull()
|
||||
}
|
||||
|
||||
interface OnItemClickListener {
|
||||
@@ -233,13 +399,13 @@ abstract class ColorSelectBaseActivity : BaseActivity() {
|
||||
val libraryId = Pref.getInt(KEY_SELECTED_COLOR_LIBRARY_ID, SELECT_NONE)
|
||||
val libraryItemId = Pref.getInt(KEY_SELECTED_COLOR_LIBRARY_ITEM_ID, SELECT_NONE)
|
||||
when (libraryId) {
|
||||
COLOR_LIBRARY_CUSTOM_COLOR_ID -> {
|
||||
identifier = context.getString(R.string.mt_custom)
|
||||
COLOR_LIBRARY_ID_PALETTE -> {
|
||||
identifier = context.getString(R.string.color_library_identifier_palette)
|
||||
}
|
||||
SELECT_NONE -> {
|
||||
val legacyIndex = Pref.getInt(KEY_LEGACY_SELECTED_COLOR_INDEX, SELECT_NONE)
|
||||
when (legacyIndex) {
|
||||
customColorPosition -> identifier = context.getString(R.string.color_library_identifier_custom)
|
||||
customColorPosition -> identifier = context.getString(R.string.color_library_identifier_palette)
|
||||
SELECT_NONE, defaultColorPosition -> identifier = context.getString(R.string.color_library_identifier_default_colors)
|
||||
else -> {
|
||||
val calculatedIndex = legacyIndex - maxOf(customColorPosition, defaultColorPosition) - 1
|
||||
@@ -251,17 +417,43 @@ abstract class ColorSelectBaseActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> colorLibraries.find { it.id == libraryId }?.let { lib ->
|
||||
else -> presetColorLibraries.find { it.id == libraryId }?.let { lib: PresetColorLibrary ->
|
||||
identifier = when {
|
||||
lib.isUserDefined -> context.getString(R.string.color_library_identifier_custom)
|
||||
else -> lib.identifierRes?.let { resId -> context.getString(resId) }
|
||||
lib.isCreated -> {
|
||||
// lib.identifierString?.let { idStr ->
|
||||
// when {
|
||||
// idStr.estimateVisualWidth <= 10 -> idStr
|
||||
// else -> {
|
||||
// var newStr = idStr
|
||||
// while (newStr.estimateVisualWidth > 8) {
|
||||
// newStr = newStr.dropLast(1)
|
||||
// }
|
||||
// "$newStr..."
|
||||
// }
|
||||
// }
|
||||
// } ?: lib.titleString?.let { titleStr ->
|
||||
// when {
|
||||
// titleStr.estimateVisualWidth <= 10 -> titleStr
|
||||
// else -> {
|
||||
// var newStr = titleStr
|
||||
// while (newStr.estimateVisualWidth > 8) {
|
||||
// newStr = newStr.dropLast(1)
|
||||
// }
|
||||
// "$newStr..."
|
||||
// }
|
||||
// }
|
||||
// } ?: context.getString(R.string.color_library_identifier_created)
|
||||
context.getString(R.string.color_library_identifier_created)
|
||||
}
|
||||
else -> context.getString(lib.identifierRes)
|
||||
}
|
||||
if (libraryItemId != -1) {
|
||||
lib.colors.find { it.id == libraryItemId }?.let { item ->
|
||||
colorName = item.nameString
|
||||
?: item.nameRes.takeUnless {
|
||||
it == R.string.text_unknown
|
||||
}?.let { context.getString(it) }
|
||||
lib.colors.find { it.itemId == libraryItemId }?.let { item ->
|
||||
// colorName = item.nameString
|
||||
// ?: item.nameRes.takeUnless {
|
||||
// it == R.string.text_unknown
|
||||
// }?.let { context.getString(it) }
|
||||
colorName = context.getString(item.nameRes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.autojs.autojs.theme.app
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
@@ -20,10 +21,10 @@ import org.autojs.autojs.theme.ThemeChangeNotifier
|
||||
import org.autojs.autojs.theme.ThemeColor
|
||||
import org.autojs.autojs.theme.ThemeColorHelper
|
||||
import org.autojs.autojs.theme.ThemeColorManager
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.COLOR_LIBRARY_CUSTOM_COLOR_ID
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.COLOR_LIBRARY_DEFAULT_COLORS_ID
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.COLOR_LIBRARY_MATERIAL_COLORS_ID
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.colorLibraries
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.COLOR_LIBRARY_ID_PALETTE
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.COLOR_LIBRARY_ID_DEFAULT
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.COLOR_LIBRARY_ID_MATERIAL
|
||||
import org.autojs.autojs.theme.app.ColorLibrariesActivity.Companion.presetColorLibraries
|
||||
import org.autojs.autojs.theme.app.ColorSelectBaseActivity.Companion.KEY_LEGACY_SELECTED_COLOR_INDEX
|
||||
import org.autojs.autojs.theme.app.ColorSelectBaseActivity.Companion.KEY_SELECTED_COLOR_LIBRARY_ID
|
||||
import org.autojs.autojs.theme.app.ColorSelectBaseActivity.Companion.KEY_SELECTED_COLOR_LIBRARY_ITEM_ID
|
||||
@@ -99,22 +100,22 @@ class ColorSettingRecyclerView : ThemeColorRecyclerView {
|
||||
private fun savePrefsForLibraries() {
|
||||
when (mSelectedPosition) {
|
||||
0 -> {
|
||||
Pref.putInt(KEY_SELECTED_COLOR_LIBRARY_ID, COLOR_LIBRARY_CUSTOM_COLOR_ID)
|
||||
Pref.putInt(KEY_SELECTED_COLOR_LIBRARY_ID, COLOR_LIBRARY_ID_PALETTE)
|
||||
Pref.putInt(KEY_SELECTED_COLOR_LIBRARY_ITEM_ID, 0)
|
||||
}
|
||||
1 -> {
|
||||
Pref.putInt(KEY_SELECTED_COLOR_LIBRARY_ID, COLOR_LIBRARY_DEFAULT_COLORS_ID)
|
||||
colorLibraries.find { it.id == COLOR_LIBRARY_DEFAULT_COLORS_ID }!!.colors.find { colorItem ->
|
||||
Pref.putInt(KEY_SELECTED_COLOR_LIBRARY_ID, COLOR_LIBRARY_ID_DEFAULT)
|
||||
presetColorLibraries.find { it.isDefault }!!.colors.find { colorItem ->
|
||||
context.getColor(colorItem.colorRes) == context.getColor(R.color.theme_color_default)
|
||||
}?.let { Pref.putInt(KEY_SELECTED_COLOR_LIBRARY_ITEM_ID, it.id) }
|
||||
}?.let { Pref.putInt(KEY_SELECTED_COLOR_LIBRARY_ITEM_ID, it.itemId) }
|
||||
}
|
||||
else -> {
|
||||
selectedThemeColor?.colorPrimary?.let { c ->
|
||||
colorLibraries.find { it.id == COLOR_LIBRARY_MATERIAL_COLORS_ID }!!.colors.find { colorItem ->
|
||||
presetColorLibraries.find { it.isMaterial }!!.colors.find { colorItem ->
|
||||
context.getColor(colorItem.colorRes) == c
|
||||
}?.let {
|
||||
Pref.putInt(KEY_SELECTED_COLOR_LIBRARY_ID, COLOR_LIBRARY_MATERIAL_COLORS_ID)
|
||||
Pref.putInt(KEY_SELECTED_COLOR_LIBRARY_ITEM_ID, it.id)
|
||||
Pref.putInt(KEY_SELECTED_COLOR_LIBRARY_ID, COLOR_LIBRARY_ID_MATERIAL)
|
||||
Pref.putInt(KEY_SELECTED_COLOR_LIBRARY_ITEM_ID, it.itemId)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,8 +144,8 @@ class ColorSettingRecyclerView : ThemeColorRecyclerView {
|
||||
.setColor(customColor)
|
||||
.create()
|
||||
.setColorPickerDialogListener { dialogId: Int, color: Int ->
|
||||
val c = color or -0x1000000
|
||||
Pref.putInt(ColorSelectBaseActivity.KEY_CUSTOM_COLOR, c)
|
||||
val colorWithFullAlpha = color or Color.BLACK
|
||||
Pref.putInt(ColorSelectBaseActivity.KEY_CUSTOM_COLOR, colorWithFullAlpha)
|
||||
setSelectedPosition(customColorPosition)
|
||||
mOnItemClickListener?.onItemClick(v, customColorPosition)
|
||||
}
|
||||
|
||||
@@ -50,7 +50,5 @@ open class ThemeColorToolbar : Toolbar, ThemeColorMutable {
|
||||
navigationIcon?.let { navigationIcon = it.applyColorFilterWith(tintColor) }
|
||||
collapseIcon?.let { collapseIcon = it.applyColorFilterWith(tintColor) }
|
||||
overflowIcon?.let { overflowIcon = it.applyColorFilterWith(tintColor) }
|
||||
|
||||
popupTheme = if (ViewUtils.isLuminanceLight(currentThemeColor)) R.style.PopupMenuThemeLight else R.style.PopupMenuThemeDark
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ abstract class BaseActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
protected fun setUpStatusBarAppearanceLightByThemeColor() {
|
||||
ViewUtils.setStatusBarAppearanceLight(this, ThemeColorManager.isLuminanceDark())
|
||||
ThemeColorManager.setStatusBarAppearanceLight(this)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration
|
||||
import org.autojs.autojs.core.accessibility.NodeInfo
|
||||
import org.autojs.autojs.extension.NumberExtensions.string
|
||||
import org.autojs.autojs.extension.NumberExtensions.jsString
|
||||
import org.autojs.autojs.util.ClipboardUtils
|
||||
import org.autojs.autojs.util.ViewUtils
|
||||
import org.autojs.autojs6.R
|
||||
@@ -68,7 +68,7 @@ class NodeInfoView : RecyclerView {
|
||||
else -> {
|
||||
when (FIELDS[i].name) {
|
||||
"bounds" -> (value as? Rect)?.let { "[ ${it.left}, ${it.top}, ${it.right}, ${it.bottom} ]" } ?: value?.toString() ?: ""
|
||||
"center" -> (value as? Point)?.let { "[ ${it.x.string}, ${it.y.string} ]" } ?: value?.toString() ?: ""
|
||||
"center" -> (value as? Point)?.let { "[ ${it.x.jsString}, ${it.y.jsString} ]" } ?: value?.toString() ?: ""
|
||||
else -> value?.toString() ?: ""
|
||||
}
|
||||
}
|
||||
@@ -158,13 +158,13 @@ class NodeInfoView : RecyclerView {
|
||||
result = if (x == x.toLong().toDouble()) {
|
||||
result.replace("%X%", x.toLong().toString())
|
||||
} else {
|
||||
result.replace("%X%", "${floor(x).string}, ${ceil(x).string}")
|
||||
result.replace("%X%", "${floor(x).jsString}, ${ceil(x).jsString}")
|
||||
}
|
||||
|
||||
result = if (y == y.toLong().toDouble()) {
|
||||
result.replace("%Y%", y.toLong().toString())
|
||||
} else {
|
||||
result.replace("%Y%", "${floor(y).string}, ${ceil(y).string}")
|
||||
result.replace("%Y%", "${floor(y).jsString}, ${ceil(y).jsString}")
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
@@ -33,7 +33,7 @@ public class FloatingActionMenu extends FrameLayout implements View.OnClickListe
|
||||
private static final int[] ICONS = {
|
||||
R.drawable.ic_floating_action_menu_dir,
|
||||
R.drawable.ic_floating_action_menu_file,
|
||||
R.drawable.ic_import_thick,
|
||||
R.drawable.ic_file_download_white_cropped,
|
||||
R.drawable.ic_project_white};
|
||||
|
||||
private static final int[] LABELS = {
|
||||
|
||||
@@ -16,6 +16,7 @@ import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.drawerlayout.widget.DrawerLayout
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
@@ -280,7 +281,7 @@ class MainActivity : BaseActivity(), DelegateHost, HostActivity {
|
||||
private fun setUpToolbarColors() {
|
||||
mToolbar.setMenuIconsColorByThemeColorLuminance(this)
|
||||
mToolbar.setNavigationIconColorByThemeColorLuminance(this)
|
||||
mSearchViewItem?.initThemeColors()
|
||||
mSearchViewItem?.setColorsByThemeColorLuminance()
|
||||
}
|
||||
|
||||
private fun setUpTabLayoutColors() {
|
||||
@@ -416,7 +417,10 @@ class MainActivity : BaseActivity(), DelegateHost, HostActivity {
|
||||
return super.onMenuItemActionCollapse(item)
|
||||
}
|
||||
}.apply {
|
||||
setQueryCallback { query: String? -> submitQuery(query) }
|
||||
setQueryCallback(object : SearchView.OnQueryTextListener {
|
||||
override fun onQueryTextSubmit(query: String?) = true.also { submitQuery(query) }
|
||||
override fun onQueryTextChange(newText: String?) = true.also { submitQuery(newText) }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ class ExplorerFragment : ViewPagerFragment(0), OnFloatingActionButtonClickListen
|
||||
mExplorerView?.setFilter(null)
|
||||
return
|
||||
}
|
||||
mExplorerView?.setFilter { item: ExplorerItem -> item.name.contains(event.query) }
|
||||
mExplorerView?.setFilter { item: ExplorerItem -> item.name.contains(event.query, true) }
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
|
||||
@@ -4,12 +4,9 @@ import android.app.Activity;
|
||||
import android.app.SearchManager;
|
||||
import android.content.Context;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
import androidx.core.view.MenuItemCompat;
|
||||
import org.autojs.autojs.theme.ThemeColorManager;
|
||||
import org.autojs.autojs6.R;
|
||||
import org.autojs.autojs.util.ViewUtils;
|
||||
|
||||
/**
|
||||
* Created by Stardust on Oct 25, 2017.
|
||||
@@ -20,49 +17,33 @@ public class SearchViewItem implements MenuItemCompat.OnActionExpandListener, Se
|
||||
void summitQuery(String query);
|
||||
}
|
||||
|
||||
private QueryCallback mQueryCallback;
|
||||
private SearchView.OnQueryTextListener mQueryCallback;
|
||||
private final MenuItem mSearchMenuItem;
|
||||
private final SearchView mSearchView;
|
||||
private final Activity mActivity;
|
||||
private EditText mTextview;
|
||||
private ImageView mCloseButtonView;
|
||||
private ImageView mSearchGoButtonView;
|
||||
|
||||
public SearchViewItem(Activity activity, MenuItem searchMenuItem) {
|
||||
mActivity = activity;
|
||||
mSearchMenuItem = searchMenuItem;
|
||||
SearchManager searchManager = (SearchManager) activity.getSystemService(Context.SEARCH_SERVICE);
|
||||
SearchView searchView = (SearchView) searchMenuItem.getActionView();
|
||||
if (searchView == null) {
|
||||
mSearchView = (SearchView) searchMenuItem.getActionView();
|
||||
if (mSearchView == null) {
|
||||
return;
|
||||
}
|
||||
searchView.setSubmitButtonEnabled(true);
|
||||
searchView.setSearchableInfo(searchManager.getSearchableInfo(activity.getComponentName()));
|
||||
mTextview = searchView.findViewById(androidx.appcompat.R.id.search_src_text);
|
||||
mCloseButtonView = searchView.findViewById(androidx.appcompat.R.id.search_close_btn);
|
||||
mSearchGoButtonView = searchView.findViewById(androidx.appcompat.R.id.search_go_btn);
|
||||
initThemeColors();
|
||||
mSearchView.setSubmitButtonEnabled(false);
|
||||
mSearchView.setSearchableInfo(searchManager.getSearchableInfo(activity.getComponentName()));
|
||||
setColorsByThemeColorLuminance();
|
||||
MenuItemCompat.setOnActionExpandListener(searchMenuItem, this);
|
||||
searchView.setOnQueryTextListener(this);
|
||||
mSearchView.setOnQueryTextListener(this);
|
||||
}
|
||||
|
||||
public void initThemeColors() {
|
||||
boolean isThemeColorLuminanceLight = ThemeColorManager.isLuminanceLight();
|
||||
int fullColor = mActivity.getColor(isThemeColorLuminanceLight ? R.color.day_full : R.color.night_full);
|
||||
int hintColor = mActivity.getColor(isThemeColorLuminanceLight ? R.color.day : R.color.night);
|
||||
|
||||
if (mTextview != null) {
|
||||
mTextview.setTextColor(fullColor);
|
||||
mTextview.setHintTextColor(hintColor);
|
||||
}
|
||||
if (mCloseButtonView != null) {
|
||||
mCloseButtonView.setColorFilter(fullColor);
|
||||
}
|
||||
if (mSearchGoButtonView != null) {
|
||||
mSearchGoButtonView.setColorFilter(fullColor);
|
||||
public void setColorsByThemeColorLuminance() {
|
||||
if (mSearchView != null) {
|
||||
ViewUtils.setSearchViewColorsByThemeColorLuminance(mActivity, mSearchView);
|
||||
}
|
||||
}
|
||||
|
||||
public void setQueryCallback(QueryCallback queryCallback) {
|
||||
public void setQueryCallback(SearchView.OnQueryTextListener queryCallback) {
|
||||
mQueryCallback = queryCallback;
|
||||
}
|
||||
|
||||
@@ -80,21 +61,23 @@ public class SearchViewItem implements MenuItemCompat.OnActionExpandListener, Se
|
||||
if (mQueryCallback == null) {
|
||||
return true;
|
||||
}
|
||||
mQueryCallback.summitQuery(null);
|
||||
mQueryCallback.onQueryTextSubmit(null);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
if (mQueryCallback == null) {
|
||||
return true;
|
||||
if (mQueryCallback != null) {
|
||||
mQueryCallback.onQueryTextSubmit(query);
|
||||
}
|
||||
mQueryCallback.summitQuery(query);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
if (mQueryCallback != null) {
|
||||
mQueryCallback.onQueryTextChange(newText);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import androidx.core.graphics.ColorUtils
|
||||
import org.autojs.autojs.app.GlobalAppContext
|
||||
import org.autojs.autojs.core.image.ColorTable
|
||||
import org.autojs.autojs.theme.ThemeColor
|
||||
import kotlin.math.pow
|
||||
import kotlin.math.roundToInt
|
||||
import kotlin.text.RegexOption.IGNORE_CASE
|
||||
|
||||
@@ -57,7 +56,7 @@ object ColorUtils {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun toInt(num: Long) = toInt(toHex(num))
|
||||
fun toInt(num: Number) = toInt(toHex(num))
|
||||
|
||||
@JvmStatic
|
||||
fun toInt(themeColor: ThemeColor) = toInt(toHex(themeColor))
|
||||
@@ -72,17 +71,17 @@ object ColorUtils {
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun toHex(num: Long, alpha: String = "auto"): String {
|
||||
fun toHex(num: Number, alpha: String = "auto"): String {
|
||||
return toHex(toString(toJavaIntegerRange(num)), alpha)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun toHex(num: Long, hasAlpha: Boolean): String {
|
||||
fun toHex(num: Number, hasAlpha: Boolean): String {
|
||||
return toHex(toString(toJavaIntegerRange(num)), hasAlpha)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun toHex(num: Long, resultLength: Int): String {
|
||||
fun toHex(num: Number, resultLength: Int): String {
|
||||
return toHex(toString(toJavaIntegerRange(num)), resultLength)
|
||||
}
|
||||
|
||||
@@ -163,7 +162,7 @@ object ColorUtils {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun toFullHex(num: Long) = toHex(num, 8)
|
||||
fun toFullHex(num: Number) = toHex(num, 8)
|
||||
|
||||
@JvmStatic
|
||||
fun toFullHex(themeColor: ThemeColor) = toHex(themeColor, 8)
|
||||
@@ -189,14 +188,16 @@ object ColorUtils {
|
||||
else -> toInt(color)
|
||||
}
|
||||
|
||||
private fun toJavaIntegerRange(x: Long): Int {
|
||||
val t = 2f.pow(32).toLong()
|
||||
val min = (-2f).pow(31).toLong()
|
||||
val max = 2f.pow(31 - 1).toLong()
|
||||
var tmp = x
|
||||
while (tmp < min) tmp += t
|
||||
while (tmp > max) tmp -= t
|
||||
return tmp.toInt()
|
||||
private fun toJavaIntegerRange(x: Number): Int {
|
||||
// @Commented by SuperMonster003 on Apr 1, 2025.
|
||||
// # val t = 2f.pow(32).toLong()
|
||||
// # val min = (-2f).pow(31).toLong()
|
||||
// # val max = 2f.pow(31 - 1).toLong()
|
||||
// # var tmp = x.toLong()
|
||||
// # while (tmp < min) tmp += t
|
||||
// # while (tmp > max) tmp -= t
|
||||
// # return tmp.toInt()
|
||||
return x.toLong().toInt()
|
||||
}
|
||||
|
||||
fun toColorStateList(color: String) = ColorStateList.valueOf(toInt(color))
|
||||
|
||||
@@ -20,23 +20,26 @@ import android.os.Looper
|
||||
import android.util.DisplayMetrics
|
||||
import android.util.TypedValue
|
||||
import android.view.Gravity
|
||||
import android.view.Menu
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.ViewTreeObserver
|
||||
import android.view.Window
|
||||
import android.view.WindowInsets
|
||||
import android.view.WindowManager
|
||||
import android.widget.EditText
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.IdRes
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.WindowInsetsControllerCompat
|
||||
import androidx.core.view.forEach
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import org.autojs.autojs.app.GlobalAppContext
|
||||
@@ -44,8 +47,6 @@ import org.autojs.autojs.core.pref.Pref
|
||||
import org.autojs.autojs.theme.ThemeColorManager
|
||||
import org.autojs.autojs.util.StringUtils.key
|
||||
import org.autojs.autojs6.R
|
||||
import org.autojs.autojs6.R.color.day
|
||||
import org.autojs.autojs6.R.color.night
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
/**
|
||||
@@ -186,12 +187,12 @@ object ViewUtils {
|
||||
|
||||
@JvmStatic
|
||||
fun getDayOrNightColorByLuminance(context: Context, color: Int): Int {
|
||||
return context.getColor(if (isLuminanceLight(color)) day else night)
|
||||
return context.getColor(if (isLuminanceLight(color)) R.color.day else R.color.night)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getDayOrNightColorResByLuminance(color: Int): Int {
|
||||
return if (isLuminanceLight(color)) day else night
|
||||
return if (isLuminanceLight(color)) R.color.day else R.color.night
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@@ -408,13 +409,19 @@ object ViewUtils {
|
||||
|
||||
fun Toolbar.setMenuIconsColorByColorLuminance(context: Context, aimColor: Int) {
|
||||
val color = getDayOrNightColorByLuminance(context, aimColor)
|
||||
this.menu.forEach { menu ->
|
||||
menu.icon?.let { ic -> menu.icon = ic.applyColorFilterWith(color) }
|
||||
}
|
||||
this.menu.setItemsColor(color)
|
||||
this.collapseIcon?.let { this.collapseIcon = it.applyColorFilterWith(color) }
|
||||
this.overflowIcon?.let { this.overflowIcon = it.applyColorFilterWith(color) }
|
||||
}
|
||||
|
||||
fun Menu.setItemsColor(color: Int) {
|
||||
for (i in 0 until size()) {
|
||||
val menuItem = getItem(i)
|
||||
menuItem.icon = menuItem.icon?.applyColorFilterWith(color)
|
||||
menuItem.subMenu?.setItemsColor(color)
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun setToolbarMenuIconsColorByColorLuminance(context: Context, toolbar: Toolbar, aimColor: Int) {
|
||||
toolbar.setMenuIconsColorByColorLuminance(context, aimColor)
|
||||
@@ -496,6 +503,41 @@ object ViewUtils {
|
||||
toolbar.setTitlesTextColorByColorLuminance(context, aimColor)
|
||||
}
|
||||
|
||||
fun SearchView.setColorsByColorLuminance(context: Context, aimColor: Int) {
|
||||
val isAimColorLight = isLuminanceLight(aimColor)
|
||||
val fullColor = context.getColor(if (isAimColorLight) R.color.day_full else R.color.night_full)
|
||||
val hintColor = context.getColor(if (isAimColorLight) R.color.day_alpha_70 else R.color.night_alpha_70)
|
||||
|
||||
findViewById<EditText?>(androidx.appcompat.R.id.search_src_text).apply {
|
||||
setTextColor(fullColor)
|
||||
setHintTextColor(hintColor)
|
||||
setLinkTextColor(fullColor)
|
||||
}
|
||||
findViewById<ImageView?>(androidx.appcompat.R.id.search_close_btn)?.apply {
|
||||
setColorFilter(fullColor)
|
||||
}
|
||||
findViewById<ImageView?>(androidx.appcompat.R.id.search_mag_icon)?.apply {
|
||||
setColorFilter(fullColor)
|
||||
}
|
||||
findViewById<ImageView?>(androidx.appcompat.R.id.search_go_btn)?.apply {
|
||||
setColorFilter(fullColor)
|
||||
}
|
||||
}
|
||||
|
||||
fun SearchView.setColorsByThemeColorLuminance(context: Context) {
|
||||
this.setColorsByColorLuminance(context, ThemeColorManager.colorPrimary)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun setSearchViewColorsByColorLuminance(context: Context, searchView: SearchView, aimColor: Int) {
|
||||
searchView.setColorsByColorLuminance(context, aimColor)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun setSearchViewColorsByThemeColorLuminance(context: Context, searchView: SearchView) {
|
||||
setSearchViewColorsByColorLuminance(context, searchView, ThemeColorManager.colorPrimary)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun showToast(context: Context, stringRes: Int) = showToast(context, stringRes, false)
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 13 KiB |
BIN
app/src/main/res/drawable/ic_color_library_cloned.png
Normal file
|
After Width: | Height: | Size: 32 KiB |
BIN
app/src/main/res/drawable/ic_color_library_created.png
Normal file
|
After Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 6.6 KiB |
BIN
app/src/main/res/drawable/ic_color_library_imported.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
app/src/main/res/drawable/ic_color_library_intelligent.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
@@ -15,12 +15,12 @@
|
||||
|
||||
<!-- 第一个路径 -->
|
||||
<path
|
||||
android:fillColor="#231F20"
|
||||
android:fillColor="#000000"
|
||||
android:pathData="M449.3,79.9C397.7,28.7,327.8,0.5,255.1,1.5C114.6,1.2,0.4,114.8,0,255.4c-0.3,140.5,113.3,254.8,253.8,255.1c29.9,0.5,56.4-19.3,64.4-48.1c5-20.5-0.4-42.3-14.5-58c-4.6-5.3-4.1-13.3,1.2-18c2.3-2,5.2-3.1,8.3-3.2h42c82,0.4,150.4-62.6,156.8-144.3C513.8,179.6,491.1,122,449.3,79.9z M356.1,332.4h-42c-35-0.2-63.5,28-63.7,63c-0.1,15.7,5.7,30.9,16.1,42.6c3.2,3.3,4.4,8.1,3.1,12.5c-1.3,5.3-7.1,8.6-15,9.2c-112.4-1.4-202.4-93.8-201-206.2c0.1-8.6,0.8-17.1,2-25.6c15-99.3,99.4-173.4,199.8-175.3h2c58.1-0.8,114.1,22,155.2,63.1c32.1,32.1,49.6,76,48.3,121.4C455.5,290.8,410.3,332,356.1,332.4z" />
|
||||
|
||||
<!-- 圆:使用路径数据来绘制圆形 -->
|
||||
<path
|
||||
android:fillColor="#231F20"
|
||||
android:fillColor="#000000"
|
||||
android:pathData="M257.4,116
|
||||
m-38.2,0
|
||||
a38.2,38.2 0 1,0 76.4,0
|
||||
@@ -28,17 +28,17 @@
|
||||
|
||||
<!-- 第二个路径 -->
|
||||
<path
|
||||
android:fillColor="#231F20"
|
||||
android:fillColor="#000000"
|
||||
android:pathData="M340.1,133.9c-18.3,10.5-24.5,33.9-14,52.1c10.5,18.3,33.9,24.5,52.2,14c18.2-10.5,24.5-33.9,14-52.1C381.8,129.6,358.4,123.3,340.1,133.9z" />
|
||||
|
||||
<!-- 第三个路径 -->
|
||||
<path
|
||||
android:fillColor="#231F20"
|
||||
android:fillColor="#000000"
|
||||
android:pathData="M174.7,133.9c-18.3-10.5-41.6-4.2-52.1,14s-4.2,41.6,14,52.1c18.2,10.5,41.6,4.3,52.1-14C199.2,167.8,193,144.4,174.7,133.9z" />
|
||||
|
||||
<!-- 第四个路径 -->
|
||||
<path
|
||||
android:fillColor="#231F20"
|
||||
android:fillColor="#000000"
|
||||
android:pathData="M108.8,237.2c-17.5,11.8-22.1,35.5-10.3,53c11.8,17.5,35.5,22.1,53,10.3c17.5-11.8,22.1-35.5,10.3-53l-0.1-0.1c-11.7-17.4-35.2-22.1-52.6-10.4" />
|
||||
|
||||
</group>
|
||||
|
||||
BIN
app/src/main/res/drawable/ic_customize.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
app/src/main/res/drawable/ic_file_download_black.png
Normal file
|
After Width: | Height: | Size: 7.3 KiB |
BIN
app/src/main/res/drawable/ic_file_download_white.png
Normal file
|
After Width: | Height: | Size: 8.7 KiB |
BIN
app/src/main/res/drawable/ic_file_download_white_cropped.png
Normal file
|
After Width: | Height: | Size: 7.0 KiB |
BIN
app/src/main/res/drawable/ic_filter.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
app/src/main/res/drawable/ic_import_from_top.png
Normal file
|
After Width: | Height: | Size: 6.3 KiB |
BIN
app/src/main/res/drawable/ic_import_from_top_thick.png
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
BIN
app/src/main/res/drawable/ic_regex.png
Normal file
|
After Width: | Height: | Size: 9.3 KiB |
@@ -17,7 +17,7 @@
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginTop="1dp"
|
||||
android:src="@drawable/ic_color_library_custom" />
|
||||
android:src="@drawable/ic_color_library_created" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
|
||||
@@ -7,19 +7,41 @@
|
||||
android:id="@+id/action_color_palette"
|
||||
android:title="@string/text_color_palette"
|
||||
android:icon="@drawable/ic_color_palette_vector"
|
||||
app:showAsAction="ifRoom" />
|
||||
app:showAsAction="always" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_search_color"
|
||||
android:title="@string/text_search_color"
|
||||
android:icon="@drawable/ic_search_black_48dp"
|
||||
app:showAsAction="ifRoom" />
|
||||
android:imeOptions="actionSearch"
|
||||
android:inputType="text"
|
||||
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
||||
app:showAsAction="always|collapseActionView" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_new_color_library"
|
||||
android:title="@string/text_new_color_library"
|
||||
android:icon="@drawable/ic_add_box_black_48dp"
|
||||
app:showAsAction="never" />
|
||||
android:id="@+id/action_add_color_library"
|
||||
android:title="@string/text_add_color_library">
|
||||
|
||||
<menu>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_new_color_library"
|
||||
android:title="@string/text_new_color_library"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_import_color_library"
|
||||
android:title="@string/text_import_color_library"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_clone_color_library"
|
||||
android:title="@string/text_clone_color_library"
|
||||
app:showAsAction="never" />
|
||||
|
||||
</menu>
|
||||
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_locate_current_theme_color"
|
||||
@@ -27,10 +49,17 @@
|
||||
android:icon="@drawable/ic_locate"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_toggle_color_select_layout"
|
||||
android:title="@string/text_switch_to_legacy_layout"
|
||||
android:icon="@drawable/ic_swap_horiz_black_48dp"
|
||||
app:showAsAction="never" />
|
||||
<item android:title="@string/text_more">
|
||||
|
||||
<menu>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_toggle_color_select_layout"
|
||||
android:title="@string/text_switch_to_legacy_layout"
|
||||
app:showAsAction="never" />
|
||||
|
||||
</menu>
|
||||
|
||||
</item>
|
||||
|
||||
</menu>
|
||||
@@ -7,7 +7,10 @@
|
||||
android:id="@+id/action_search_color"
|
||||
android:title="@string/text_search_color"
|
||||
android:icon="@drawable/ic_search_black_48dp"
|
||||
app:showAsAction="ifRoom" />
|
||||
android:imeOptions="actionSearch"
|
||||
android:inputType="text"
|
||||
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
||||
app:showAsAction="always|collapseActionView" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_locate_current_theme_color"
|
||||
|
||||
@@ -923,5 +923,20 @@
|
||||
<string name="color_library_identifier_default_colors">Default</string>
|
||||
<string name="color_library_identifier_custom">Custom</string>
|
||||
<string name="dialog_title_color_palette">Color palette</string>
|
||||
<string name="text_add_color_library">Add a color library</string>
|
||||
<string name="text_import_color_library">Import a color library</string>
|
||||
<string name="text_new_intelligent_color_library">New intelligent color library</string>
|
||||
<string name="text_clone_color_library">Clone a color library</string>
|
||||
<string name="color_library_intelligent_colors">Intelligent color library</string>
|
||||
<string name="color_library_title_intelligent_colors">Intelligent colors</string>
|
||||
<string name="color_library_identifier_intelligent_colors">Intell.</string>
|
||||
<string name="color_library_identifier_palette">Palette</string>
|
||||
<string name="color_library_identifier_created">Created</string>
|
||||
<string name="text_search_all_colors">Search all colors</string>
|
||||
<string name="dialog_button_open_color_palette">Palette</string>
|
||||
<string name="content_current_theme_color_configured_by_palette">Current theme color %1$s is configured by the color palette</string>
|
||||
<string name="text_failed_to_locate">Failed to locate</string>
|
||||
<string name="content_failed_to_locate_library_for_theme_color">Failed to locate the color library for the theme color</string>
|
||||
<string name="content_failed_to_determine_index_of_theme_color_item">Failed to determine the index of the theme color item</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -919,5 +919,20 @@
|
||||
<string name="color_library_identifier_default_colors">Default</string>
|
||||
<string name="color_library_identifier_custom">Custom</string>
|
||||
<string name="dialog_title_color_palette">Color palette</string>
|
||||
<string name="text_add_color_library">Add a color library</string>
|
||||
<string name="text_import_color_library">Import a color library</string>
|
||||
<string name="text_new_intelligent_color_library">New intelligent color library</string>
|
||||
<string name="text_clone_color_library">Clone a color library</string>
|
||||
<string name="color_library_intelligent_colors">Intelligent color library</string>
|
||||
<string name="color_library_title_intelligent_colors">Intelligent colors</string>
|
||||
<string name="color_library_identifier_intelligent_colors">Intell.</string>
|
||||
<string name="color_library_identifier_palette">Palette</string>
|
||||
<string name="color_library_identifier_created">Created</string>
|
||||
<string name="text_search_all_colors">Search all colors</string>
|
||||
<string name="dialog_button_open_color_palette">Palette</string>
|
||||
<string name="content_current_theme_color_configured_by_palette">Current theme color %1$s is configured by the color palette</string>
|
||||
<string name="text_failed_to_locate">Failed to locate</string>
|
||||
<string name="content_failed_to_locate_library_for_theme_color">Failed to locate the color library for the theme color</string>
|
||||
<string name="content_failed_to_determine_index_of_theme_color_item">Failed to determine the index of the theme color item</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -922,5 +922,20 @@
|
||||
<string name="color_library_identifier_default_colors">Default</string>
|
||||
<string name="color_library_identifier_custom">Custom</string>
|
||||
<string name="dialog_title_color_palette">Color palette</string>
|
||||
<string name="text_add_color_library">Add a color library</string>
|
||||
<string name="text_import_color_library">Import a color library</string>
|
||||
<string name="text_new_intelligent_color_library">New intelligent color library</string>
|
||||
<string name="text_clone_color_library">Clone a color library</string>
|
||||
<string name="color_library_intelligent_colors">Intelligent color library</string>
|
||||
<string name="color_library_title_intelligent_colors">Intelligent colors</string>
|
||||
<string name="color_library_identifier_intelligent_colors">Intell.</string>
|
||||
<string name="color_library_identifier_palette">Palette</string>
|
||||
<string name="color_library_identifier_created">Created</string>
|
||||
<string name="text_search_all_colors">Search all colors</string>
|
||||
<string name="dialog_button_open_color_palette">Palette</string>
|
||||
<string name="content_current_theme_color_configured_by_palette">Current theme color %1$s is configured by the color palette</string>
|
||||
<string name="text_failed_to_locate">Failed to locate</string>
|
||||
<string name="content_failed_to_locate_library_for_theme_color">Failed to locate the color library for the theme color</string>
|
||||
<string name="content_failed_to_determine_index_of_theme_color_item">Failed to determine the index of the theme color item</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -922,5 +922,20 @@
|
||||
<string name="color_library_identifier_default_colors">Default</string>
|
||||
<string name="color_library_identifier_custom">Custom</string>
|
||||
<string name="dialog_title_color_palette">Color palette</string>
|
||||
<string name="text_add_color_library">Add a color library</string>
|
||||
<string name="text_import_color_library">Import a color library</string>
|
||||
<string name="text_new_intelligent_color_library">New intelligent color library</string>
|
||||
<string name="text_clone_color_library">Clone a color library</string>
|
||||
<string name="color_library_intelligent_colors">Intelligent color library</string>
|
||||
<string name="color_library_title_intelligent_colors">Intelligent colors</string>
|
||||
<string name="color_library_identifier_intelligent_colors">Intell.</string>
|
||||
<string name="color_library_identifier_palette">Palette</string>
|
||||
<string name="color_library_identifier_created">Created</string>
|
||||
<string name="text_search_all_colors">Search all colors</string>
|
||||
<string name="dialog_button_open_color_palette">Palette</string>
|
||||
<string name="content_current_theme_color_configured_by_palette">Current theme color %1$s is configured by the color palette</string>
|
||||
<string name="text_failed_to_locate">Failed to locate</string>
|
||||
<string name="content_failed_to_locate_library_for_theme_color">Failed to locate the color library for the theme color</string>
|
||||
<string name="content_failed_to_determine_index_of_theme_color_item">Failed to determine the index of the theme color item</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -922,5 +922,20 @@
|
||||
<string name="color_library_identifier_default_colors">Default</string>
|
||||
<string name="color_library_identifier_custom">Custom</string>
|
||||
<string name="dialog_title_color_palette">Color palette</string>
|
||||
<string name="text_add_color_library">Add a color library</string>
|
||||
<string name="text_import_color_library">Import a color library</string>
|
||||
<string name="text_new_intelligent_color_library">New intelligent color library</string>
|
||||
<string name="text_clone_color_library">Clone a color library</string>
|
||||
<string name="color_library_intelligent_colors">Intelligent color library</string>
|
||||
<string name="color_library_title_intelligent_colors">Intelligent colors</string>
|
||||
<string name="color_library_identifier_intelligent_colors">Intell.</string>
|
||||
<string name="color_library_identifier_palette">Palette</string>
|
||||
<string name="color_library_identifier_created">Created</string>
|
||||
<string name="text_search_all_colors">Search all colors</string>
|
||||
<string name="dialog_button_open_color_palette">Palette</string>
|
||||
<string name="content_current_theme_color_configured_by_palette">Current theme color %1$s is configured by the color palette</string>
|
||||
<string name="text_failed_to_locate">Failed to locate</string>
|
||||
<string name="content_failed_to_locate_library_for_theme_color">Failed to locate the color library for the theme color</string>
|
||||
<string name="content_failed_to_determine_index_of_theme_color_item">Failed to determine the index of the theme color item</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -923,5 +923,20 @@
|
||||
<string name="color_library_identifier_default_colors">Default</string>
|
||||
<string name="color_library_identifier_custom">Custom</string>
|
||||
<string name="dialog_title_color_palette">Color palette</string>
|
||||
<string name="text_add_color_library">Add a color library</string>
|
||||
<string name="text_import_color_library">Import a color library</string>
|
||||
<string name="text_new_intelligent_color_library">New intelligent color library</string>
|
||||
<string name="text_clone_color_library">Clone a color library</string>
|
||||
<string name="color_library_intelligent_colors">Intelligent color library</string>
|
||||
<string name="color_library_title_intelligent_colors">Intelligent colors</string>
|
||||
<string name="color_library_identifier_intelligent_colors">Intell.</string>
|
||||
<string name="color_library_identifier_palette">Palette</string>
|
||||
<string name="color_library_identifier_created">Created</string>
|
||||
<string name="text_search_all_colors">Search all colors</string>
|
||||
<string name="dialog_button_open_color_palette">Palette</string>
|
||||
<string name="content_current_theme_color_configured_by_palette">Current theme color %1$s is configured by the color palette</string>
|
||||
<string name="text_failed_to_locate">Failed to locate</string>
|
||||
<string name="content_failed_to_locate_library_for_theme_color">Failed to locate the color library for the theme color</string>
|
||||
<string name="content_failed_to_determine_index_of_theme_color_item">Failed to determine the index of the theme color item</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -922,5 +922,20 @@
|
||||
<string name="color_library_identifier_default_colors">Default</string>
|
||||
<string name="color_library_identifier_custom">Custom</string>
|
||||
<string name="dialog_title_color_palette">Color palette</string>
|
||||
<string name="text_add_color_library">Add a color library</string>
|
||||
<string name="text_import_color_library">Import a color library</string>
|
||||
<string name="text_new_intelligent_color_library">New intelligent color library</string>
|
||||
<string name="text_clone_color_library">Clone a color library</string>
|
||||
<string name="color_library_intelligent_colors">Intelligent color library</string>
|
||||
<string name="color_library_title_intelligent_colors">Intelligent colors</string>
|
||||
<string name="color_library_identifier_intelligent_colors">Intell.</string>
|
||||
<string name="color_library_identifier_palette">Palette</string>
|
||||
<string name="color_library_identifier_created">Created</string>
|
||||
<string name="text_search_all_colors">Search all colors</string>
|
||||
<string name="dialog_button_open_color_palette">Palette</string>
|
||||
<string name="content_current_theme_color_configured_by_palette">Current theme color %1$s is configured by the color palette</string>
|
||||
<string name="text_failed_to_locate">Failed to locate</string>
|
||||
<string name="content_failed_to_locate_library_for_theme_color">Failed to locate the color library for the theme color</string>
|
||||
<string name="content_failed_to_determine_index_of_theme_color_item">Failed to determine the index of the theme color item</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -921,5 +921,20 @@
|
||||
<string name="color_library_identifier_default_colors">Default</string>
|
||||
<string name="color_library_identifier_custom">Custom</string>
|
||||
<string name="dialog_title_color_palette">Color palette</string>
|
||||
<string name="text_add_color_library">Add a color library</string>
|
||||
<string name="text_import_color_library">Import a color library</string>
|
||||
<string name="text_new_intelligent_color_library">New intelligent color library</string>
|
||||
<string name="text_clone_color_library">Clone a color library</string>
|
||||
<string name="color_library_intelligent_colors">Intelligent color library</string>
|
||||
<string name="color_library_title_intelligent_colors">Intelligent colors</string>
|
||||
<string name="color_library_identifier_intelligent_colors">Intell.</string>
|
||||
<string name="color_library_identifier_palette">Palette</string>
|
||||
<string name="color_library_identifier_created">Created</string>
|
||||
<string name="text_search_all_colors">Search all colors</string>
|
||||
<string name="dialog_button_open_color_palette">Palette</string>
|
||||
<string name="content_current_theme_color_configured_by_palette">Current theme color %1$s is configured by the color palette</string>
|
||||
<string name="text_failed_to_locate">Failed to locate</string>
|
||||
<string name="content_failed_to_locate_library_for_theme_color">Failed to locate the color library for the theme color</string>
|
||||
<string name="content_failed_to_determine_index_of_theme_color_item">Failed to determine the index of the theme color item</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -921,5 +921,20 @@
|
||||
<string name="color_library_identifier_default_colors">Default</string>
|
||||
<string name="color_library_identifier_custom">Custom</string>
|
||||
<string name="dialog_title_color_palette">Color palette</string>
|
||||
<string name="text_add_color_library">Add a color library</string>
|
||||
<string name="text_import_color_library">Import a color library</string>
|
||||
<string name="text_new_intelligent_color_library">New intelligent color library</string>
|
||||
<string name="text_clone_color_library">Clone a color library</string>
|
||||
<string name="color_library_intelligent_colors">Intelligent color library</string>
|
||||
<string name="color_library_title_intelligent_colors">Intelligent colors</string>
|
||||
<string name="color_library_identifier_intelligent_colors">Intell.</string>
|
||||
<string name="color_library_identifier_palette">Palette</string>
|
||||
<string name="color_library_identifier_created">Created</string>
|
||||
<string name="text_search_all_colors">Search all colors</string>
|
||||
<string name="dialog_button_open_color_palette">Palette</string>
|
||||
<string name="content_current_theme_color_configured_by_palette">Current theme color %1$s is configured by the color palette</string>
|
||||
<string name="text_failed_to_locate">Failed to locate</string>
|
||||
<string name="content_failed_to_locate_library_for_theme_color">Failed to locate the color library for the theme color</string>
|
||||
<string name="content_failed_to_determine_index_of_theme_color_item">Failed to determine the index of the theme color item</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -921,5 +921,20 @@
|
||||
<string name="color_library_identifier_default_colors">默认</string>
|
||||
<string name="color_library_identifier_custom">自定义</string>
|
||||
<string name="dialog_title_color_palette">调色盘</string>
|
||||
<string name="text_add_color_library">添加颜色库</string>
|
||||
<string name="text_import_color_library">导入颜色库</string>
|
||||
<string name="text_new_intelligent_color_library">新建智能颜色库</string>
|
||||
<string name="text_clone_color_library">克隆颜色库</string>
|
||||
<string name="color_library_intelligent_colors">智能颜色库</string>
|
||||
<string name="color_library_title_intelligent_colors">智能颜色</string>
|
||||
<string name="color_library_identifier_intelligent_colors">智能</string>
|
||||
<string name="color_library_identifier_palette">调色盘</string>
|
||||
<string name="color_library_identifier_created">自建</string>
|
||||
<string name="text_search_all_colors">搜索全部颜色</string>
|
||||
<string name="dialog_button_open_color_palette">打开调色盘</string>
|
||||
<string name="content_current_theme_color_configured_by_palette">当前主题色 %1$s 由调色盘配置</string>
|
||||
<string name="text_failed_to_locate">定位失败</string>
|
||||
<string name="content_failed_to_locate_library_for_theme_color">无法定位主题色所在颜色库</string>
|
||||
<string name="content_failed_to_determine_index_of_theme_color_item">无法确定主题色条目的索引值</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -2,8 +2,16 @@
|
||||
<resources>
|
||||
|
||||
<color name="day">#DE212121</color>
|
||||
<color name="day_alpha_70">#B3212121</color>
|
||||
<color name="day_alpha_60">#9A212121</color>
|
||||
<color name="day_alpha_30">#4D212121</color>
|
||||
<color name="day_alpha_20">#33212121</color>
|
||||
<color name="day_full">@color/md_gray_900</color>
|
||||
<color name="night">#DEFBFBFB</color>
|
||||
<color name="night_alpha_70">#B3FBFBFB</color>
|
||||
<color name="night_alpha_60">#9AFBFBFB</color>
|
||||
<color name="night_alpha_30">#4DFBFBFB</color>
|
||||
<color name="night_alpha_20">#33FBFBFB</color>
|
||||
<color name="night_full">#FBFBFB</color>
|
||||
<color name="dawn">#DE252525</color>
|
||||
<color name="dawn_full">#252525</color>
|
||||
|
||||
@@ -1163,5 +1163,20 @@
|
||||
<string name="color_library_identifier_web_colors" translatable="false">WEB</string>
|
||||
<string name="color_library_identifier_custom">Custom</string>
|
||||
<string name="dialog_title_color_palette">Color palette</string>
|
||||
<string name="text_add_color_library">Add a color library</string>
|
||||
<string name="text_import_color_library">Import a color library</string>
|
||||
<string name="text_new_intelligent_color_library">New intelligent color library</string>
|
||||
<string name="text_clone_color_library">Clone a color library</string>
|
||||
<string name="color_library_intelligent_colors">Intelligent color library</string>
|
||||
<string name="color_library_title_intelligent_colors">Intelligent colors</string>
|
||||
<string name="color_library_identifier_intelligent_colors">Intell.</string>
|
||||
<string name="color_library_identifier_palette">Palette</string>
|
||||
<string name="color_library_identifier_created">Created</string>
|
||||
<string name="text_search_all_colors">Search all colors</string>
|
||||
<string name="dialog_button_open_color_palette">Palette</string>
|
||||
<string name="content_current_theme_color_configured_by_palette">Current theme color %1$s is configured by the color palette</string>
|
||||
<string name="text_failed_to_locate">Failed to locate</string>
|
||||
<string name="content_failed_to_locate_library_for_theme_color">Failed to locate the color library for the theme color</string>
|
||||
<string name="content_failed_to_determine_index_of_theme_color_item">Failed to determine the index of the theme color item</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -121,7 +121,8 @@
|
||||
</style>
|
||||
|
||||
<style name="MtAppTheme.PopupOverlay" parent="OverflowMenu">
|
||||
<item name="android:textColorPrimary">@color/day_full</item>
|
||||
<item name="android:textColor">@color/day_night_full</item>
|
||||
<item name="android:tint">@color/day_night_full</item>
|
||||
</style>
|
||||
|
||||
<style name="ConsoleTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
|
||||