Skip to content
Closed
Show file tree
Hide file tree
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
28 changes: 26 additions & 2 deletions app/src/main/java/be/scri/services/GeneralKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -153,21 +153,45 @@ abstract class GeneralKeyboardIME(
setupCommandBarTheme(binding)
}

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.setBackgroundColor(getColor(R.color.special_key_dark))
promptTextView?.setBackgroundColor(getColor(R.color.special_key_dark))
keyboardBinding.promptTextBorder?.setBackgroundColor(getColor(R.color.special_key_dark))
} else {
commandBarButton.setBackgroundColor(getColor(white))
promptTextView?.setBackgroundColor(getColor(white))
keyboardBinding.promptTextBorder?.setBackgroundColor(getColor(white))
}

Log.d(
"KeyboardUpdate",
"CommandBar Hint Updated: [State: $currentState, Language: $language, Hint: $hintMessage]",
)
}

private fun updateKeyboardMode(isCommandMode: Boolean = false) {
updateCommandBarHintandPrompt()
val sharedPref = getSharedPreferences("app_preferences", MODE_PRIVATE)
val currentNightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
val isSystemDarkMode = currentNightMode == Configuration.UI_MODE_NIGHT_YES
val isUserDarkMode = sharedPref.getBoolean("dark_mode", isSystemDarkMode)

if (isUserDarkMode) {
val color = ContextCompat.getColorStateList(this, R.color.light_key_color)
keyboardBinding.scribeKey.foregroundTintList = color
} else {
val colorLight = ContextCompat.getColorStateList(this, R.color.light_key_text_color)
keyboardBinding.scribeKey.foregroundTintList = colorLight
}

updateCommandBarHintandPrompt(isUserDarkMode)
enterKeyType =
if (isCommandMode) {
KeyboardBase.MyCustomActions.IME_ACTION_COMMAND
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/button_background_rounded.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<layer-list>
<item android:id="@+id/button_background_shape">
<shape android:shape="rectangle">
<solid android:color="@color/light_scribe_blue"/>
<solid android:color="@color/color_primary"/>
<corners android:radius="12dp"/>
</shape>
</item>
Expand Down