diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 5c73feda3..70528c77d 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -136,7 +136,7 @@ android {
flavorDimensions.add("variants")
sourceSets {
- getByName("main").java.srcDirs("src/main/kotlin")
+ getByName("main").java.srcDirs("src/main/java", "src/main/kotlin")
named("test") {
java.srcDirs("src/test/java", "src/test/kotlin")
}
diff --git a/app/src/androidTestKeyboards/kotlin/be/scri/helpers/KeyboardTest.kt b/app/src/androidTestKeyboards/kotlin/be/scri/helpers/KeyboardTest.kt
index 8e88881c8..09e31f4f1 100644
--- a/app/src/androidTestKeyboards/kotlin/be/scri/helpers/KeyboardTest.kt
+++ b/app/src/androidTestKeyboards/kotlin/be/scri/helpers/KeyboardTest.kt
@@ -5,8 +5,8 @@ import android.view.KeyEvent
import android.view.inputmethod.InputConnection
import android.widget.Button
import androidx.test.ext.junit.runners.AndroidJUnit4
+import be.scri.models.ScribeState
import be.scri.services.GeneralKeyboardIME
-import be.scri.services.GeneralKeyboardIME.ScribeState
import io.mockk.every
import io.mockk.mockk
import io.mockk.verify
diff --git a/app/src/keyboards/AndroidManifest.xml b/app/src/keyboards/AndroidManifest.xml
new file mode 100644
index 000000000..b7e6101df
--- /dev/null
+++ b/app/src/keyboards/AndroidManifest.xml
@@ -0,0 +1,111 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/java/be/scri/helpers/AutocompletionHandler.kt b/app/src/keyboards/java/be/scri/helpers/AutocompletionHandler.kt
similarity index 97%
rename from app/src/main/java/be/scri/helpers/AutocompletionHandler.kt
rename to app/src/keyboards/java/be/scri/helpers/AutocompletionHandler.kt
index 616a84c92..7a3308046 100644
--- a/app/src/main/java/be/scri/helpers/AutocompletionHandler.kt
+++ b/app/src/keyboards/java/be/scri/helpers/AutocompletionHandler.kt
@@ -5,7 +5,7 @@ package be.scri.helpers
import android.os.Handler
import android.os.Looper
import be.scri.services.GeneralKeyboardIME
-import be.scri.services.GeneralKeyboardIME.ScribeState
+import be.scri.models.ScribeState
/**
* Handles autocompletion when user is typing.
diff --git a/app/src/main/java/be/scri/helpers/BackspaceHandler.kt b/app/src/keyboards/java/be/scri/helpers/BackspaceHandler.kt
similarity index 98%
rename from app/src/main/java/be/scri/helpers/BackspaceHandler.kt
rename to app/src/keyboards/java/be/scri/helpers/BackspaceHandler.kt
index b9794e10b..e5eb546a1 100644
--- a/app/src/main/java/be/scri/helpers/BackspaceHandler.kt
+++ b/app/src/keyboards/java/be/scri/helpers/BackspaceHandler.kt
@@ -5,6 +5,7 @@ package be.scri.helpers
import android.text.TextUtils
import android.view.inputmethod.InputConnection
import be.scri.helpers.PreferencesHelper.getIsWordByWordDeletionEnabled
+import be.scri.models.ScribeState
import be.scri.services.GeneralKeyboardIME
import be.scri.services.GeneralKeyboardIME.Companion.MAX_TEXT_LENGTH
@@ -91,7 +92,7 @@ class BackspaceHandler(
val finalCommandBarText = ime.getCommandBarTextWithoutCursor()
val isEmptyOrAHint = finalCommandBarText.isEmpty() || finalCommandBarText == ime.currentCommandBarHint
val isGerman = ime.language == "German"
- val isPluralState = ime.currentState == GeneralKeyboardIME.ScribeState.PLURAL
+ val isPluralState = ime.currentState == ScribeState.PLURAL
if (isEmptyOrAHint && isGerman && isPluralState) {
ime.keyboard?.mShiftState = SHIFT_ON_ONE_CHAR
diff --git a/app/src/main/java/be/scri/helpers/KeyHandler.kt b/app/src/keyboards/java/be/scri/helpers/KeyHandler.kt
similarity index 99%
rename from app/src/main/java/be/scri/helpers/KeyHandler.kt
rename to app/src/keyboards/java/be/scri/helpers/KeyHandler.kt
index 928e29790..5deb78645 100644
--- a/app/src/main/java/be/scri/helpers/KeyHandler.kt
+++ b/app/src/keyboards/java/be/scri/helpers/KeyHandler.kt
@@ -6,7 +6,7 @@ import android.content.Context
import android.util.Log
import android.view.inputmethod.InputConnection
import be.scri.services.GeneralKeyboardIME
-import be.scri.services.GeneralKeyboardIME.ScribeState
+import be.scri.models.ScribeState
/**
* Handles key events for the [GeneralKeyboardIME].
diff --git a/app/src/keyboards/java/be/scri/helpers/KeyboardLanguageMappingConstants.kt b/app/src/keyboards/java/be/scri/helpers/KeyboardLanguageMappingConstants.kt
new file mode 100644
index 000000000..28984886f
--- /dev/null
+++ b/app/src/keyboards/java/be/scri/helpers/KeyboardLanguageMappingConstants.kt
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+package be.scri.helpers
+
+import be.scri.helpers.english.ENInterfaceVariables
+import be.scri.helpers.french.FRInterfaceVariables
+import be.scri.helpers.german.DEInterfaceVariables
+import be.scri.helpers.italian.ITInterfaceVariables
+import be.scri.helpers.portuguese.PTInterfaceVariables
+import be.scri.helpers.russian.RUInterfaceVariables
+import be.scri.helpers.spanish.ESInterfaceVariables
+import be.scri.helpers.swedish.SVInterfaceVariables
+
+/**
+ * Object containing keyboard-specific constant mappings related to language-specific UI elements.
+ */
+object KeyboardLanguageMappingConstants {
+ val translatePlaceholder =
+ mapOf(
+ "EN" to ENInterfaceVariables.TRANSLATE_KEY_LBL,
+ "ES" to ESInterfaceVariables.TRANSLATE_KEY_LBL,
+ "DE" to DEInterfaceVariables.TRANSLATE_KEY_LBL,
+ "IT" to ITInterfaceVariables.TRANSLATE_KEY_LBL,
+ "FR" to FRInterfaceVariables.TRANSLATE_KEY_LBL,
+ "PT" to PTInterfaceVariables.TRANSLATE_KEY_LBL,
+ "RU" to RUInterfaceVariables.TRANSLATE_KEY_LBL,
+ "SV" to SVInterfaceVariables.TRANSLATE_KEY_LBL,
+ )
+
+ val conjugatePlaceholder =
+ mapOf(
+ "EN" to ENInterfaceVariables.CONJUGATE_KEY_LBL,
+ "ES" to ESInterfaceVariables.CONJUGATE_KEY_LBL,
+ "DE" to DEInterfaceVariables.CONJUGATE_KEY_LBL,
+ "IT" to ITInterfaceVariables.CONJUGATE_KEY_LBL,
+ "FR" to FRInterfaceVariables.CONJUGATE_KEY_LBL,
+ "PT" to PTInterfaceVariables.CONJUGATE_KEY_LBL,
+ "RU" to RUInterfaceVariables.CONJUGATE_KEY_LBL,
+ "SV" to SVInterfaceVariables.CONJUGATE_KEY_LBL,
+ )
+
+ val pluralPlaceholder =
+ mapOf(
+ "EN" to ENInterfaceVariables.PLURAL_KEY_LBL,
+ "ES" to ESInterfaceVariables.PLURAL_KEY_LBL,
+ "DE" to DEInterfaceVariables.PLURAL_KEY_LBL,
+ "IT" to ITInterfaceVariables.PLURAL_KEY_LBL,
+ "FR" to FRInterfaceVariables.PLURAL_KEY_LBL,
+ "PT" to PTInterfaceVariables.PLURAL_KEY_LBL,
+ "RU" to RUInterfaceVariables.PLURAL_KEY_LBL,
+ "SV" to SVInterfaceVariables.PLURAL_KEY_LBL,
+ )
+}
diff --git a/app/src/main/java/be/scri/helpers/SpaceKeyProcessor.kt b/app/src/keyboards/java/be/scri/helpers/SpaceKeyProcessor.kt
similarity index 99%
rename from app/src/main/java/be/scri/helpers/SpaceKeyProcessor.kt
rename to app/src/keyboards/java/be/scri/helpers/SpaceKeyProcessor.kt
index eaaef4558..0d9d0f1ca 100644
--- a/app/src/main/java/be/scri/helpers/SpaceKeyProcessor.kt
+++ b/app/src/keyboards/java/be/scri/helpers/SpaceKeyProcessor.kt
@@ -3,7 +3,7 @@
package be.scri.helpers
import be.scri.services.GeneralKeyboardIME
-import be.scri.services.GeneralKeyboardIME.ScribeState
+import be.scri.models.ScribeState
/**
* Processes key events specifically related to the space key.
diff --git a/app/src/main/java/be/scri/helpers/SuggestionHandler.kt b/app/src/keyboards/java/be/scri/helpers/SuggestionHandler.kt
similarity index 99%
rename from app/src/main/java/be/scri/helpers/SuggestionHandler.kt
rename to app/src/keyboards/java/be/scri/helpers/SuggestionHandler.kt
index 57b44deed..48774e30b 100644
--- a/app/src/main/java/be/scri/helpers/SuggestionHandler.kt
+++ b/app/src/keyboards/java/be/scri/helpers/SuggestionHandler.kt
@@ -5,7 +5,7 @@ package be.scri.helpers
import android.os.Handler
import android.os.Looper
import be.scri.services.GeneralKeyboardIME
-import be.scri.services.GeneralKeyboardIME.ScribeState
+import be.scri.models.ScribeState
/**
* Handles auto-suggestions such as noun gender, plurality, case, and emojis.
diff --git a/app/src/main/java/be/scri/helpers/english/ENInterfaceVariables.kt b/app/src/keyboards/java/be/scri/helpers/english/ENInterfaceVariables.kt
similarity index 100%
rename from app/src/main/java/be/scri/helpers/english/ENInterfaceVariables.kt
rename to app/src/keyboards/java/be/scri/helpers/english/ENInterfaceVariables.kt
diff --git a/app/src/main/java/be/scri/helpers/french/FRInterfaceVariables.kt b/app/src/keyboards/java/be/scri/helpers/french/FRInterfaceVariables.kt
similarity index 100%
rename from app/src/main/java/be/scri/helpers/french/FRInterfaceVariables.kt
rename to app/src/keyboards/java/be/scri/helpers/french/FRInterfaceVariables.kt
diff --git a/app/src/main/java/be/scri/helpers/german/DEInterfaceVariables.kt b/app/src/keyboards/java/be/scri/helpers/german/DEInterfaceVariables.kt
similarity index 100%
rename from app/src/main/java/be/scri/helpers/german/DEInterfaceVariables.kt
rename to app/src/keyboards/java/be/scri/helpers/german/DEInterfaceVariables.kt
diff --git a/app/src/main/java/be/scri/helpers/italian/ITInterfaceVariables.kt b/app/src/keyboards/java/be/scri/helpers/italian/ITInterfaceVariables.kt
similarity index 100%
rename from app/src/main/java/be/scri/helpers/italian/ITInterfaceVariables.kt
rename to app/src/keyboards/java/be/scri/helpers/italian/ITInterfaceVariables.kt
diff --git a/app/src/main/java/be/scri/helpers/portuguese/PTInterfaceVariables.kt b/app/src/keyboards/java/be/scri/helpers/portuguese/PTInterfaceVariables.kt
similarity index 100%
rename from app/src/main/java/be/scri/helpers/portuguese/PTInterfaceVariables.kt
rename to app/src/keyboards/java/be/scri/helpers/portuguese/PTInterfaceVariables.kt
diff --git a/app/src/main/java/be/scri/helpers/russian/RUInterfaceVariables.kt b/app/src/keyboards/java/be/scri/helpers/russian/RUInterfaceVariables.kt
similarity index 100%
rename from app/src/main/java/be/scri/helpers/russian/RUInterfaceVariables.kt
rename to app/src/keyboards/java/be/scri/helpers/russian/RUInterfaceVariables.kt
diff --git a/app/src/main/java/be/scri/helpers/spanish/ESInterfaceVariables.kt b/app/src/keyboards/java/be/scri/helpers/spanish/ESInterfaceVariables.kt
similarity index 100%
rename from app/src/main/java/be/scri/helpers/spanish/ESInterfaceVariables.kt
rename to app/src/keyboards/java/be/scri/helpers/spanish/ESInterfaceVariables.kt
diff --git a/app/src/main/java/be/scri/helpers/swedish/SVInterfaceVariables.kt b/app/src/keyboards/java/be/scri/helpers/swedish/SVInterfaceVariables.kt
similarity index 100%
rename from app/src/main/java/be/scri/helpers/swedish/SVInterfaceVariables.kt
rename to app/src/keyboards/java/be/scri/helpers/swedish/SVInterfaceVariables.kt
diff --git a/app/src/main/java/be/scri/helpers/ui/HintUtils.kt b/app/src/keyboards/java/be/scri/helpers/ui/HintUtils.kt
similarity index 94%
rename from app/src/main/java/be/scri/helpers/ui/HintUtils.kt
rename to app/src/keyboards/java/be/scri/helpers/ui/HintUtils.kt
index 45a2cb7e9..5210e371f 100644
--- a/app/src/main/java/be/scri/helpers/ui/HintUtils.kt
+++ b/app/src/keyboards/java/be/scri/helpers/ui/HintUtils.kt
@@ -12,7 +12,7 @@ import be.scri.helpers.portuguese.PTInterfaceVariables
import be.scri.helpers.russian.RUInterfaceVariables
import be.scri.helpers.spanish.ESInterfaceVariables
import be.scri.helpers.swedish.SVInterfaceVariables
-import be.scri.services.GeneralKeyboardIME
+import be.scri.models.ScribeState
import kotlin.collections.get
/**
@@ -47,12 +47,12 @@ object HintUtils {
* @return The appropriate hint message for the given state and language.
*/
fun getCommandBarHint(
- currentState: GeneralKeyboardIME.ScribeState,
+ currentState: ScribeState,
language: String,
word: String?,
): String =
when (currentState) {
- GeneralKeyboardIME.ScribeState.SELECT_VERB_CONJUNCTION -> word ?: ""
+ ScribeState.SELECT_VERB_CONJUNCTION -> word ?: ""
else -> getHintForState(currentState)[language] ?: ""
}
@@ -63,11 +63,11 @@ object HintUtils {
*
* @return A map of language codes to hint strings for the current state.
*/
- private fun getHintForState(currentState: GeneralKeyboardIME.ScribeState): Map =
+ private fun getHintForState(currentState: ScribeState): Map =
when (currentState) {
- GeneralKeyboardIME.ScribeState.TRANSLATE -> getTranslateHints()
- GeneralKeyboardIME.ScribeState.CONJUGATE -> getConjugateHints()
- GeneralKeyboardIME.ScribeState.PLURAL -> getPluralHints()
+ ScribeState.TRANSLATE -> getTranslateHints()
+ ScribeState.CONJUGATE -> getConjugateHints()
+ ScribeState.PLURAL -> getPluralHints()
else -> emptyMap()
}
@@ -311,16 +311,16 @@ object HintUtils {
* @return The appropriate prompt text for the given state and language.
*/
fun getPromptText(
- currentState: GeneralKeyboardIME.ScribeState,
+ currentState: ScribeState,
language: String,
context: Context,
text: String?,
): String =
when (currentState) {
- GeneralKeyboardIME.ScribeState.TRANSLATE -> getTranslationPrompt(language, context)
- GeneralKeyboardIME.ScribeState.CONJUGATE -> getConjugationPrompt(language)
- GeneralKeyboardIME.ScribeState.PLURAL -> getPluralPrompt(language)
- GeneralKeyboardIME.ScribeState.SELECT_VERB_CONJUNCTION -> text!!
+ ScribeState.TRANSLATE -> getTranslationPrompt(language, context)
+ ScribeState.CONJUGATE -> getConjugationPrompt(language)
+ ScribeState.PLURAL -> getPluralPrompt(language)
+ ScribeState.SELECT_VERB_CONJUNCTION -> text!!
else -> ""
}
diff --git a/app/src/main/java/be/scri/helpers/ui/KeyboardUIManager.kt b/app/src/keyboards/java/be/scri/helpers/ui/KeyboardUIManager.kt
similarity index 99%
rename from app/src/main/java/be/scri/helpers/ui/KeyboardUIManager.kt
rename to app/src/keyboards/java/be/scri/helpers/ui/KeyboardUIManager.kt
index 928a94523..2d25db93e 100644
--- a/app/src/main/java/be/scri/helpers/ui/KeyboardUIManager.kt
+++ b/app/src/keyboards/java/be/scri/helpers/ui/KeyboardUIManager.kt
@@ -22,15 +22,15 @@ import be.scri.R
import be.scri.R.color.white
import be.scri.databinding.InputMethodViewBinding
import be.scri.helpers.KeyboardBase
-import be.scri.helpers.LanguageMappingConstants.conjugatePlaceholder
+import be.scri.helpers.KeyboardLanguageMappingConstants.conjugatePlaceholder
import be.scri.helpers.LanguageMappingConstants.getLanguageAlias
-import be.scri.helpers.LanguageMappingConstants.pluralPlaceholder
-import be.scri.helpers.LanguageMappingConstants.translatePlaceholder
+import be.scri.helpers.KeyboardLanguageMappingConstants.pluralPlaceholder
+import be.scri.helpers.KeyboardLanguageMappingConstants.translatePlaceholder
import be.scri.helpers.PreferencesHelper
import be.scri.helpers.PreferencesHelper.getIsDarkModeOrNot
import be.scri.helpers.english.ENInterfaceVariables.ALREADY_PLURAL_MSG
+import be.scri.models.ScribeState
import be.scri.services.GeneralKeyboardIME
-import be.scri.services.GeneralKeyboardIME.ScribeState
import be.scri.views.KeyboardView
/**
diff --git a/app/src/main/java/be/scri/services/EnglishKeyboardIME.kt b/app/src/keyboards/java/be/scri/services/EnglishKeyboardIME.kt
similarity index 100%
rename from app/src/main/java/be/scri/services/EnglishKeyboardIME.kt
rename to app/src/keyboards/java/be/scri/services/EnglishKeyboardIME.kt
diff --git a/app/src/main/java/be/scri/services/FrenchKeyboardIME.kt b/app/src/keyboards/java/be/scri/services/FrenchKeyboardIME.kt
similarity index 100%
rename from app/src/main/java/be/scri/services/FrenchKeyboardIME.kt
rename to app/src/keyboards/java/be/scri/services/FrenchKeyboardIME.kt
diff --git a/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt b/app/src/keyboards/java/be/scri/services/GeneralKeyboardIME.kt
similarity index 99%
rename from app/src/main/java/be/scri/services/GeneralKeyboardIME.kt
rename to app/src/keyboards/java/be/scri/services/GeneralKeyboardIME.kt
index 60bad4b9a..0d7346a77 100644
--- a/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt
+++ b/app/src/keyboards/java/be/scri/services/GeneralKeyboardIME.kt
@@ -57,6 +57,7 @@ import be.scri.helpers.SuggestionHandler
import be.scri.helpers.data.AutocompletionDataManager
import be.scri.helpers.english.ENInterfaceVariables.ALREADY_PLURAL_MSG
import be.scri.helpers.ui.KeyboardUIManager
+import be.scri.models.ScribeState
import be.scri.views.KeyboardView
import java.util.Locale
@@ -65,14 +66,15 @@ private const val DATA_CONSTANT_3 = 3
@Suppress("TooManyFunctions", "LargeClass")
abstract class GeneralKeyboardIME(
- var language: String,
+ override var language: String,
) : InputMethodService(),
KeyboardView.OnKeyboardActionListener,
- KeyboardUIManager.KeyboardUIListener {
+ KeyboardUIManager.KeyboardUIListener,
+ KeyboardBase.KeyboardContextProvider {
// Abstract members required by subclasses (like EnglishKeyboardIME)
abstract override fun getKeyboardLayoutXML(): Int
- abstract val keyboardLetters: Int
+ abstract override val keyboardLetters: Int
abstract val keyboardSymbols: Int
abstract val keyboardSymbolShift: Int
@@ -83,7 +85,7 @@ abstract class GeneralKeyboardIME(
lateinit var uiManager: KeyboardUIManager
abstract var lastShiftPressTS: Long
- abstract var keyboardMode: Int
+ abstract override var keyboardMode: Int
abstract var inputTypeClass: Int
abstract var enterKeyType: Int
abstract var switchToLetters: Boolean
@@ -175,7 +177,7 @@ abstract class GeneralKeyboardIME(
internal const val CUSTOM_CURSOR = "│" // special tall cursor character
}
- enum class ScribeState { IDLE, SELECT_COMMAND, TRANSLATE, CONJUGATE, PLURAL, SELECT_VERB_CONJUNCTION, INVALID, ALREADY_PLURAL }
+
// MARK: Lifecycle Methods
@@ -470,7 +472,7 @@ abstract class GeneralKeyboardIME(
*
* @return true if the current input field is likely a search or address bar, false otherwise.
*/
- fun isSearchBar(): Boolean {
+ override fun isSearchBar(): Boolean {
val editorInfo = currentInputEditorInfo
val isActionSearch = (enterKeyType == EditorInfo.IME_ACTION_SEARCH)
val isUriType = editorInfo?.let { (it.inputType and InputType.TYPE_TEXT_VARIATION_URI) != 0 } == true
@@ -929,7 +931,7 @@ abstract class GeneralKeyboardIME(
* Sets the flag to indicate that the delete key is currently repeating (long press).
* Delegated to BackspaceHandler.
*/
- fun setDeleteRepeating(repeating: Boolean) {
+ override fun setDeleteRepeating(repeating: Boolean) {
backspaceHandler.isDeleteRepeating = repeating
}
diff --git a/app/src/main/java/be/scri/services/GermanKeyboardIME.kt b/app/src/keyboards/java/be/scri/services/GermanKeyboardIME.kt
similarity index 100%
rename from app/src/main/java/be/scri/services/GermanKeyboardIME.kt
rename to app/src/keyboards/java/be/scri/services/GermanKeyboardIME.kt
diff --git a/app/src/main/java/be/scri/services/ItalianKeyboardIME.kt b/app/src/keyboards/java/be/scri/services/ItalianKeyboardIME.kt
similarity index 100%
rename from app/src/main/java/be/scri/services/ItalianKeyboardIME.kt
rename to app/src/keyboards/java/be/scri/services/ItalianKeyboardIME.kt
diff --git a/app/src/main/java/be/scri/services/PortugueseKeyboardIME.kt b/app/src/keyboards/java/be/scri/services/PortugueseKeyboardIME.kt
similarity index 100%
rename from app/src/main/java/be/scri/services/PortugueseKeyboardIME.kt
rename to app/src/keyboards/java/be/scri/services/PortugueseKeyboardIME.kt
diff --git a/app/src/main/java/be/scri/services/RussianKeyboardIME.kt b/app/src/keyboards/java/be/scri/services/RussianKeyboardIME.kt
similarity index 100%
rename from app/src/main/java/be/scri/services/RussianKeyboardIME.kt
rename to app/src/keyboards/java/be/scri/services/RussianKeyboardIME.kt
diff --git a/app/src/main/java/be/scri/services/SpanishKeyboardIME.kt b/app/src/keyboards/java/be/scri/services/SpanishKeyboardIME.kt
similarity index 100%
rename from app/src/main/java/be/scri/services/SpanishKeyboardIME.kt
rename to app/src/keyboards/java/be/scri/services/SpanishKeyboardIME.kt
diff --git a/app/src/main/java/be/scri/services/SwedishKeyboardIME.kt b/app/src/keyboards/java/be/scri/services/SwedishKeyboardIME.kt
similarity index 100%
rename from app/src/main/java/be/scri/services/SwedishKeyboardIME.kt
rename to app/src/keyboards/java/be/scri/services/SwedishKeyboardIME.kt
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index da738c606..05c327083 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -31,112 +31,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/java/be/scri/helpers/KeyboardBase.kt b/app/src/main/java/be/scri/helpers/KeyboardBase.kt
index bfc98dcf3..550348096 100644
--- a/app/src/main/java/be/scri/helpers/KeyboardBase.kt
+++ b/app/src/main/java/be/scri/helpers/KeyboardBase.kt
@@ -16,7 +16,6 @@ import android.view.inputmethod.EditorInfo
import android.view.inputmethod.EditorInfo.IME_ACTION_NONE
import androidx.annotation.XmlRes
import be.scri.R
-import be.scri.services.GeneralKeyboardIME
import org.xmlpull.v1.XmlPullParserException
import java.io.IOException
import kotlin.math.roundToInt
@@ -28,6 +27,17 @@ import kotlin.math.roundToInt
*/
@Suppress("LongMethod", "NestedBlockDepth", "CyclomaticComplexMethod")
class KeyboardBase {
+
+ /**
+ * Interface for providing keyboard context to KeyboardBase without
+ * a direct dependency on GeneralKeyboardIME.
+ */
+ interface KeyboardContextProvider {
+ val language: String
+ val keyboardMode: Int
+ val keyboardLetters: Int
+ fun isSearchBar(): Boolean
+ }
/** Horizontal gap default for all rows */
private var mDefaultHorizontalGap = 0
@@ -532,13 +542,13 @@ class KeyboardBase {
var currentRow: Row? = null
val res = context.resources
- // Get the IME instance to check the current keyboard mode.
- val imeInstance = context as? GeneralKeyboardIME
- val language = imeInstance?.language
- val currentKeyboardMode = imeInstance?.keyboardMode
- val keyboardLettersMode = imeInstance?.keyboardLetters
+ // Get the keyboard context provider if available.
+ val provider = context as? KeyboardContextProvider
+ val language = provider?.language
+ val currentKeyboardMode = provider?.keyboardMode
+ val keyboardLettersMode = provider?.keyboardLetters
- val isSearchBar = imeInstance?.isSearchBar() == true
+ val isSearchBar = provider?.isSearchBar() == true
val periodAndCommaEnabled: Boolean =
if (language != null) {
PreferencesHelper.getEnablePeriodAndCommaABC(context, language)
diff --git a/app/src/main/java/be/scri/helpers/LanguageMappingConstants.kt b/app/src/main/java/be/scri/helpers/LanguageMappingConstants.kt
index 5826aed93..9e9d2108f 100644
--- a/app/src/main/java/be/scri/helpers/LanguageMappingConstants.kt
+++ b/app/src/main/java/be/scri/helpers/LanguageMappingConstants.kt
@@ -1,18 +1,10 @@
// SPDX-License-Identifier: GPL-3.0-or-later
package be.scri.helpers
-import be.scri.helpers.english.ENInterfaceVariables
-import be.scri.helpers.french.FRInterfaceVariables
-import be.scri.helpers.german.DEInterfaceVariables
-import be.scri.helpers.italian.ITInterfaceVariables
-import be.scri.helpers.portuguese.PTInterfaceVariables
-import be.scri.helpers.russian.RUInterfaceVariables
-import be.scri.helpers.spanish.ESInterfaceVariables
-import be.scri.helpers.swedish.SVInterfaceVariables
-
/**
- * Object containing constant mappings related to language-specific data and UI elements.
- * This includes conversions for grammatical annotations and placeholders for UI text.
+ * Object containing constant mappings related to language-specific data.
+ * This includes conversions for grammatical annotations.
+ * Keyboard-specific UI placeholders are in KeyboardLanguageMappingConstants.
*/
object LanguageMappingConstants {
val prepAnnotationConversionDict =
@@ -35,42 +27,6 @@ object LanguageMappingConstants {
"Russian" to mapOf("F" to "Ж", "M" to "М", "N" to "Н"),
)
- val translatePlaceholder =
- mapOf(
- "EN" to ENInterfaceVariables.TRANSLATE_KEY_LBL,
- "ES" to ESInterfaceVariables.TRANSLATE_KEY_LBL,
- "DE" to DEInterfaceVariables.TRANSLATE_KEY_LBL,
- "IT" to ITInterfaceVariables.TRANSLATE_KEY_LBL,
- "FR" to FRInterfaceVariables.TRANSLATE_KEY_LBL,
- "PT" to PTInterfaceVariables.TRANSLATE_KEY_LBL,
- "RU" to RUInterfaceVariables.TRANSLATE_KEY_LBL,
- "SV" to SVInterfaceVariables.TRANSLATE_KEY_LBL,
- )
-
- val conjugatePlaceholder =
- mapOf(
- "EN" to ENInterfaceVariables.CONJUGATE_KEY_LBL,
- "ES" to ESInterfaceVariables.CONJUGATE_KEY_LBL,
- "DE" to DEInterfaceVariables.CONJUGATE_KEY_LBL,
- "IT" to ITInterfaceVariables.CONJUGATE_KEY_LBL,
- "FR" to FRInterfaceVariables.CONJUGATE_KEY_LBL,
- "PT" to PTInterfaceVariables.CONJUGATE_KEY_LBL,
- "RU" to RUInterfaceVariables.CONJUGATE_KEY_LBL,
- "SV" to SVInterfaceVariables.CONJUGATE_KEY_LBL,
- )
-
- val pluralPlaceholder =
- mapOf(
- "EN" to ENInterfaceVariables.PLURAL_KEY_LBL,
- "ES" to ESInterfaceVariables.PLURAL_KEY_LBL,
- "DE" to DEInterfaceVariables.PLURAL_KEY_LBL,
- "IT" to ITInterfaceVariables.PLURAL_KEY_LBL,
- "FR" to FRInterfaceVariables.PLURAL_KEY_LBL,
- "PT" to PTInterfaceVariables.PLURAL_KEY_LBL,
- "RU" to RUInterfaceVariables.PLURAL_KEY_LBL,
- "SV" to SVInterfaceVariables.PLURAL_KEY_LBL,
- )
-
/**
* Converts a full language name (e.g., "English") to its two-letter ISO alias (e.g., "EN").
*
diff --git a/app/src/main/java/be/scri/helpers/PreferencesHelper.kt b/app/src/main/java/be/scri/helpers/PreferencesHelper.kt
index f5da00b11..de367de9a 100644
--- a/app/src/main/java/be/scri/helpers/PreferencesHelper.kt
+++ b/app/src/main/java/be/scri/helpers/PreferencesHelper.kt
@@ -592,4 +592,19 @@ object PreferencesHelper {
val sharedPref = context.getSharedPreferences(SCRIBE_PREFS, Context.MODE_PRIVATE)
return sharedPref.getBoolean(getLanguageSpecificPreferenceKey(HOLD_FOR_ALT_KEYS, language), true)
}
+
+ /**
+ * Resets the application hints, marking them as not shown in the shared preferences.
+ *
+ * @param context The context used to access shared preferences.
+ */
+ fun resetHints(context: Context) {
+ val sharedPref = context.getSharedPreferences("app_preferences", Context.MODE_PRIVATE)
+ with(sharedPref.edit()) {
+ putBoolean("hint_shown_main", false)
+ putBoolean("hint_shown_settings", false)
+ putBoolean("hint_shown_about", false)
+ apply()
+ }
+ }
}
diff --git a/app/src/main/java/be/scri/models/ScribeState.kt b/app/src/main/java/be/scri/models/ScribeState.kt
new file mode 100644
index 000000000..83782d670
--- /dev/null
+++ b/app/src/main/java/be/scri/models/ScribeState.kt
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+package be.scri.models
+
+/**
+ * Represents the various states of the Scribe keyboard command system.
+ */
+enum class ScribeState {
+ IDLE,
+ SELECT_COMMAND,
+ TRANSLATE,
+ CONJUGATE,
+ PLURAL,
+ SELECT_VERB_CONJUNCTION,
+ INVALID,
+ ALREADY_PLURAL,
+}
diff --git a/app/src/main/java/be/scri/ui/screens/about/AboutScreen.kt b/app/src/main/java/be/scri/ui/screens/about/AboutScreen.kt
index f5d18c700..6410c7da2 100644
--- a/app/src/main/java/be/scri/ui/screens/about/AboutScreen.kt
+++ b/app/src/main/java/be/scri/ui/screens/about/AboutScreen.kt
@@ -16,7 +16,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import be.scri.R
-import be.scri.helpers.ui.HintUtils
+import be.scri.helpers.PreferencesHelper
import be.scri.ui.common.ScribeBaseScreen
import be.scri.ui.common.components.ItemCardContainerWithTitle
import be.scri.ui.screens.about.AboutUtil.getCommunityList
@@ -52,7 +52,7 @@ fun AboutScreen(
onRateScribeClick = { AboutUtil.onRateScribeClick(context) },
onMailClick = { AboutUtil.onMailClick(context) },
onResetHintsClick = {
- HintUtils.resetHints(context)
+ PreferencesHelper.resetHints(context)
resetHints()
},
context = context,
diff --git a/app/src/main/java/be/scri/views/KeyboardView.kt b/app/src/main/java/be/scri/views/KeyboardView.kt
index 3ae1787df..fd9372cf5 100644
--- a/app/src/main/java/be/scri/views/KeyboardView.kt
+++ b/app/src/main/java/be/scri/views/KeyboardView.kt
@@ -67,8 +67,7 @@ import be.scri.helpers.MAX_KEYS_PER_MINI_ROW
import be.scri.helpers.SHIFT_OFF
import be.scri.helpers.SHIFT_ON_ONE_CHAR
import be.scri.helpers.SHIFT_ON_PERMANENT
-import be.scri.services.GeneralKeyboardIME
-import be.scri.services.GeneralKeyboardIME.ScribeState
+import be.scri.models.ScribeState
import java.util.Arrays
import java.util.Locale
@@ -137,6 +136,12 @@ class KeyboardView
* Enters a period after a space character, used in double-tap space bar scenarios.
*/
fun commitPeriodAfterSpace()
+
+ /**
+ * Sets the delete repeating state. Default no-op for implementations
+ * that don't need delete repeat tracking.
+ */
+ fun setDeleteRepeating(isRepeating: Boolean) {}
}
var mKeyboard: KeyboardBase? = null
@@ -1544,7 +1549,7 @@ class KeyboardView
val key = mKeys[mRepeatKeyIndex]
if (key.code == KEYCODE_DELETE) {
mHandler?.removeMessages(MSG_REPEAT)
- (mOnKeyboardActionListener as? GeneralKeyboardIME)?.setDeleteRepeating(false)
+ mOnKeyboardActionListener?.setDeleteRepeating(false)
mRepeatKeyIndex = NOT_A_KEY
}
}
@@ -1727,7 +1732,7 @@ class KeyboardView
if (mAbortKey) {
// Reset delete repeating flag when key is aborted.
if (mRepeatKeyIndex != NOT_A_KEY && mKeys[mRepeatKeyIndex].code == KEYCODE_DELETE) {
- (mOnKeyboardActionListener as? GeneralKeyboardIME)?.setDeleteRepeating(false)
+ mOnKeyboardActionListener?.setDeleteRepeating(false)
}
mRepeatKeyIndex = NOT_A_KEY
handled = true
@@ -1840,7 +1845,7 @@ class KeyboardView
invalidateKey(keyIndex)
// Reset delete repeating flag when any key is released.
if (mRepeatKeyIndex != NOT_A_KEY && mKeys[mRepeatKeyIndex].code == KEYCODE_DELETE) {
- (mOnKeyboardActionListener as? GeneralKeyboardIME)?.setDeleteRepeating(false)
+ mOnKeyboardActionListener?.setDeleteRepeating(false)
}
mRepeatKeyIndex = NOT_A_KEY
mOnKeyboardActionListener!!.onActionUp()
@@ -1851,7 +1856,7 @@ class KeyboardView
mLastSpaceMoveX = 0
// Reset delete repeating flag when action is cancelled.
if (mRepeatKeyIndex != NOT_A_KEY && mKeys[mRepeatKeyIndex].code == KEYCODE_DELETE) {
- (mOnKeyboardActionListener as? GeneralKeyboardIME)?.setDeleteRepeating(false)
+ mOnKeyboardActionListener?.setDeleteRepeating(false)
}
removeMessages()
dismissPopupKeyboard()
@@ -1879,7 +1884,7 @@ class KeyboardView
} else {
// Set delete repeating flag when repeat actually starts (not on initial press).
if (!initialCall && key.code == KEYCODE_DELETE) {
- (mOnKeyboardActionListener as? GeneralKeyboardIME)?.setDeleteRepeating(true)
+ mOnKeyboardActionListener?.setDeleteRepeating(true)
}
detectAndSendKey(mCurrentKey, key.x, key.y, mLastTapTime)
}
diff --git a/app/src/test/kotlin/be/scri/ui/screens/about/AboutUtilTest.kt b/app/src/test/kotlin/be/scri/ui/screens/about/AboutUtilTest.kt
index de752c3fc..054e09f72 100644
--- a/app/src/test/kotlin/be/scri/ui/screens/about/AboutUtilTest.kt
+++ b/app/src/test/kotlin/be/scri/ui/screens/about/AboutUtilTest.kt
@@ -5,7 +5,7 @@ import android.content.Context
import android.content.Intent
import be.scri.R
import be.scri.activities.MainActivity
-import be.scri.helpers.ui.HintUtils
+import be.scri.helpers.PreferencesHelper
import be.scri.helpers.ui.RatingHelper
import be.scri.helpers.ui.ShareHelper
import be.scri.helpers.ui.ShareHelperInterface
@@ -146,11 +146,11 @@ class AboutUtilTest {
}
@Test
- fun `onResetHintsClick calls HintUtils resetHints`() {
+ fun `onResetHintsClick calls PreferencesHelper resetHints`() {
val mockContext = mockk(relaxed = true)
- mockkObject(HintUtils)
+ mockkObject(PreferencesHelper)
- every { HintUtils.resetHints(mockContext) } returns Unit
+ every { PreferencesHelper.resetHints(mockContext) } returns Unit
var called = false
val list =
@@ -160,13 +160,13 @@ class AboutUtilTest {
onMailClick = {},
onResetHintsClick = {
called = true
- HintUtils.resetHints(mockContext)
+ PreferencesHelper.resetHints(mockContext)
},
)
list[4].onClick()
- verify(exactly = 1) { HintUtils.resetHints(mockContext) }
+ verify(exactly = 1) { PreferencesHelper.resetHints(mockContext) }
assertTrue(called)
}
}
diff --git a/app/src/test/kotlin/be/scri/helpers/ui/KeyboardUIManagerTest.kt b/app/src/testKeyboards/kotlin/be/scri/helpers/ui/KeyboardUIManagerTest.kt
similarity index 99%
rename from app/src/test/kotlin/be/scri/helpers/ui/KeyboardUIManagerTest.kt
rename to app/src/testKeyboards/kotlin/be/scri/helpers/ui/KeyboardUIManagerTest.kt
index c5818c0a7..abf0b4e1f 100644
--- a/app/src/test/kotlin/be/scri/helpers/ui/KeyboardUIManagerTest.kt
+++ b/app/src/testKeyboards/kotlin/be/scri/helpers/ui/KeyboardUIManagerTest.kt
@@ -8,7 +8,7 @@ import android.view.View
import androidx.test.core.app.ApplicationProvider
import be.scri.databinding.InputMethodViewBinding
import be.scri.helpers.ui.KeyboardUIManager.KeyboardUIListener
-import be.scri.services.GeneralKeyboardIME.ScribeState
+import be.scri.models.ScribeState
import io.mockk.every
import io.mockk.mockk
import io.mockk.verify