@@ -95,15 +95,10 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL
9595
9696 when (code) {
9797 MyKeyboard .KEYCODE_DELETE -> {
98- if (keyboard!! .mShiftState == ShiftState .ON_ONE_CHAR ) {
99- keyboard!! .setShifted(ShiftState .OFF )
100- }
10198
102- if (config.enableSentencesCapitalization ) {
99+ if (keyboard !! .mShiftState != ShiftState . ON_PERMANENT ) {
103100 val extractedText = inputConnection.getTextBeforeCursor(3 , 0 )?.dropLast(1 )
104- if (ShiftState .shouldCapitalizeOnDelete(text = extractedText)) {
105- keyboard!! .setShifted(ShiftState .ON_ONE_CHAR )
106- }
101+ keyboard!! .setShifted(ShiftState .getCapitalizationOnDelete(context = this , text = extractedText))
107102 }
108103
109104 val selectedText = inputConnection.getSelectedText(0 )
@@ -192,16 +187,8 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL
192187 inputConnection.commitText(codeChar.toString(), 1 )
193188 }
194189
195- if (keyboardMode == KEYBOARD_LETTERS ) {
196- if (keyboard!! .mShiftState == ShiftState .ON_ONE_CHAR ) {
197- keyboard!! .setShifted(ShiftState .OFF )
198- }
199- if (config.enableSentencesCapitalization && ShiftState .shouldCapitalizeSentence(
200- previousChar = originalText.lastOrNull(), currentChar = code.toChar()
201- )
202- ) {
203- keyboard!! .setShifted(ShiftState .ON_ONE_CHAR )
204- }
190+ if (keyboardMode == KEYBOARD_LETTERS && keyboard!! .mShiftState != ShiftState .ON_PERMANENT ) {
191+ keyboard!! .setShifted(ShiftState .getShiftStateForText(this , newText = " $originalText$codeChar " ))
205192 keyboardView!! .invalidateAllKeys()
206193 }
207194
@@ -218,7 +205,7 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL
218205 // TODO: Change keyboardMode to enum class
219206 keyboardMode = KEYBOARD_LETTERS
220207 val text = currentInputConnection?.getExtractedText(ExtractedTextRequest (), 0 )?.text
221- val newShiftState = ShiftState .getShiftStateForText(this , text)
208+ val newShiftState = ShiftState .getShiftStateForText(this , text?.toString().orEmpty() )
222209
223210 keyboard = MyKeyboard (this , getKeyboardLayoutXML(), enterKeyType, shiftState = newShiftState)
224211
0 commit comments