Skip to content
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Emojis for the following are chosen based on [gitmoji](https://gitmoji.dev/).

### Bug Fixes

- The keyboard service no longer crashes when an editor starts input with no `EditorInfo` ([#699](https://github.com/scribe-org/Scribe-Android/issues/699)).
- Downloading or checking for language data updates no longer crashes the app when the server returns a malformed timestamp ([#700](https://github.com/scribe-org/Scribe-Android/issues/700)).

### 🔒 Security
Expand Down
9 changes: 5 additions & 4 deletions app/src/keyboards/java/be/scri/services/GeneralKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -442,16 +442,17 @@ abstract class GeneralKeyboardIME(
restarting: Boolean,
) {
super.onStartInput(attribute, restarting)
inputTypeClass = attribute!!.inputType and TYPE_MASK_CLASS
enterKeyType = attribute.imeOptions and (IME_MASK_ACTION or IME_FLAG_NO_ENTER_ACTION)
val editorInfo = attribute ?: EditorInfo()
inputTypeClass = editorInfo.inputType and TYPE_MASK_CLASS
enterKeyType = editorInfo.imeOptions and (IME_MASK_ACTION or IME_FLAG_NO_ENTER_ACTION)
currentEnterKeyType = enterKeyType

// This setter triggers the logic in the property override if not shadowed.
hasTextBeforeCursor = currentInputConnection?.getTextBeforeCursor(1, 0)?.isNotEmpty() == true

isNumericKeyboardActive = shouldUseNumericKeyboard(attribute.inputType)
isNumericKeyboardActive = shouldUseNumericKeyboard(editorInfo.inputType)
keyboardMode = if (isNumericKeyboardActive) keyboardSymbols else keyboardLetters
val keyboardXml = getKeyboardLayoutXMLForInputType(attribute.inputType, getKeyboardLayoutXML())
val keyboardXml = getKeyboardLayoutXMLForInputType(editorInfo.inputType, getKeyboardLayoutXML())

loadLanguageData()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package be.scri.services

import android.text.InputType
import android.view.inputmethod.EditorInfo
import be.scri.R
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
Expand Down Expand Up @@ -55,4 +56,15 @@ class GeneralKeyboardIMEInputTypeTest {
GeneralKeyboardIME.getKeyboardLayoutXMLForInputType(inputType, R.xml.keys_letters_english),
)
}

@Test
fun defaultEditorInfo_fallsBackToLetterLayout() {
val fallback = EditorInfo()

assertFalse(GeneralKeyboardIME.shouldUseNumericKeyboard(fallback.inputType))
assertEquals(
R.xml.keys_letters_english,
GeneralKeyboardIME.getKeyboardLayoutXMLForInputType(fallback.inputType, R.xml.keys_letters_english),
)
}
}
Loading