diff --git a/app/src/main/java/helium314/keyboard/keyboard/clipboard/ClipboardHistoryView.kt b/app/src/main/java/helium314/keyboard/keyboard/clipboard/ClipboardHistoryView.kt index 188ed3c5e..98c70f61c 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/clipboard/ClipboardHistoryView.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/clipboard/ClipboardHistoryView.kt @@ -65,10 +65,6 @@ class ClipboardHistoryView @JvmOverloads constructor( keyBackgroundId = keyboardViewAttr.getResourceId(R.styleable.KeyboardView_keyBackground, 0) keyboardViewAttr.recycle() 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)) .forEach { toolbarKeys.add(createToolbarKey(context, KeyboardIconsSet.instance, it)) } keyboardAttr.recycle() @@ -169,6 +165,9 @@ class ClipboardHistoryView @JvmOverloads constructor( adapter = clipboardAdapter 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() { 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 6876823c6..154cff3c2 100644 --- a/app/src/main/java/helium314/keyboard/latin/common/Colors.kt +++ b/app/src/main/java/helium314/keyboard/latin/common/Colors.kt @@ -626,9 +626,9 @@ private fun stateList(pressed: Int, normal: Int): ColorStateList { return ColorStateList(states, intArrayOf(pressed, normal)) } -private fun activatedStateList(normal: Int, activated: Int): ColorStateList { - val states = arrayOf(intArrayOf(-android.R.attr.state_activated), intArrayOf(android.R.attr.state_activated)) - return ColorStateList(states, intArrayOf(normal, activated)) +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 { diff --git a/app/src/main/java/helium314/keyboard/latin/utils/ToolbarUtils.kt b/app/src/main/java/helium314/keyboard/latin/utils/ToolbarUtils.kt index ee4126e82..766265349 100644 --- a/app/src/main/java/helium314/keyboard/latin/utils/ToolbarUtils.kt +++ b/app/src/main/java/helium314/keyboard/latin/utils/ToolbarUtils.kt @@ -26,7 +26,6 @@ import helium314.keyboard.latin.R import helium314.keyboard.latin.databinding.ReorderDialogItemBinding import helium314.keyboard.latin.settings.Settings import helium314.keyboard.latin.utils.ToolbarKey.* -import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json import java.util.EnumMap 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) if (contentDescriptionId != 0) button.contentDescription = context.getString(contentDescriptionId) - button.isActivated = !when (key) { + button.isActivated = when (key) { INCOGNITO -> Settings.readAlwaysIncognitoMode(DeviceProtectedUtils.getSharedPreferences(context)) ONE_HANDED -> Settings.getInstance().current.mOneHandedModeEnabled AUTOCORRECT -> Settings.getInstance().current.mAutoCorrectionEnabledPerUserSettings