From 99dbd134cb32af6e8d48bed9d772b71d66e289ef Mon Sep 17 00:00:00 2001 From: LeanBitLab Date: Fri, 4 Dec 2026 17:53:03 +0530 Subject: [PATCH] fix(toolbar): same icon color for toggle keys that are off Keys like incognito or selection mode were drawn in a different shade while off, which looked like a disabled or odd icon. "On" is already shown by the highlighted background. --- .../helium314/keyboard/latin/common/Colors.kt | 27 +++---------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/helium314/keyboard/latin/common/Colors.kt b/app/src/main/java/helium314/keyboard/latin/common/Colors.kt index 0c8e2db48..9b660be9d 100644 --- a/app/src/main/java/helium314/keyboard/latin/common/Colors.kt +++ b/app/src/main/java/helium314/keyboard/latin/common/Colors.kt @@ -203,11 +203,8 @@ class DynamicColors(context: Context, override val themeStyle: String, override private val spaceBarStateList: ColorStateList private val adjustedBackgroundStateList: ColorStateList private val stripBackgroundList: ColorStateList - private val toolbarKeyStateList = activatedStateList( - keyText, - if (isBrightColor(keyText)) darken(darken(keyText)) - else brighten(brighten(keyText)) - ) + // one color also for toggle keys that are off, "on" is shown by their background + private val toolbarKeyStateList = ColorStateList.valueOf(keyText) /** darkened variant of [accent] because the accent color is always light for dynamic colors */ private val adjustedAccent: Int = darken(accent) @@ -492,11 +489,7 @@ class DefaultColors ( private val spaceBarStateList: ColorStateList private val adjustedBackgroundStateList: ColorStateList private val stripBackgroundList: ColorStateList - private val toolbarKeyStateList = activatedStateList( - effectiveToolbarKeyColor, - if (isBrightColor(effectiveToolbarKeyColor)) darken(darken(effectiveToolbarKeyColor)) - else brighten(brighten(effectiveToolbarKeyColor)) - ) + private val toolbarKeyStateList = ColorStateList.valueOf(effectiveToolbarKeyColor) private var backgroundSetupDone = false init { @@ -672,14 +665,7 @@ class AllColors(private val colorMap: EnumMap, override val them private val stateListMap = EnumMap(ColorType::class.java) private var backgroundSetupDone = false private val colorFilters = hashMapOf() - private val toolbarKeyStateList by lazy { - val color = get(ColorType.TOOL_BAR_KEY) - activatedStateList( - color, - if (isBrightColor(color)) darken(darken(color)) - else brighten(brighten(color)) - ) - } + private val toolbarKeyStateList by lazy { ColorStateList.valueOf(get(ColorType.TOOL_BAR_KEY)) } override fun get(color: ColorType): Int { if (color == ColorType.ACTION_KEY_ICON && !colorMap.containsKey(ColorType.ACTION_KEY_ICON)) { @@ -799,11 +785,6 @@ private fun pressedStateList(pressed: Int, normal: Int): ColorStateList { return ColorStateList(states, intArrayOf(pressed, normal)) } -private fun activatedStateList(activated: Int, normal: Int): ColorStateList { - val states = arrayOf(intArrayOf(android.R.attr.state_activated), intArrayOf(-android.R.attr.state_activated)) - return ColorStateList(states, intArrayOf(activated, normal)) -} - enum class ColorType { ACTION_KEY_ICON, ACTION_KEY_BACKGROUND,