Skip to content
Open
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
20 changes: 19 additions & 1 deletion src/main/kotlin/tribixbite/cleverkeys/CleverKeysService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ class CleverKeysService : InputMethodService(),
if (intent?.action == ACTION_THEME_CHANGED) {
// 1. Refresh config to pick up new values (colors, etc.)
_configManager.refresh(resources)

// 2. FORCE view recreation.
// Even if the theme ID hasn't changed (e.g. editing custom theme colors),
// we need to recreate the view to pick up the new colors.
Expand Down Expand Up @@ -566,6 +566,17 @@ class CleverKeysService : InputMethodService(),
_configManager.refresh(resources)
}

/**
* Recalculate the keyboard height based on current orientation/foldable state
* and apply it to the keyboard view. Call this whenever the height might have changed.
*/
private fun refreshKeyboardHeight() {
if (!::_neuralLayoutBridge.isInitialized) return
val height = _neuralLayoutBridge.calculateDynamicKeyboardHeight()
_keyboardView.layoutParams?.height = height.toInt()
_keyboardView.requestLayout()
}

// ConfigChangeListener implementation (v1.32.345)

/**
Expand Down Expand Up @@ -774,6 +785,7 @@ class CleverKeysService : InputMethodService(),
// Without this, landscape margins are never applied because Config.orientation_landscape
// isn't updated when the device rotates
refresh_config()
refreshKeyboardHeight()
}

override fun onUpdateSelection(
Expand Down Expand Up @@ -873,6 +885,12 @@ class CleverKeysService : InputMethodService(),
return
}

if (key in setOf("keyboard_height", "keyboard_height_landscape",
"keyboard_height_unfolded", "keyboard_height_landscape_unfolded")) {
refreshKeyboardHeight()
// Do NOT return here – let the existing handler also run if needed
}

// Initialize handler lazily (depends on components that may not exist yet)
if (_preferenceUIUpdateHandler == null) {
_preferenceUIUpdateHandler = PreferenceUIUpdateHandler.create(
Expand Down