mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-20 14:19:08 +00:00
rename stateList to pressedStateList for clarification
This commit is contained in:
parent
54f222c0ee
commit
833aa321b9
1 changed files with 39 additions and 39 deletions
|
@ -195,12 +195,12 @@ class DynamicColors(context: Context, override val themeStyle: String, override
|
||||||
}
|
}
|
||||||
adjustedBackgroundStateList =
|
adjustedBackgroundStateList =
|
||||||
if (themeStyle == STYLE_HOLO) {
|
if (themeStyle == STYLE_HOLO) {
|
||||||
stateList(accent, adjustedBackground)
|
pressedStateList(accent, adjustedBackground)
|
||||||
} else if (isNight) {
|
} else if (isNight) {
|
||||||
if (hasKeyBorders) stateList(doubleAdjustedAccent, keyBackground)
|
if (hasKeyBorders) pressedStateList(doubleAdjustedAccent, keyBackground)
|
||||||
else stateList(adjustedAccent, adjustedKeyBackground)
|
else pressedStateList(adjustedAccent, adjustedKeyBackground)
|
||||||
} else {
|
} else {
|
||||||
stateList(accent, Color.WHITE)
|
pressedStateList(accent, Color.WHITE)
|
||||||
}
|
}
|
||||||
|
|
||||||
val stripBackground = if (keyboardBackground == null && !hasKeyBorders) {
|
val stripBackground = if (keyboardBackground == null && !hasKeyBorders) {
|
||||||
|
@ -210,7 +210,7 @@ class DynamicColors(context: Context, override val themeStyle: String, override
|
||||||
}
|
}
|
||||||
val pressedStripElementBackground = if (keyboardBackground == null) adjustedBackground
|
val pressedStripElementBackground = if (keyboardBackground == null) adjustedBackground
|
||||||
else if (isDarkColor(background)) 0x22ffffff else 0x11000000
|
else if (isDarkColor(background)) 0x22ffffff else 0x11000000
|
||||||
stripBackgroundList = stateList(pressedStripElementBackground, stripBackground)
|
stripBackgroundList = pressedStateList(pressedStripElementBackground, stripBackground)
|
||||||
|
|
||||||
adjustedBackgroundFilter =
|
adjustedBackgroundFilter =
|
||||||
if (themeStyle == STYLE_HOLO) colorFilter(adjustedBackground)
|
if (themeStyle == STYLE_HOLO) colorFilter(adjustedBackground)
|
||||||
|
@ -218,47 +218,47 @@ class DynamicColors(context: Context, override val themeStyle: String, override
|
||||||
|
|
||||||
if (hasKeyBorders) {
|
if (hasKeyBorders) {
|
||||||
backgroundStateList =
|
backgroundStateList =
|
||||||
if (!isNight) stateList(adjustedFunctionalKey, background)
|
if (!isNight) pressedStateList(adjustedFunctionalKey, background)
|
||||||
else stateList(adjustedKeyBackground, background)
|
else pressedStateList(adjustedKeyBackground, background)
|
||||||
|
|
||||||
keyStateList =
|
keyStateList =
|
||||||
if (!isNight) stateList(adjustedBackground, keyBackground)
|
if (!isNight) pressedStateList(adjustedBackground, keyBackground)
|
||||||
else stateList(adjustedKeyBackground, keyBackground)
|
else pressedStateList(adjustedKeyBackground, keyBackground)
|
||||||
|
|
||||||
functionalKeyStateList =
|
functionalKeyStateList =
|
||||||
if (!isNight) stateList(doubleAdjustedFunctionalKey, functionalKey)
|
if (!isNight) pressedStateList(doubleAdjustedFunctionalKey, functionalKey)
|
||||||
else stateList(functionalKey, doubleAdjustedKeyBackground)
|
else pressedStateList(functionalKey, doubleAdjustedKeyBackground)
|
||||||
|
|
||||||
actionKeyStateList =
|
actionKeyStateList =
|
||||||
if (!isNight) stateList(gesture, accent)
|
if (!isNight) pressedStateList(gesture, accent)
|
||||||
else stateList(doubleAdjustedAccent, accent)
|
else pressedStateList(doubleAdjustedAccent, accent)
|
||||||
|
|
||||||
spaceBarStateList =
|
spaceBarStateList =
|
||||||
if (themeStyle == STYLE_HOLO) stateList(spaceBar, spaceBar)
|
if (themeStyle == STYLE_HOLO) pressedStateList(spaceBar, spaceBar)
|
||||||
else keyStateList
|
else keyStateList
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// need to set color to background if key borders are disabled, or there will be ugly keys
|
// need to set color to background if key borders are disabled, or there will be ugly keys
|
||||||
backgroundStateList =
|
backgroundStateList =
|
||||||
if (!isNight) stateList(adjustedFunctionalKey, background)
|
if (!isNight) pressedStateList(adjustedFunctionalKey, background)
|
||||||
else stateList(adjustedKeyBackground, background)
|
else pressedStateList(adjustedKeyBackground, background)
|
||||||
|
|
||||||
keyStateList =
|
keyStateList =
|
||||||
if (!isNight) stateList(adjustedFunctionalKey, Color.TRANSPARENT)
|
if (!isNight) pressedStateList(adjustedFunctionalKey, Color.TRANSPARENT)
|
||||||
else stateList(functionalKey, Color.TRANSPARENT)
|
else pressedStateList(functionalKey, Color.TRANSPARENT)
|
||||||
|
|
||||||
functionalKeyStateList =
|
functionalKeyStateList =
|
||||||
if (themeStyle == STYLE_HOLO) stateList(functionalKey, Color.TRANSPARENT)
|
if (themeStyle == STYLE_HOLO) pressedStateList(functionalKey, Color.TRANSPARENT)
|
||||||
else keyStateList
|
else keyStateList
|
||||||
|
|
||||||
actionKeyStateList =
|
actionKeyStateList =
|
||||||
if (themeStyle == STYLE_HOLO) stateList(accent, Color.TRANSPARENT)
|
if (themeStyle == STYLE_HOLO) pressedStateList(accent, Color.TRANSPARENT)
|
||||||
else if (!isNight) stateList(gesture, accent)
|
else if (!isNight) pressedStateList(gesture, accent)
|
||||||
else stateList(doubleAdjustedAccent, accent)
|
else pressedStateList(doubleAdjustedAccent, accent)
|
||||||
|
|
||||||
spaceBarStateList =
|
spaceBarStateList =
|
||||||
if (!isNight) stateList(gesture, adjustedFunctionalKey)
|
if (!isNight) pressedStateList(gesture, adjustedFunctionalKey)
|
||||||
else stateList(adjustedKeyBackground, spaceBar)
|
else pressedStateList(adjustedKeyBackground, spaceBar)
|
||||||
}
|
}
|
||||||
keyTextFilter = colorFilter(keyText)
|
keyTextFilter = colorFilter(keyText)
|
||||||
|
|
||||||
|
@ -409,7 +409,7 @@ class DefaultColors (
|
||||||
adjustedBackground = darken(background)
|
adjustedBackground = darken(background)
|
||||||
doubleAdjustedBackground = darken(adjustedBackground)
|
doubleAdjustedBackground = darken(adjustedBackground)
|
||||||
}
|
}
|
||||||
adjustedBackgroundStateList = stateList(doubleAdjustedBackground, adjustedBackground)
|
adjustedBackgroundStateList = pressedStateList(doubleAdjustedBackground, adjustedBackground)
|
||||||
|
|
||||||
val stripBackground: Int
|
val stripBackground: Int
|
||||||
val pressedStripElementBackground: Int
|
val pressedStripElementBackground: Int
|
||||||
|
@ -424,7 +424,7 @@ class DefaultColors (
|
||||||
stripBackground = adjustedBackground
|
stripBackground = adjustedBackground
|
||||||
pressedStripElementBackground = doubleAdjustedBackground
|
pressedStripElementBackground = doubleAdjustedBackground
|
||||||
}
|
}
|
||||||
stripBackgroundList = stateList(pressedStripElementBackground, stripBackground)
|
stripBackgroundList = pressedStateList(pressedStripElementBackground, stripBackground)
|
||||||
|
|
||||||
if (themeStyle == STYLE_HOLO && keyboardBackground == null) {
|
if (themeStyle == STYLE_HOLO && keyboardBackground == null) {
|
||||||
val darkerBackground = adjustLuminosityAndKeepAlpha(background, -0.2f)
|
val darkerBackground = adjustLuminosityAndKeepAlpha(background, -0.2f)
|
||||||
|
@ -437,22 +437,22 @@ class DefaultColors (
|
||||||
|
|
||||||
adjustedBackgroundFilter = colorFilter(adjustedBackground)
|
adjustedBackgroundFilter = colorFilter(adjustedBackground)
|
||||||
if (hasKeyBorders) {
|
if (hasKeyBorders) {
|
||||||
backgroundStateList = stateList(brightenOrDarken(background, true), background)
|
backgroundStateList = pressedStateList(brightenOrDarken(background, true), background)
|
||||||
keyStateList = if (themeStyle == STYLE_HOLO) stateList(keyBackground, keyBackground)
|
keyStateList = if (themeStyle == STYLE_HOLO) pressedStateList(keyBackground, keyBackground)
|
||||||
else stateList(brightenOrDarken(keyBackground, true), keyBackground)
|
else pressedStateList(brightenOrDarken(keyBackground, true), keyBackground)
|
||||||
functionalKeyStateList = stateList(brightenOrDarken(functionalKey, true), functionalKey)
|
functionalKeyStateList = pressedStateList(brightenOrDarken(functionalKey, true), functionalKey)
|
||||||
actionKeyStateList = if (themeStyle == STYLE_HOLO) functionalKeyStateList
|
actionKeyStateList = if (themeStyle == STYLE_HOLO) functionalKeyStateList
|
||||||
else stateList(brightenOrDarken(accent, true), accent)
|
else pressedStateList(brightenOrDarken(accent, true), accent)
|
||||||
spaceBarStateList = if (themeStyle == STYLE_HOLO) stateList(spaceBar, spaceBar)
|
spaceBarStateList = if (themeStyle == STYLE_HOLO) pressedStateList(spaceBar, spaceBar)
|
||||||
else stateList(brightenOrDarken(spaceBar, true), spaceBar)
|
else pressedStateList(brightenOrDarken(spaceBar, true), spaceBar)
|
||||||
} else {
|
} else {
|
||||||
// need to set color to background if key borders are disabled, or there will be ugly keys
|
// need to set color to background if key borders are disabled, or there will be ugly keys
|
||||||
backgroundStateList = stateList(brightenOrDarken(background, true), background)
|
backgroundStateList = pressedStateList(brightenOrDarken(background, true), background)
|
||||||
keyStateList = stateList(keyBackground, Color.TRANSPARENT)
|
keyStateList = pressedStateList(keyBackground, Color.TRANSPARENT)
|
||||||
functionalKeyStateList = keyStateList
|
functionalKeyStateList = keyStateList
|
||||||
actionKeyStateList = if (themeStyle == STYLE_HOLO) functionalKeyStateList
|
actionKeyStateList = if (themeStyle == STYLE_HOLO) functionalKeyStateList
|
||||||
else stateList(brightenOrDarken(accent, true), accent)
|
else pressedStateList(brightenOrDarken(accent, true), accent)
|
||||||
spaceBarStateList = stateList(brightenOrDarken(spaceBar, true), spaceBar)
|
spaceBarStateList = pressedStateList(brightenOrDarken(spaceBar, true), spaceBar)
|
||||||
}
|
}
|
||||||
keyTextFilter = colorFilter(keyText)
|
keyTextFilter = colorFilter(keyText)
|
||||||
actionKeyIconColorFilter = when {
|
actionKeyIconColorFilter = when {
|
||||||
|
@ -556,7 +556,7 @@ class AllColors(private val colorMap: EnumMap<ColorType, Int>, override val them
|
||||||
override fun get(color: ColorType): Int = colorMap[color] ?: color.default()
|
override fun get(color: ColorType): Int = colorMap[color] ?: color.default()
|
||||||
|
|
||||||
override fun setColor(drawable: Drawable, color: ColorType) {
|
override fun setColor(drawable: Drawable, color: ColorType) {
|
||||||
val colorStateList = stateListMap.getOrPut(color) { stateList(brightenOrDarken(get(color), true), get(color)) }
|
val colorStateList = stateListMap.getOrPut(color) { pressedStateList(brightenOrDarken(get(color), true), get(color)) }
|
||||||
DrawableCompat.setTintMode(drawable, PorterDuff.Mode.MULTIPLY)
|
DrawableCompat.setTintMode(drawable, PorterDuff.Mode.MULTIPLY)
|
||||||
DrawableCompat.setTintList(drawable, colorStateList)
|
DrawableCompat.setTintList(drawable, colorStateList)
|
||||||
}
|
}
|
||||||
|
@ -621,7 +621,7 @@ private fun colorFilter(color: Int, mode: BlendModeCompat = BlendModeCompat.MODU
|
||||||
return BlendModeColorFilterCompat.createBlendModeColorFilterCompat(color, mode)!!
|
return BlendModeColorFilterCompat.createBlendModeColorFilterCompat(color, mode)!!
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun stateList(pressed: Int, normal: Int): ColorStateList {
|
private fun pressedStateList(pressed: Int, normal: Int): ColorStateList {
|
||||||
val states = arrayOf(intArrayOf(android.R.attr.state_pressed), intArrayOf(-android.R.attr.state_pressed))
|
val states = arrayOf(intArrayOf(android.R.attr.state_pressed), intArrayOf(-android.R.attr.state_pressed))
|
||||||
return ColorStateList(states, intArrayOf(pressed, normal))
|
return ColorStateList(states, intArrayOf(pressed, normal))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue