mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-02 12:52:15 +00:00
fix weird issue with toolbar keys having wrong color for their state
and remove related semi-workaround
This commit is contained in:
parent
419c0d847b
commit
54f222c0ee
3 changed files with 7 additions and 9 deletions
|
@ -65,10 +65,6 @@ class ClipboardHistoryView @JvmOverloads constructor(
|
||||||
keyBackgroundId = keyboardViewAttr.getResourceId(R.styleable.KeyboardView_keyBackground, 0)
|
keyBackgroundId = keyboardViewAttr.getResourceId(R.styleable.KeyboardView_keyBackground, 0)
|
||||||
keyboardViewAttr.recycle()
|
keyboardViewAttr.recycle()
|
||||||
val keyboardAttr = context.obtainStyledAttributes(attrs, R.styleable.Keyboard, defStyle, R.style.SuggestionStripView)
|
val keyboardAttr = context.obtainStyledAttributes(attrs, R.styleable.Keyboard, defStyle, R.style.SuggestionStripView)
|
||||||
// todo (maybe): setting the correct color only works because the activated state is inverted
|
|
||||||
// even when state is activated, the not activated color is set
|
|
||||||
// in suggestionStripView the same thing works correctly, wtf?
|
|
||||||
// need to properly fix it (and maybe undo the inverted isActivated) when adding a toggle key
|
|
||||||
getEnabledClipboardToolbarKeys(DeviceProtectedUtils.getSharedPreferences(context))
|
getEnabledClipboardToolbarKeys(DeviceProtectedUtils.getSharedPreferences(context))
|
||||||
.forEach { toolbarKeys.add(createToolbarKey(context, KeyboardIconsSet.instance, it)) }
|
.forEach { toolbarKeys.add(createToolbarKey(context, KeyboardIconsSet.instance, it)) }
|
||||||
keyboardAttr.recycle()
|
keyboardAttr.recycle()
|
||||||
|
@ -169,6 +165,9 @@ class ClipboardHistoryView @JvmOverloads constructor(
|
||||||
adapter = clipboardAdapter
|
adapter = clipboardAdapter
|
||||||
layoutParams.width = ResourceUtils.getKeyboardWidth(context, Settings.getInstance().current)
|
layoutParams.width = ResourceUtils.getKeyboardWidth(context, Settings.getInstance().current)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// absurd workaround so Android sets the correct color from stateList (depending on "activated")
|
||||||
|
toolbarKeys.forEach { it.isEnabled = false; it.isEnabled = true }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun stopClipboardHistory() {
|
fun stopClipboardHistory() {
|
||||||
|
|
|
@ -626,9 +626,9 @@ private fun stateList(pressed: Int, normal: Int): ColorStateList {
|
||||||
return ColorStateList(states, intArrayOf(pressed, normal))
|
return ColorStateList(states, intArrayOf(pressed, normal))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun activatedStateList(normal: Int, activated: Int): ColorStateList {
|
private fun activatedStateList(activated: Int, normal: Int): ColorStateList {
|
||||||
val states = arrayOf(intArrayOf(-android.R.attr.state_activated), intArrayOf(android.R.attr.state_activated))
|
val states = arrayOf(intArrayOf(android.R.attr.state_activated), intArrayOf(-android.R.attr.state_activated))
|
||||||
return ColorStateList(states, intArrayOf(normal, activated))
|
return ColorStateList(states, intArrayOf(activated, normal))
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class ColorType {
|
enum class ColorType {
|
||||||
|
|
|
@ -26,7 +26,6 @@ import helium314.keyboard.latin.R
|
||||||
import helium314.keyboard.latin.databinding.ReorderDialogItemBinding
|
import helium314.keyboard.latin.databinding.ReorderDialogItemBinding
|
||||||
import helium314.keyboard.latin.settings.Settings
|
import helium314.keyboard.latin.settings.Settings
|
||||||
import helium314.keyboard.latin.utils.ToolbarKey.*
|
import helium314.keyboard.latin.utils.ToolbarKey.*
|
||||||
import kotlinx.serialization.encodeToString
|
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import java.util.EnumMap
|
import java.util.EnumMap
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
@ -38,7 +37,7 @@ fun createToolbarKey(context: Context, iconsSet: KeyboardIconsSet, key: ToolbarK
|
||||||
val contentDescriptionId = context.resources.getIdentifier(key.name.lowercase(), "string", context.packageName)
|
val contentDescriptionId = context.resources.getIdentifier(key.name.lowercase(), "string", context.packageName)
|
||||||
if (contentDescriptionId != 0)
|
if (contentDescriptionId != 0)
|
||||||
button.contentDescription = context.getString(contentDescriptionId)
|
button.contentDescription = context.getString(contentDescriptionId)
|
||||||
button.isActivated = !when (key) {
|
button.isActivated = when (key) {
|
||||||
INCOGNITO -> Settings.readAlwaysIncognitoMode(DeviceProtectedUtils.getSharedPreferences(context))
|
INCOGNITO -> Settings.readAlwaysIncognitoMode(DeviceProtectedUtils.getSharedPreferences(context))
|
||||||
ONE_HANDED -> Settings.getInstance().current.mOneHandedModeEnabled
|
ONE_HANDED -> Settings.getInstance().current.mOneHandedModeEnabled
|
||||||
AUTOCORRECT -> Settings.getInstance().current.mAutoCorrectionEnabledPerUserSettings
|
AUTOCORRECT -> Settings.getInstance().current.mAutoCorrectionEnabledPerUserSettings
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue