Skip to content

Commit

Permalink
Merge branch 'main' into compose_migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Saifuddin53 authored Dec 28, 2024
2 parents d76fe12 + e1bb782 commit b931ea7
Show file tree
Hide file tree
Showing 13 changed files with 230 additions and 8 deletions.
23 changes: 23 additions & 0 deletions app/src/main/java/be/scri/helpers/DatabaseHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,27 @@ class DatabaseHelper(
}
return values
}

fun getNounKeywords(language: String): HashMap<String, MutableList<String>> {
val hashMap = HashMap<String, MutableList<String>>()
val dbFile = context.getDatabasePath("${language}LanguageData.sqlite")
val db = SQLiteDatabase.openDatabase(dbFile.path, null, SQLiteDatabase.OPEN_READONLY)
val cursor = db.rawQuery("SELECT * FROM nouns", null)

cursor.use {
if (cursor.moveToFirst()) {
do {
val key = cursor.getString(0).lowercase()
hashMap[key] = getNounKeyMaps(cursor)
} while (cursor.moveToNext())
}
}
return hashMap
}

fun getNounKeyMaps(cursor: Cursor): MutableList<String> {
val values = mutableListOf<String>()
values.add(cursor.getString(2))
return values
}
}
18 changes: 17 additions & 1 deletion app/src/main/java/be/scri/services/EnglishKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,32 +61,48 @@ class EnglishKeyboardIME : SimpleKeyboardIME("English") {
MyKeyboard.KEYCODE_DELETE -> {
handleKeycodeDelete()
keyboardView!!.invalidateAllKeys()
disableAutoSuggest()
}

MyKeyboard.KEYCODE_SHIFT -> {
super.handleKeyboardLetters(keyboardMode, keyboardView)
keyboardView!!.invalidateAllKeys()
disableAutoSuggest()
}

MyKeyboard.KEYCODE_ENTER -> {
handleKeycodeEnter()
disableAutoSuggest()
}

MyKeyboard.KEYCODE_MODE_CHANGE -> {
handleModeChange(keyboardMode, keyboardView, this)
disableAutoSuggest()
}

MyKeyboard.KEYCODE_SPACE -> {
handleElseCondition(code, keyboardMode, binding = null)
updateAutoSuggestText(nounTypeSuggestion)
}

else -> {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleElseCondition(code, keyboardMode, binding = null)
disableAutoSuggest()
} else {
handleElseCondition(code, keyboardMode, keyboardBinding, commandBarState = true)
disableAutoSuggest()
}
}
}

lastWord = getLastWordBeforeCursor()
Log.d("Debug", "$lastWord")
autosuggestEmojis = findEmojisForLastWord(emojiKeywords, lastWord)
nounTypeSuggestion = findNounTypeForLastWord(nounKeywords, lastWord)
Log.d("Debug", "$autosuggestEmojis")
Log.d("MY-TAG", "$nounTypeSuggestion")
updateButtonText(isAutoSuggestEnabled, autosuggestEmojis)

if (code != MyKeyboard.KEYCODE_SHIFT) {
super.updateShiftKeyState()
}
Expand Down
18 changes: 17 additions & 1 deletion app/src/main/java/be/scri/services/FrenchKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,32 +57,48 @@ class FrenchKeyboardIME : SimpleKeyboardIME("French") {
MyKeyboard.KEYCODE_DELETE -> {
handleKeycodeDelete()
keyboardView!!.invalidateAllKeys()
disableAutoSuggest()
}

MyKeyboard.KEYCODE_SHIFT -> {
super.handleKeyboardLetters(keyboardMode, keyboardView)
keyboardView!!.invalidateAllKeys()
disableAutoSuggest()
}

MyKeyboard.KEYCODE_ENTER -> {
handleKeycodeEnter()
disableAutoSuggest()
}

MyKeyboard.KEYCODE_MODE_CHANGE -> {
handleModeChange(keyboardMode, keyboardView, this)
disableAutoSuggest()
}

MyKeyboard.KEYCODE_SPACE -> {
handleElseCondition(code, keyboardMode, binding = null)
updateAutoSuggestText(nounTypeSuggestion)
}

else -> {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleElseCondition(code, keyboardMode, binding = null)
disableAutoSuggest()
} else {
handleElseCondition(code, keyboardMode, keyboardBinding, commandBarState = true)
disableAutoSuggest()
}
}
}

lastWord = getLastWordBeforeCursor()
Log.d("Debug", "$lastWord")
autosuggestEmojis = findEmojisForLastWord(emojiKeywords, lastWord)
nounTypeSuggestion = findNounTypeForLastWord(nounKeywords, lastWord)
Log.d("Debug", "$autosuggestEmojis")
Log.d("MY-TAG", "$nounTypeSuggestion")
updateButtonText(isAutoSuggestEnabled, autosuggestEmojis)

if (code != MyKeyboard.KEYCODE_SHIFT) {
super.updateShiftKeyState()
}
Expand Down
18 changes: 17 additions & 1 deletion app/src/main/java/be/scri/services/GermanKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,32 +65,48 @@ class GermanKeyboardIME : SimpleKeyboardIME("German") {
MyKeyboard.KEYCODE_DELETE -> {
handleKeycodeDelete()
keyboardView!!.invalidateAllKeys()
disableAutoSuggest()
}

MyKeyboard.KEYCODE_SHIFT -> {
super.handleKeyboardLetters(keyboardMode, keyboardView)
keyboardView!!.invalidateAllKeys()
disableAutoSuggest()
}

MyKeyboard.KEYCODE_ENTER -> {
handleKeycodeEnter()
disableAutoSuggest()
}

MyKeyboard.KEYCODE_MODE_CHANGE -> {
handleModeChange(keyboardMode, keyboardView, this)
disableAutoSuggest()
}

MyKeyboard.KEYCODE_SPACE -> {
handleElseCondition(code, keyboardMode, binding = null)
updateAutoSuggestText(nounTypeSuggestion)
}

else -> {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleElseCondition(code, keyboardMode, binding = null)
disableAutoSuggest()
} else {
handleElseCondition(code, keyboardMode, keyboardBinding, commandBarState = true)
disableAutoSuggest()
}
}
}

lastWord = getLastWordBeforeCursor()
Log.d("Debug", "$lastWord")
autosuggestEmojis = findEmojisForLastWord(emojiKeywords, lastWord)
nounTypeSuggestion = findNounTypeForLastWord(nounKeywords, lastWord)
Log.d("Debug", "$autosuggestEmojis")
Log.d("MY-TAG", "$nounTypeSuggestion")
updateButtonText(isAutoSuggestEnabled, autosuggestEmojis)

if (code != MyKeyboard.KEYCODE_SHIFT) {
super.updateShiftKeyState()
}
Expand Down
18 changes: 17 additions & 1 deletion app/src/main/java/be/scri/services/ItalianKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,32 +57,48 @@ class ItalianKeyboardIME : SimpleKeyboardIME("Italian") {
MyKeyboard.KEYCODE_DELETE -> {
handleKeycodeDelete()
keyboardView!!.invalidateAllKeys()
disableAutoSuggest()
}

MyKeyboard.KEYCODE_SHIFT -> {
super.handleKeyboardLetters(keyboardMode, keyboardView)
keyboardView!!.invalidateAllKeys()
disableAutoSuggest()
}

MyKeyboard.KEYCODE_ENTER -> {
handleKeycodeEnter()
disableAutoSuggest()
}

MyKeyboard.KEYCODE_MODE_CHANGE -> {
handleModeChange(keyboardMode, keyboardView, this)
disableAutoSuggest()
}

MyKeyboard.KEYCODE_SPACE -> {
handleElseCondition(code, keyboardMode, binding = null)
updateAutoSuggestText(nounTypeSuggestion)
}

else -> {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleElseCondition(code, keyboardMode, binding = null)
disableAutoSuggest()
} else {
handleElseCondition(code, keyboardMode, keyboardBinding, commandBarState = true)
disableAutoSuggest()
}
}
}

