From cc87f4f9edd3b1eed220652a025ef681019a1f0c Mon Sep 17 00:00:00 2001 From: junior-od Date: Tue, 13 Jan 2026 16:32:35 +0100 Subject: [PATCH 1/3] fix: Capitalize conjugations when input verb is capitalized --- .../be/scri/services/GeneralKeyboardIME.kt | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt b/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt index d7c683a1..9a82db2e 100644 --- a/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt +++ b/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt @@ -2405,7 +2405,10 @@ abstract class GeneralKeyboardIME( */ private fun handleConjugateState(rawInput: String) { val searchInput = rawInput.lowercase() + + // Store the original input to check capitalization currentVerbForConjugation = rawInput + val languageAlias = getLanguageAlias(language) val tempOutput = @@ -2415,9 +2418,14 @@ abstract class GeneralKeyboardIME( searchInput, ) + // Apply capitalization if the original input was capitalized + val isCapitalized = rawInput.firstOrNull()?.isUpperCase() == true conjugateOutput = if (tempOutput?.isEmpty() == true || tempOutput?.values?.all { it.isEmpty() } == true) { null + } else if (isCapitalized && tempOutput != null) { + // Apply capitalization to all conjugated forms + applyCapitalizationToConjugations(tempOutput) } else { tempOutput } @@ -2439,6 +2447,41 @@ abstract class GeneralKeyboardIME( updateUI() } + /** + * Applies proper capitalization to all conjugated forms in the output map. + * Only capitalizes the first letter of the first word in each conjugation. + * + * @param conjugations The original map of conjugations from the database + * @return A new map with properly capitalized conjugations + */ + private fun applyCapitalizationToConjugations( + conjugations: MutableMap>>, + ): MutableMap>> { + val capitalizedOutput: MutableMap>> = mutableMapOf() + + conjugations.forEach { (tenseKey, conjugationMap) -> + val capitalizedConjugations: MutableMap> = mutableMapOf() + + conjugationMap.forEach { (categoryKey, forms) -> + val capitalizedForms = + forms.map { form -> + if (form.isNotEmpty()) { + // Only capitalize the first character of the entire string + // This handles both simple forms ("bin") and complex forms ("have walked") + form.replaceFirstChar { it.uppercase() } + } else { + form + } + } + capitalizedConjugations[categoryKey] = capitalizedForms + } + + capitalizedOutput[tenseKey] = capitalizedConjugations + } + + return capitalizedOutput + } + /** * Handles the default behavior of the Enter key when not in a special Scribe command mode. * From 4dfb3e4623843bac92339b994f3a92c7a9614004 Mon Sep 17 00:00:00 2001 From: junior-od Date: Wed, 14 Jan 2026 17:25:17 +0100 Subject: [PATCH 2/3] fix: Add ALL CAPS support for translate, plural, and conjugate commands --- .../be/scri/services/GeneralKeyboardIME.kt | 66 ++++++++++++------- 1 file changed, 44 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt b/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt index 9a82db2e..b77e312f 100644 --- a/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt +++ b/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt @@ -2364,6 +2364,7 @@ abstract class GeneralKeyboardIME( /** * Handles the Enter key press when in the plural or translate state. + * Now supports ALL CAPS input formatting. * * @param rawInput The text from the command bar. * @param inputConnection The current input connection. @@ -2372,6 +2373,9 @@ abstract class GeneralKeyboardIME( rawInput: String, inputConnection: InputConnection, ) { + // Detect if input is ALL CAPS + val isAllCaps = rawInput.isNotEmpty() && rawInput.all { !it.isLetter() || it.isUpperCase() } + val commandModeOutput = when (currentState) { ScribeState.PLURAL -> { @@ -2382,10 +2386,25 @@ abstract class GeneralKeyboardIME( return } null -> "" - else -> pluralResult + else -> { + // Apply ALL CAPS formatting if input was ALL CAPS + if (isAllCaps) { + pluralResult.uppercase() + } else { + pluralResult + } + } + } + } + ScribeState.TRANSLATE -> { + val translation = getTranslation(language, rawInput) + // Apply ALL CAPS formatting if input was ALL CAPS + if (isAllCaps) { + translation.uppercase() + } else { + translation } } - ScribeState.TRANSLATE -> getTranslation(language, rawInput) else -> "" } @@ -2400,6 +2419,7 @@ abstract class GeneralKeyboardIME( /** * Handles the Enter key press when in the `CONJUGATE` state. It fetches the * conjugation data for the entered verb and transitions to the selection view. + * Now supports ALL CAPS input formatting. * * @param rawInput The verb entered in the command bar. */ @@ -2418,14 +2438,16 @@ abstract class GeneralKeyboardIME( searchInput, ) - // Apply capitalization if the original input was capitalized - val isCapitalized = rawInput.firstOrNull()?.isUpperCase() == true + // Detect capitalization style + val isAllCaps = rawInput.isNotEmpty() && rawInput.all { !it.isLetter() || it.isUpperCase() } + val isCapitalized = !isAllCaps && rawInput.firstOrNull()?.isUpperCase() == true + conjugateOutput = if (tempOutput?.isEmpty() == true || tempOutput?.values?.all { it.isEmpty() } == true) { null - } else if (isCapitalized && tempOutput != null) { - // Apply capitalization to all conjugated forms - applyCapitalizationToConjugations(tempOutput) + } else if ((isAllCaps || isCapitalized) && tempOutput != null) { + // Apply appropriate capitalization to all conjugated forms + applyCapitalizationToConjugations(tempOutput, isAllCaps) } else { tempOutput } @@ -2448,38 +2470,38 @@ abstract class GeneralKeyboardIME( } /** - * Applies proper capitalization to all conjugated forms in the output map. - * Only capitalizes the first letter of the first word in each conjugation. + * Applies capitalization to all conjugated forms in the output map. + * Supports both standard capitalization (first letter) and ALL CAPS formatting. * * @param conjugations The original map of conjugations from the database - * @return A new map with properly capitalized conjugations + * @param isAllCaps If true, applies ALL CAPS; if false, capitalizes only the first letter + * @return A new map with properly formatted conjugations */ private fun applyCapitalizationToConjugations( conjugations: MutableMap>>, + isAllCaps: Boolean = false, ): MutableMap>> { - val capitalizedOutput: MutableMap>> = mutableMapOf() + val formattedOutput: MutableMap>> = mutableMapOf() conjugations.forEach { (tenseKey, conjugationMap) -> - val capitalizedConjugations: MutableMap> = mutableMapOf() + val formattedConjugations: MutableMap> = mutableMapOf() conjugationMap.forEach { (categoryKey, forms) -> - val capitalizedForms = + val formattedForms = forms.map { form -> - if (form.isNotEmpty()) { - // Only capitalize the first character of the entire string - // This handles both simple forms ("bin") and complex forms ("have walked") - form.replaceFirstChar { it.uppercase() } - } else { - form + when { + form.isEmpty() -> form + isAllCaps -> form.uppercase() + else -> form.replaceFirstChar { it.uppercase() } } } - capitalizedConjugations[categoryKey] = capitalizedForms + formattedConjugations[categoryKey] = formattedForms } - capitalizedOutput[tenseKey] = capitalizedConjugations + formattedOutput[tenseKey] = formattedConjugations } - return capitalizedOutput + return formattedOutput } /** From 4fcb5e9b6f91adb7bf57a0502098b76402d35b2d Mon Sep 17 00:00:00 2001 From: Andrew Tavis McAllister Date: Thu, 15 Jan 2026 00:40:42 +0100 Subject: [PATCH 3/3] Minor comment removals and formatting --- .../be/scri/services/GeneralKeyboardIME.kt | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt b/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt index b77e312f..2ea9ec6d 100644 --- a/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt +++ b/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt @@ -2364,7 +2364,6 @@ abstract class GeneralKeyboardIME( /** * Handles the Enter key press when in the plural or translate state. - * Now supports ALL CAPS input formatting. * * @param rawInput The text from the command bar. * @param inputConnection The current input connection. @@ -2373,7 +2372,7 @@ abstract class GeneralKeyboardIME( rawInput: String, inputConnection: InputConnection, ) { - // Detect if input is ALL CAPS + // Detect if input is all capital letters. val isAllCaps = rawInput.isNotEmpty() && rawInput.all { !it.isLetter() || it.isUpperCase() } val commandModeOutput = @@ -2387,7 +2386,7 @@ abstract class GeneralKeyboardIME( } null -> "" else -> { - // Apply ALL CAPS formatting if input was ALL CAPS + // Apply all capital letters formatting if input was this format. if (isAllCaps) { pluralResult.uppercase() } else { @@ -2398,7 +2397,7 @@ abstract class GeneralKeyboardIME( } ScribeState.TRANSLATE -> { val translation = getTranslation(language, rawInput) - // Apply ALL CAPS formatting if input was ALL CAPS + // Apply all capital letters formatting if input was this format. if (isAllCaps) { translation.uppercase() } else { @@ -2419,14 +2418,13 @@ abstract class GeneralKeyboardIME( /** * Handles the Enter key press when in the `CONJUGATE` state. It fetches the * conjugation data for the entered verb and transitions to the selection view. - * Now supports ALL CAPS input formatting. * * @param rawInput The verb entered in the command bar. */ private fun handleConjugateState(rawInput: String) { val searchInput = rawInput.lowercase() - // Store the original input to check capitalization + // Store the original input to check capitalization. currentVerbForConjugation = rawInput val languageAlias = getLanguageAlias(language) @@ -2438,7 +2436,7 @@ abstract class GeneralKeyboardIME( searchInput, ) - // Detect capitalization style + // Detect capitalization style. val isAllCaps = rawInput.isNotEmpty() && rawInput.all { !it.isLetter() || it.isUpperCase() } val isCapitalized = !isAllCaps && rawInput.firstOrNull()?.isUpperCase() == true @@ -2446,7 +2444,7 @@ abstract class GeneralKeyboardIME( if (tempOutput?.isEmpty() == true || tempOutput?.values?.all { it.isEmpty() } == true) { null } else if ((isAllCaps || isCapitalized) && tempOutput != null) { - // Apply appropriate capitalization to all conjugated forms + // Apply appropriate capitalization to all conjugated forms. applyCapitalizationToConjugations(tempOutput, isAllCaps) } else { tempOutput @@ -2471,11 +2469,12 @@ abstract class GeneralKeyboardIME( /** * Applies capitalization to all conjugated forms in the output map. - * Supports both standard capitalization (first letter) and ALL CAPS formatting. + * Supports both standard capitalization (first letter) and all capital letters formatting. * - * @param conjugations The original map of conjugations from the database - * @param isAllCaps If true, applies ALL CAPS; if false, capitalizes only the first letter - * @return A new map with properly formatted conjugations + * @param conjugations The original map of conjugations from the database. + * @param isAllCaps If true, applies all capital letters; if false, capitalizes only first letter. + + * @return A new map with properly formatted conjugations. */ private fun applyCapitalizationToConjugations( conjugations: MutableMap>>,