Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 4 additions & 23 deletions app/src/main/java/helium314/keyboard/latin/common/Colors.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -672,14 +665,7 @@ class AllColors(private val colorMap: EnumMap<ColorType, Int>, override val them
private val stateListMap = EnumMap<ColorType, ColorStateList>(ColorType::class.java)
private var backgroundSetupDone = false
private val colorFilters = hashMapOf<ColorType, ColorFilter>()
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)) {
Expand Down Expand Up @@ -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,
Expand Down
Loading