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
3 changes: 3 additions & 0 deletions app/src/keyboards/java/be/scri/services/EnglishKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class EnglishKeyboardIME : GeneralKeyboardIME("English") {
else -> R.xml.keys_letters_english_without_period_and_comma
}

override val defaultConjugateModeType: String = "2x2"
override val defaultConjugateLayoutXML: Int = R.xml.conjugate_view_2x2

override val keyboardLetters: Int = 0
override val keyboardSymbols: Int = 1
override val keyboardSymbolShift: Int = 2
Expand Down
25 changes: 9 additions & 16 deletions app/src/keyboards/java/be/scri/services/GeneralKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ abstract class GeneralKeyboardIME(
abstract var enterKeyType: Int
abstract var switchToLetters: Boolean

// Language-specific layout and behavior configurations (decoupled from base class).
open val defaultConjugateModeType: String = "3x2"
open val defaultConjugateLayoutXML: Int = R.xml.conjugate_view_3x2
open val isPluralCapitalized: Boolean = false

/**
* Property used by EnglishKeyboardIME override.
* We define a custom getter here for the base logic, but subclasses can override the field.
Expand Down Expand Up @@ -756,20 +761,11 @@ abstract class GeneralKeyboardIME(
* @param isSubsequentArea true if this is for a secondary view.
*/
internal fun saveConjugateModeType(
language: String,
language: String = this.language,
isSubsequentArea: Boolean = false,
) {
val sharedPref = applicationContext.getSharedPreferences("keyboard_preferences", MODE_PRIVATE)
val mode =
if (!isSubsequentArea) {
when (language) {
"English", "Russian", "Swedish" -> "2x2"
"German", "French", "Italian", "Portuguese", "Spanish" -> "3x2"
else -> "none"
}
} else {
"none"
}
val mode = if (!isSubsequentArea) defaultConjugateModeType else "none"
sharedPref.edit { putString("conjugate_mode_type", mode) }
}

Expand Down Expand Up @@ -853,7 +849,7 @@ abstract class GeneralKeyboardIME(
override fun onPluralClicked() {
currentState = ScribeState.PLURAL
saveConjugateModeType("none")
if (language == "German") keyboard?.mShiftState = SHIFT_ON_ONE_CHAR
if (isPluralCapitalized) keyboard?.mShiftState = SHIFT_ON_ONE_CHAR
refreshUI()
}

Expand Down Expand Up @@ -2077,10 +2073,7 @@ abstract class GeneralKeyboardIME(
ScribeState.SELECT_VERB_CONJUNCTION -> {
saveConjugateModeType(language)
if (!isSubsequentArea && dataSize == 0) {
when (language) {
"English", "Russian", "Swedish" -> R.xml.conjugate_view_2x2
else -> R.xml.conjugate_view_3x2
}
defaultConjugateLayoutXML
} else {
when (dataSize) {
DATA_SIZE_2 -> R.xml.conjugate_view_2x1
Expand Down
2 changes: 2 additions & 0 deletions app/src/keyboards/java/be/scri/services/GermanKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class GermanKeyboardIME : GeneralKeyboardIME("German") {
R.xml.keys_letter_german_without_period_and_comma
}

override val isPluralCapitalized: Boolean = true

// Fulfill the abstract contract from GeneralKeyboardIME.
override val keyboardLetters: Int = 0
override val keyboardSymbols: Int = 1
Expand Down
3 changes: 3 additions & 0 deletions app/src/keyboards/java/be/scri/services/RussianKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class RussianKeyboardIME : GeneralKeyboardIME("Russian") {
else -> R.xml.keys_letters_russian_without_period_and_comma
}

override val defaultConjugateModeType: String = "2x2"
override val defaultConjugateLayoutXML: Int = R.xml.conjugate_view_2x2

override val keyboardLetters: Int = 0
override val keyboardSymbols: Int = 1
override val keyboardSymbolShift: Int = 2
Expand Down
3 changes: 3 additions & 0 deletions app/src/keyboards/java/be/scri/services/SwedishKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class SwedishKeyboardIME : GeneralKeyboardIME("Swedish") {
R.xml.keys_letter_swedish_without_period_and_comma
}

override val defaultConjugateModeType: String = "2x2"
override val defaultConjugateLayoutXML: Int = R.xml.conjugate_view_2x2

override val keyboardLetters: Int = 0
override val keyboardSymbols: Int = 1
override val keyboardSymbolShift: Int = 2
Expand Down
Loading