Skip to content

Commit

Permalink
fix(command-mode): fix shift key and capitalization behaviour
Browse files Browse the repository at this point in the history
Correct capitalization behavior, fix shift key icon, and handle German plural noun capitalization.

Closes #287
  • Loading branch information
smalik2811 committed Jan 16, 2025
1 parent 4a3cb97 commit 678cef3
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions app/src/main/java/be/scri/services/GeneralKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ abstract class GeneralKeyboardIME(
} else {
currentEnterKeyType!!
}
keyboard = KeyboardBase(this, getKeyboardLayoutXML(), enterKeyType)
keyboardView?.setKeyboard(keyboard!!)
}

fun getIsAccentCharacterDisabled(): Boolean {
Expand Down Expand Up @@ -336,6 +336,10 @@ abstract class GeneralKeyboardIME(
Log.i("MY-TAG", "PLURAL STATE")
updateKeyboardMode(true)
currentState = ScribeState.PLURAL
if (language == "German") {
// Nouns are capitalized in 'German' language.
keyboard!!.mShiftState = SHIFT_ON_ONE_CHAR
}
updateUI()
}
}
Expand Down Expand Up @@ -552,7 +556,11 @@ abstract class GeneralKeyboardIME(
}

fun updateShiftKeyState() {
if (keyboardMode == keyboardLetters) {
// The shift state in the command modes like Translate, Conjugate, Plural etc. should not depend on the
// capitalization mode of the Input Connection. It should be be carried on from the previous mode.
if ((currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) &&
keyboardMode == keyboardLetters
) {
val editorInfo = currentInputEditorInfo
if (
editorInfo != null &&
Expand Down Expand Up @@ -762,11 +770,11 @@ abstract class GeneralKeyboardIME(
binding?.commandBar?.append(codeChar.toString())
inputConnection.commitText(codeChar.toString(), 1)
}
}

if (keyboard!!.mShiftState == SHIFT_ON_ONE_CHAR && keyboardMode == keyboardLetters) {
keyboard!!.mShiftState = SHIFT_OFF
keyboardView!!.invalidateAllKeys()
}
if (keyboard!!.mShiftState == SHIFT_ON_ONE_CHAR && keyboardMode == keyboardLetters) {
keyboard!!.mShiftState = SHIFT_OFF
keyboardView!!.invalidateAllKeys()
}
}

Expand Down

0 comments on commit 678cef3

Please sign in to comment.