From e3b3a7d509ae0a686c622f2853272546ca784c08 Mon Sep 17 00:00:00 2001 From: janice Date: Sun, 16 Mar 2025 01:38:24 +0530 Subject: [PATCH 1/2] Fix dark mode coloration of command bar, X symbol and command keys. --- .../be/scri/services/GeneralKeyboardIME.kt | 19 +++++++++++++++++-- .../drawable/button_background_rounded.xml | 2 +- app/src/main/res/values/colors.xml | 1 + 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt b/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt index bc630f78..3ca20aa8 100644 --- a/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt +++ b/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt @@ -452,13 +452,24 @@ abstract class GeneralKeyboardIME( * This function is responsible for modifying the UI elements of the command bar * to provide appropriate hints and prompts to the user. */ - private fun updateCommandBarHintAndPrompt() { + private fun updateCommandBarHintAndPrompt(isUserDarkMode: Boolean? = null) { val commandBarButton = keyboardBinding.commandBar val hintMessage = HintUtils.getCommandBarHint(currentState, language) val promptText = HintUtils.getPromptText(currentState, language) val promptTextView = keyboardBinding.promptText promptTextView.text = promptText commandBarButton.hint = hintMessage + + if (isUserDarkMode == true) { + commandBarButton.backgroundTintList = ContextCompat.getColorStateList(this, R.color.command_bar_color_dark) + promptTextView.setBackgroundColor(getColor(R.color.command_bar_color_dark)) + keyboardBinding.promptTextBorder.setBackgroundColor(getColor(R.color.command_bar_color_dark)) + } else { + commandBarButton.backgroundTintList = ContextCompat.getColorStateList(this, R.color.white) + promptTextView.setBackgroundColor(getColor(white)) + keyboardBinding.promptTextBorder.setBackgroundColor(getColor(white)) + } + Log.d( "KeyboardUpdate", "CommandBar Hint Updated: [State: $currentState, Language: $language, Hint: $hintMessage]", @@ -524,10 +535,14 @@ abstract class GeneralKeyboardIME( when (isUserDarkMode) { true -> { keyboardBinding.topKeyboardDivider.setBackgroundColor(getColor(R.color.special_key_dark)) + val color = ContextCompat.getColorStateList(this, R.color.light_key_color) + keyboardBinding.scribeKey.foregroundTintList = color } false -> { keyboardBinding.topKeyboardDivider.setBackgroundColor(getColor(R.color.special_key_light)) + val colorLight = ContextCompat.getColorStateList(this, R.color.light_key_text_color) + keyboardBinding.scribeKey.foregroundTintList = colorLight } } handleModeChange(keyboardSymbols, keyboardView, this) @@ -541,7 +556,7 @@ abstract class GeneralKeyboardIME( updateUI() } setInputView(keyboardHolder) - updateCommandBarHintAndPrompt() + updateCommandBarHintAndPrompt(isUserDarkMode) } /** diff --git a/app/src/main/res/drawable/button_background_rounded.xml b/app/src/main/res/drawable/button_background_rounded.xml index 36f4690e..25cf89d7 100644 --- a/app/src/main/res/drawable/button_background_rounded.xml +++ b/app/src/main/res/drawable/button_background_rounded.xml @@ -4,7 +4,7 @@ - + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index bee80d87..8743f10a 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -16,6 +16,7 @@ @android:color/transparent #aeb3be #202020 + #2E2E2E @color/dark_scribe_color @color/light_scribe_color From 51092a4a202713ec281ba2eb0d0d52e2c80b34da Mon Sep 17 00:00:00 2001 From: janice Date: Mon, 17 Mar 2025 23:51:49 +0530 Subject: [PATCH 2/2] Update colors for prompt text, command bar button text and hint to match user theme. --- app/src/main/java/be/scri/services/GeneralKeyboardIME.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt b/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt index 3ca20aa8..683746d6 100644 --- a/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt +++ b/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt @@ -461,11 +461,17 @@ abstract class GeneralKeyboardIME( commandBarButton.hint = hintMessage if (isUserDarkMode == true) { + commandBarButton.setHintTextColor(getColor(R.color.hint_white)) + commandBarButton.setTextColor(getColor(white)) commandBarButton.backgroundTintList = ContextCompat.getColorStateList(this, R.color.command_bar_color_dark) + promptTextView.setTextColor(getColor(white)) promptTextView.setBackgroundColor(getColor(R.color.command_bar_color_dark)) keyboardBinding.promptTextBorder.setBackgroundColor(getColor(R.color.command_bar_color_dark)) } else { + commandBarButton.setHintTextColor(getColor(R.color.hint_black)) + commandBarButton.setTextColor(Color.BLACK) commandBarButton.backgroundTintList = ContextCompat.getColorStateList(this, R.color.white) + promptTextView.setTextColor(Color.BLACK) promptTextView.setBackgroundColor(getColor(white)) keyboardBinding.promptTextBorder.setBackgroundColor(getColor(white)) }