lastWord = getLastWordBeforeCursor()
Log.d("Debug", "$lastWord")
autosuggestEmojis = findEmojisForLastWord(emojiKeywords, lastWord)
nounTypeSuggestion = findNounTypeForLastWord(nounKeywords, lastWord)
Log.d("Debug", "$autosuggestEmojis")
Log.d("MY-TAG", "$nounTypeSuggestion")
updateButtonText(isAutoSuggestEnabled, autosuggestEmojis)

if (code != MyKeyboard.KEYCODE_SHIFT) {
super.updateShiftKeyState()
}
Expand Down
18 changes: 17 additions & 1 deletion app/src/main/java/be/scri/services/PortugueseKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,32 +57,48 @@ class PortugueseKeyboardIME : SimpleKeyboardIME("Portuguese") {
MyKeyboard.KEYCODE_DELETE -> {
handleKeycodeDelete()
keyboardView!!.invalidateAllKeys()
disableAutoSuggest()
}

MyKeyboard.KEYCODE_SHIFT -> {
super.handleKeyboardLetters(keyboardMode, keyboardView)
keyboardView!!.invalidateAllKeys()
disableAutoSuggest()
}

MyKeyboard.KEYCODE_ENTER -> {
handleKeycodeEnter()
disableAutoSuggest()
}

MyKeyboard.KEYCODE_MODE_CHANGE -> {
handleModeChange(keyboardMode, keyboardView, this)
disableAutoSuggest()
}

MyKeyboard.KEYCODE_SPACE -> {
handleElseCondition(code, keyboardMode, binding = null)
updateAutoSuggestText(nounTypeSuggestion)
}

else -> {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleElseCondition(code, keyboardMode, binding = null)
disableAutoSuggest()
} else {
handleElseCondition(code, keyboardMode, keyboardBinding, commandBarState = true)
disableAutoSuggest()
}
}
}

lastWord = getLastWordBeforeCursor()
Log.d("Debug", "$lastWord")
autosuggestEmojis = findEmojisForLastWord(emojiKeywords, lastWord)
nounTypeSuggestion = findNounTypeForLastWord(nounKeywords, lastWord)
Log.d("Debug", "$autosuggestEmojis")
Log.d("MY-TAG", "$nounTypeSuggestion")
updateButtonText(isAutoSuggestEnabled, autosuggestEmojis)

if (code != MyKeyboard.KEYCODE_SHIFT) {
super.updateShiftKeyState()
}
Expand Down
18 changes: 17 additions & 1 deletion app/src/main/java/be/scri/services/RussianKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,32 +57,48 @@ class RussianKeyboardIME : SimpleKeyboardIME("Russian") {
MyKeyboard.KEYCODE_DELETE -> {
handleKeycodeDelete()
keyboardView!!.invalidateAllKeys()
disableAutoSuggest()
}

MyKeyboard.KEYCODE_SHIFT -> {
super.handleKeyboardLetters(keyboardMode, keyboardView)
keyboardView!!.invalidateAllKeys()
disableAutoSuggest()
}

MyKeyboard.KEYCODE_ENTER -> {
handleKeycodeEnter()
disableAutoSuggest()
}

MyKeyboard.KEYCODE_MODE_CHANGE -> {
handleModeChange(keyboardMode, keyboardView, this)
disableAutoSuggest()
}

MyKeyboard.KEYCODE_SPACE -> {
handleElseCondition(code, keyboardMode, binding = null)
updateAutoSuggestText(nounTypeSuggestion)
}

else -> {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleElseCondition(code, keyboardMode, binding = null)
disableAutoSuggest()
} else {
handleElseCondition(code, keyboardMode, keyboardBinding, commandBarState = true)
disableAutoSuggest()
}
}
}

lastWord = getLastWordBeforeCursor()
Log.d("Debug", "$lastWord")
autosuggestEmojis = findEmojisForLastWord(emojiKeywords, lastWord)
nounTypeSuggestion = findNounTypeForLastWord(nounKeywords, lastWord)
Log.d("Debug", "$autosuggestEmojis")
Log.d("MY-TAG", "$nounTypeSuggestion")
updateButtonText(isAutoSuggestEnabled, autosuggestEmojis)

if (code != MyKeyboard.KEYCODE_SHIFT) {
super.updateShiftKeyState()
}
Expand Down
Loading

0 comments on commit b931ea7

Please sign in to comment.