diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index bc5817108..137de7027 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -138,7 +138,15 @@ android {
sourceSets {
- getByName("main").java.srcDirs("src/main/kotlin")
+ getByName("main") {
+ java.srcDirs("src/main/kotlin")
+ }
+ getByName("keyboards") {
+ java.srcDirs("src/keyboards/java")
+ }
+ getByName("conjugate") {
+ java.srcDirs("src/conjugate/java")
+ }
named("test") {
java.srcDirs("src/test/java", "src/test/kotlin")
}
diff --git a/app/src/keyboards/AndroidManifest.xml b/app/src/keyboards/AndroidManifest.xml
new file mode 100644
index 000000000..e4ec47c48
--- /dev/null
+++ b/app/src/keyboards/AndroidManifest.xml
@@ -0,0 +1,111 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/java/be/scri/helpers/AlphanumericComparator.kt b/app/src/keyboards/java/be/scri/helpers/AlphanumericComparator.kt
similarity index 100%
rename from app/src/main/java/be/scri/helpers/AlphanumericComparator.kt
rename to app/src/keyboards/java/be/scri/helpers/AlphanumericComparator.kt
diff --git a/app/src/main/java/be/scri/helpers/AnnotationTextUtils.kt b/app/src/keyboards/java/be/scri/helpers/AnnotationTextUtils.kt
similarity index 100%
rename from app/src/main/java/be/scri/helpers/AnnotationTextUtils.kt
rename to app/src/keyboards/java/be/scri/helpers/AnnotationTextUtils.kt
diff --git a/app/src/main/java/be/scri/helpers/AutocompletionHandler.kt b/app/src/keyboards/java/be/scri/helpers/AutocompletionHandler.kt
similarity index 100%
rename from app/src/main/java/be/scri/helpers/AutocompletionHandler.kt
rename to app/src/keyboards/java/be/scri/helpers/AutocompletionHandler.kt
diff --git a/app/src/main/java/be/scri/helpers/BackspaceHandler.kt b/app/src/keyboards/java/be/scri/helpers/BackspaceHandler.kt
similarity index 92%
rename from app/src/main/java/be/scri/helpers/BackspaceHandler.kt
rename to app/src/keyboards/java/be/scri/helpers/BackspaceHandler.kt
index b9794e10b..e8154bc0b 100644
--- a/app/src/main/java/be/scri/helpers/BackspaceHandler.kt
+++ b/app/src/keyboards/java/be/scri/helpers/BackspaceHandler.kt
@@ -1,19 +1,15 @@
-// SPDX-License-Identifier: GPL-3.0-or-later
-
package be.scri.helpers
import android.text.TextUtils
import android.view.inputmethod.InputConnection
-import be.scri.helpers.PreferencesHelper.getIsWordByWordDeletionEnabled
import be.scri.services.GeneralKeyboardIME
-import be.scri.services.GeneralKeyboardIME.Companion.MAX_TEXT_LENGTH
/**
- * Handles backspace/delete events for the [GeneralKeyboardIME].
+ * Handles backspace/delete events for the [be.scri.services.GeneralKeyboardIME].
* Encapsulates logic for single character deletion, word-by-word deletion,
* command bar deletion, and repeating delete state.
*
- * @property ime The [GeneralKeyboardIME] instance this handler is associated with.
+ * @property ime The [be.scri.services.GeneralKeyboardIME] instance this handler is associated with.
*/
class BackspaceHandler(
private val ime: GeneralKeyboardIME,
@@ -46,7 +42,10 @@ class BackspaceHandler(
} else {
val inputConnection = ime.currentInputConnection ?: return
if (TextUtils.isEmpty(inputConnection.getSelectedText(0))) {
- val isWordByWordEnabled = getIsWordByWordDeletionEnabled(ime.applicationContext, ime.language)
+ val isWordByWordEnabled = PreferencesHelper.getIsWordByWordDeletionEnabled(
+ ime.applicationContext,
+ ime.language
+ )
// Only use word-by-word deletion on long press when the feature is enabled.
if (isWordByWordEnabled && isLongPress) {
deleteWordByWord(inputConnection)
@@ -104,7 +103,7 @@ class BackspaceHandler(
* @param inputConnection The current input connection.
*/
private fun deleteWordByWord(inputConnection: InputConnection) {
- val textBeforeCursor = inputConnection.getTextBeforeCursor(MAX_TEXT_LENGTH, 0)?.toString() ?: ""
+ val textBeforeCursor = inputConnection.getTextBeforeCursor(GeneralKeyboardIME.Companion.MAX_TEXT_LENGTH, 0)?.toString() ?: ""
if (textBeforeCursor.isEmpty()) {
return
diff --git a/app/src/main/java/be/scri/helpers/Constants.kt b/app/src/keyboards/java/be/scri/helpers/Constants.kt
similarity index 100%
rename from app/src/main/java/be/scri/helpers/Constants.kt
rename to app/src/keyboards/java/be/scri/helpers/Constants.kt
diff --git a/app/src/main/java/be/scri/helpers/EmojiUtils.kt b/app/src/keyboards/java/be/scri/helpers/EmojiUtils.kt
similarity index 98%
rename from app/src/main/java/be/scri/helpers/EmojiUtils.kt
rename to app/src/keyboards/java/be/scri/helpers/EmojiUtils.kt
index 8b333b018..78e0546c8 100644
--- a/app/src/main/java/be/scri/helpers/EmojiUtils.kt
+++ b/app/src/keyboards/java/be/scri/helpers/EmojiUtils.kt
@@ -1,4 +1,3 @@
-// SPDX-License-Identifier: GPL-3.0-or-later
package be.scri.helpers
import android.view.inputmethod.InputConnection
diff --git a/app/src/main/java/be/scri/helpers/KeyHandler.kt b/app/src/keyboards/java/be/scri/helpers/KeyHandler.kt
similarity index 93%
rename from app/src/main/java/be/scri/helpers/KeyHandler.kt
rename to app/src/keyboards/java/be/scri/helpers/KeyHandler.kt
index 928e29790..d1b8935cc 100644
--- a/app/src/main/java/be/scri/helpers/KeyHandler.kt
+++ b/app/src/keyboards/java/be/scri/helpers/KeyHandler.kt
@@ -1,20 +1,17 @@
-// SPDX-License-Identifier: GPL-3.0-or-later
-
package be.scri.helpers
import android.content.Context
import android.util.Log
import android.view.inputmethod.InputConnection
import be.scri.services.GeneralKeyboardIME
-import be.scri.services.GeneralKeyboardIME.ScribeState
/**
- * Handles key events for the [GeneralKeyboardIME].
+ * Handles key events for the [be.scri.services.GeneralKeyboardIME].
* This class processes raw key codes, determines the appropriate action based on the
* current keyboard state and the key pressed, and delegates to specific handlers
- * or directly interacts with the [GeneralKeyboardIME] instance.
+ * or directly interacts with the [be.scri.services.GeneralKeyboardIME] instance.
*
- * @property ime The [GeneralKeyboardIME] instance this handler is associated with.
+ * @property ime The [be.scri.services.GeneralKeyboardIME] instance this handler is associated with.
*/
@Suppress("TooManyFunctions")
class KeyHandler(
@@ -174,7 +171,7 @@ class KeyHandler(
* @param inputConnection The active input connection.
*/
private fun commitTab(inputConnection: InputConnection) {
- inputConnection.commitText("\t", GeneralKeyboardIME.COMMIT_TEXT_CURSOR_POSITION)
+ inputConnection.commitText("\t", GeneralKeyboardIME.Companion.COMMIT_TEXT_CURSOR_POSITION)
}
/**
@@ -203,7 +200,7 @@ class KeyHandler(
private fun handleDeleteKey() {
ime.handleDelete(ime.isDeleteRepeating()) // pass the actual repeating status
- if (ime.currentState == ScribeState.IDLE) {
+ if (ime.currentState == GeneralKeyboardIME.ScribeState.IDLE) {
val currentWord = ime.getLastWordBeforeCursor()
autocompletionHandler.processAutocomplete(currentWord)
suggestionHandler.processEmojiSuggestions(currentWord)
@@ -218,7 +215,7 @@ class KeyHandler(
ime.currentInputConnection?.commitText(currencySymbol, 1)
// Process emoji suggestions if in idle state.
- if (ime.currentState == ScribeState.IDLE) {
+ if (ime.currentState == GeneralKeyboardIME.ScribeState.IDLE) {
suggestionHandler.processEmojiSuggestions(ime.getLastWordBeforeCursor())
}
}
@@ -257,10 +254,10 @@ class KeyHandler(
private fun handleNavigationKey(code: Int) {
val isRight = code == KeyboardBase.KEYCODE_RIGHT_ARROW
ime.currentInputConnection?.let { ic ->
- val currentPos = ic.getTextBeforeCursor(GeneralKeyboardIME.MAX_TEXT_LENGTH, 0)?.length ?: 0
+ val currentPos = ic.getTextBeforeCursor(GeneralKeyboardIME.Companion.MAX_TEXT_LENGTH, 0)?.length ?: 0
val newPos =
if (isRight) {
- val textAfter = ic.getTextAfterCursor(GeneralKeyboardIME.MAX_TEXT_LENGTH, 0)?.toString() ?: ""
+ val textAfter = ic.getTextAfterCursor(GeneralKeyboardIME.Companion.MAX_TEXT_LENGTH, 0)?.toString() ?: ""
(currentPos + 1).coerceAtMost(currentPos + textAfter.length)
} else {
(currentPos - 1).coerceAtLeast(0)
@@ -348,16 +345,16 @@ class KeyHandler(
private fun handleDefaultKey(code: Int) {
val isCommandBarActive =
when (ime.currentState) {
- ScribeState.TRANSLATE,
- ScribeState.CONJUGATE,
- ScribeState.PLURAL,
+ GeneralKeyboardIME.ScribeState.TRANSLATE,
+ GeneralKeyboardIME.ScribeState.CONJUGATE,
+ GeneralKeyboardIME.ScribeState.PLURAL,
-> true // use command bar for actual commands
else -> false // use main input field for IDLE and SELECT_COMMAND
}
ime.handleElseCondition(code, ime.keyboardMode, isCommandBarActive)
- if (ime.currentState == ScribeState.IDLE) {
+ if (ime.currentState == GeneralKeyboardIME.ScribeState.IDLE) {
val currentWord = ime.getLastWordBeforeCursor()
autocompletionHandler.processAutocomplete(currentWord)
suggestionHandler.processEmojiSuggestions(currentWord)
diff --git a/app/src/main/java/be/scri/helpers/KeyboardBase.kt b/app/src/keyboards/java/be/scri/helpers/KeyboardBase.kt
similarity index 99%
rename from app/src/main/java/be/scri/helpers/KeyboardBase.kt
rename to app/src/keyboards/java/be/scri/helpers/KeyboardBase.kt
index bfc98dcf3..56a2217b6 100644
--- a/app/src/main/java/be/scri/helpers/KeyboardBase.kt
+++ b/app/src/keyboards/java/be/scri/helpers/KeyboardBase.kt
@@ -1,5 +1,3 @@
-// SPDX-License-Identifier: GPL-3.0-or-later
-
package be.scri.helpers
import android.annotation.SuppressLint
@@ -13,7 +11,6 @@ import android.util.Log
import android.util.TypedValue
import android.util.Xml
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
@@ -53,7 +50,7 @@ class KeyboardBase {
private var mDisplayWidth = 0
/** What icon should we show at Enter key */
- var mEnterKeyType = IME_ACTION_NONE
+ var mEnterKeyType = EditorInfo.IME_ACTION_NONE
/** Keyboard rows */
private val mRows = ArrayList()
diff --git a/app/src/main/java/be/scri/helpers/SpaceKeyProcessor.kt b/app/src/keyboards/java/be/scri/helpers/SpaceKeyProcessor.kt
similarity index 94%
rename from app/src/main/java/be/scri/helpers/SpaceKeyProcessor.kt
rename to app/src/keyboards/java/be/scri/helpers/SpaceKeyProcessor.kt
index eaaef4558..dd02c5e1f 100644
--- a/app/src/main/java/be/scri/helpers/SpaceKeyProcessor.kt
+++ b/app/src/keyboards/java/be/scri/helpers/SpaceKeyProcessor.kt
@@ -1,16 +1,13 @@
-// SPDX-License-Identifier: GPL-3.0-or-later
-
package be.scri.helpers
import be.scri.services.GeneralKeyboardIME
-import be.scri.services.GeneralKeyboardIME.ScribeState
/**
* Processes key events specifically related to the space key.
* This includes handling "period on double tap" logic, committing spaces
* in normal input mode or command bar mode, and interacting with suggestions.
*
- * @property ime The [GeneralKeyboardIME] instance this processor is associated with.
+ * @property ime The [be.scri.services.GeneralKeyboardIME] instance this processor is associated with.
* @property suggestionHandler The [SuggestionHandler] to manage suggestions.
*/
class SpaceKeyProcessor(
@@ -28,8 +25,8 @@ class SpaceKeyProcessor(
*/
fun processKeycodeSpace(currentWasLastKeySpace: Boolean): Boolean {
val isCommandBar =
- ime.currentState != ScribeState.IDLE &&
- ime.currentState != ScribeState.SELECT_COMMAND
+ ime.currentState != GeneralKeyboardIME.ScribeState.IDLE &&
+ ime.currentState != GeneralKeyboardIME.ScribeState.SELECT_COMMAND
return if (isCommandBar) {
handleSpaceInCommandBar()
diff --git a/app/src/main/java/be/scri/helpers/SuggestionHandler.kt b/app/src/keyboards/java/be/scri/helpers/SuggestionHandler.kt
similarity index 93%
rename from app/src/main/java/be/scri/helpers/SuggestionHandler.kt
rename to app/src/keyboards/java/be/scri/helpers/SuggestionHandler.kt
index 57b44deed..386698012 100644
--- a/app/src/main/java/be/scri/helpers/SuggestionHandler.kt
+++ b/app/src/keyboards/java/be/scri/helpers/SuggestionHandler.kt
@@ -1,16 +1,13 @@
-// SPDX-License-Identifier: GPL-3.0-or-later
-
package be.scri.helpers
import android.os.Handler
import android.os.Looper
import be.scri.services.GeneralKeyboardIME
-import be.scri.services.GeneralKeyboardIME.ScribeState
/**
* Handles auto-suggestions such as noun gender, plurality, case, and emojis.
*
- * @property ime The [GeneralKeyboardIME] instance this handler is associated with.
+ * @property ime The [be.scri.services.GeneralKeyboardIME] instance this handler is associated with.
*/
class SuggestionHandler(
private val ime: GeneralKeyboardIME,
@@ -39,7 +36,7 @@ class SuggestionHandler(
linguisticSuggestionRunnable =
Runnable {
- if (ime.currentState != ScribeState.IDLE) {
+ if (ime.currentState != GeneralKeyboardIME.ScribeState.IDLE) {
clearAllSuggestionsAndHideButtonUI()
return@Runnable
}
@@ -80,7 +77,7 @@ class SuggestionHandler(
wordSuggestionRunnable =
Runnable {
- if (ime.currentState != ScribeState.IDLE) {
+ if (ime.currentState != GeneralKeyboardIME.ScribeState.IDLE) {
clearAllSuggestionsAndHideButtonUI()
return@Runnable
}
@@ -119,7 +116,7 @@ class SuggestionHandler(
emojiSuggestionRunnable =
Runnable {
- if (ime.currentState != ScribeState.IDLE) {
+ if (ime.currentState != GeneralKeyboardIME.ScribeState.IDLE) {
clearAllSuggestionsAndHideButtonUI()
return@Runnable
}
@@ -175,7 +172,7 @@ class SuggestionHandler(
ime.disableAutoSuggest()
- if (ime.currentState != ScribeState.SELECT_COMMAND) {
+ if (ime.currentState != GeneralKeyboardIME.ScribeState.SELECT_COMMAND) {
ime.updateButtonVisibility(false)
}
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 9eca291fa..c2f1a0f9d 100644
--- a/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt
+++ b/app/src/keyboards/java/be/scri/services/GeneralKeyboardIME.kt
@@ -52,7 +52,7 @@ import be.scri.helpers.SHIFT_ON_PERMANENT
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.ui.KeyboardUIManager
import be.scri.views.KeyboardView
import java.util.Locale
@@ -1418,7 +1418,7 @@ abstract class GeneralKeyboardIME(
backgroundRes: Int,
) {
button.text = text
- button.setTextColor(ContextCompat.getColor(applicationContext, be.scri.R.color.white))
+ button.setTextColor(ContextCompat.getColor(applicationContext, R.color.white))
button.isClickable = false
button.setOnClickListener(null)
@@ -1430,7 +1430,7 @@ abstract class GeneralKeyboardIME(
if (contentDrawable is LayerDrawable) {
val shapeDrawable =
contentDrawable.findDrawableByLayerId(
- be.scri.R.id.button_background_shape,
+ R.id.button_background_shape,
) as? GradientDrawable
shapeDrawable?.setColor(
@@ -1472,7 +1472,7 @@ abstract class GeneralKeyboardIME(
it,
leftSuggestion.first,
leftSuggestion.second,
- be.scri.R.drawable.gender_suggestion_button_left_background,
+ R.drawable.gender_suggestion_button_left_background,
)
}
@@ -1481,7 +1481,7 @@ abstract class GeneralKeyboardIME(
it,
rightSuggestion.first,
rightSuggestion.second,
- be.scri.R.drawable.gender_suggestion_button_right_background,
+ R.drawable.gender_suggestion_button_right_background,
)
}
}
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/java/be/scri/helpers/ui/KeyboardUIManager.kt b/app/src/keyboards/java/be/scri/ui/KeyboardUIManager.kt
similarity index 88%
rename from app/src/main/java/be/scri/helpers/ui/KeyboardUIManager.kt
rename to app/src/keyboards/java/be/scri/ui/KeyboardUIManager.kt
index cc95db4c0..e62325e39 100644
--- a/app/src/main/java/be/scri/helpers/ui/KeyboardUIManager.kt
+++ b/app/src/keyboards/java/be/scri/ui/KeyboardUIManager.kt
@@ -1,6 +1,4 @@
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-package be.scri.helpers.ui
+package be.scri.ui
import android.annotation.SuppressLint
import android.content.Context
@@ -19,18 +17,13 @@ import androidx.core.content.ContextCompat
import androidx.core.content.edit
import androidx.core.graphics.toColorInt
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.LanguageMappingConstants.getLanguageAlias
-import be.scri.helpers.LanguageMappingConstants.pluralPlaceholder
-import be.scri.helpers.LanguageMappingConstants.translatePlaceholder
+import be.scri.helpers.LanguageMappingConstants
import be.scri.helpers.PreferencesHelper
-import be.scri.helpers.PreferencesHelper.getIsDarkModeOrNot
-import be.scri.helpers.english.ENInterfaceVariables.ALREADY_PLURAL_MSG
+import be.scri.helpers.english.ENInterfaceVariables
+import be.scri.helpers.ui.HintUtils
import be.scri.services.GeneralKeyboardIME
-import be.scri.services.GeneralKeyboardIME.ScribeState
import be.scri.views.KeyboardView
/**
@@ -91,7 +84,7 @@ class KeyboardUIManager(
var currentCommandBarHint: String = ""
var commandBarHintColor: Int = Color.GRAY
var commandBarTextColor: Int = Color.BLACK
- private var earlierValue: Int? = keyboardView.setEnterKeyIcon(ScribeState.IDLE)
+ private var earlierValue: Int? = keyboardView.setEnterKeyIcon(GeneralKeyboardIME.ScribeState.IDLE)
private var currentPage = 0
private val totalPages = 3
@@ -128,17 +121,17 @@ class KeyboardUIManager(
*/
fun updateEnterKeyColor(
isDarkMode: Boolean?,
- currentState: ScribeState,
+ currentState: GeneralKeyboardIME.ScribeState,
) {
- val resolvedIsDarkMode = isDarkMode ?: getIsDarkModeOrNot(context)
+ val resolvedIsDarkMode = isDarkMode ?: PreferencesHelper.getIsDarkModeOrNot(context)
when (currentState) {
- ScribeState.IDLE, ScribeState.SELECT_COMMAND -> {
- keyboardView.setEnterKeyIcon(ScribeState.IDLE, earlierValue)
+ GeneralKeyboardIME.ScribeState.IDLE, GeneralKeyboardIME.ScribeState.SELECT_COMMAND -> {
+ keyboardView.setEnterKeyIcon(GeneralKeyboardIME.ScribeState.IDLE, earlierValue)
keyboardView.setEnterKeyColor(null, isDarkMode = resolvedIsDarkMode)
}
else -> {
keyboardView.setEnterKeyColor(context.getColor(R.color.color_primary))
- keyboardView.setEnterKeyIcon(ScribeState.PLURAL, earlierValue)
+ keyboardView.setEnterKeyIcon(GeneralKeyboardIME.ScribeState.PLURAL, earlierValue)
}
}
val scribeKeyTint = if (resolvedIsDarkMode) R.color.light_key_color else R.color.light_key_text_color
@@ -148,10 +141,10 @@ class KeyboardUIManager(
/**
* The main dispatcher for updating the entire keyboard UI. It calls the appropriate setup function
- * based on the current [ScribeState].
+ * based on the current [GeneralKeyboardIME.ScribeState].
*/
fun updateUI(
- currentState: ScribeState,
+ currentState: GeneralKeyboardIME.ScribeState,
language: String,
emojiAutoSuggestionEnabled: Boolean,
autoSuggestEmojis: MutableList?,
@@ -160,21 +153,23 @@ class KeyboardUIManager(
selectedConjugationSubCategory: String?,
currentVerbForConjugation: String?,
) {
- val isUserDarkMode = getIsDarkModeOrNot(context)
+ val isUserDarkMode = PreferencesHelper.getIsDarkModeOrNot(context)
when (currentState) {
- ScribeState.IDLE -> setupIdleView(language, emojiAutoSuggestionEnabled, autoSuggestEmojis)
- ScribeState.SELECT_COMMAND -> setupSelectCommandView(language)
- ScribeState.INVALID -> setupInvalidView(language)
- ScribeState.TRANSLATE -> {
+ GeneralKeyboardIME.ScribeState.IDLE -> setupIdleView(language, emojiAutoSuggestionEnabled, autoSuggestEmojis)
+ GeneralKeyboardIME.ScribeState.SELECT_COMMAND -> setupSelectCommandView(language)
+ GeneralKeyboardIME.ScribeState.INVALID -> setupInvalidView(language)
+ GeneralKeyboardIME.ScribeState.TRANSLATE -> {
setupToolbarView(currentState, language, conjugateOutput, conjugateLabels, selectedConjugationSubCategory, currentVerbForConjugation)
- binding.translateBtn.text = translatePlaceholder[getLanguageAlias(language)] ?: "Translate"
+ binding.translateBtn.text = LanguageMappingConstants.translatePlaceholder[LanguageMappingConstants.getLanguageAlias(
+ language
+ )] ?: "Translate"
binding.translateBtn.visibility = View.VISIBLE
}
- ScribeState.CONJUGATE, ScribeState.SELECT_VERB_CONJUNCTION, ScribeState.PLURAL -> {
+ GeneralKeyboardIME.ScribeState.CONJUGATE, GeneralKeyboardIME.ScribeState.SELECT_VERB_CONJUNCTION, GeneralKeyboardIME.ScribeState.PLURAL -> {
setupToolbarView(currentState, language, conjugateOutput, conjugateLabels, selectedConjugationSubCategory, currentVerbForConjugation)
}
- ScribeState.ALREADY_PLURAL -> setupAlreadyPluralView()
+ GeneralKeyboardIME.ScribeState.ALREADY_PLURAL -> setupAlreadyPluralView()
}
updateEnterKeyColor(isUserDarkMode, currentState)
@@ -191,7 +186,7 @@ class KeyboardUIManager(
binding.commandOptionsBar.visibility = View.VISIBLE
binding.toolbarBar.visibility = View.GONE
- val isUserDarkMode = getIsDarkModeOrNot(context)
+ val isUserDarkMode = PreferencesHelper.getIsDarkModeOrNot(context)
binding.commandOptionsBar.setBackgroundColor(
ContextCompat.getColor(
@@ -208,7 +203,7 @@ class KeyboardUIManager(
button.setTextColor(textColor)
button.text = HintUtils.getBaseAutoSuggestions(language).getOrNull(index)
button.isAllCaps = false
- button.textSize = GeneralKeyboardIME.SUGGESTION_SIZE
+ button.textSize = GeneralKeyboardIME.Companion.SUGGESTION_SIZE
button.setOnClickListener(null)
}
@@ -230,8 +225,8 @@ class KeyboardUIManager(
initializeKeyboard(listener.getKeyboardLayoutXML())
- updateButtonVisibility(ScribeState.IDLE, emojiAutoSuggestionEnabled, autoSuggestEmojis)
- updateEmojiSuggestion(ScribeState.IDLE, emojiAutoSuggestionEnabled, autoSuggestEmojis)
+ updateButtonVisibility(GeneralKeyboardIME.ScribeState.IDLE, emojiAutoSuggestionEnabled, autoSuggestEmojis)
+ updateEmojiSuggestion(GeneralKeyboardIME.ScribeState.IDLE, emojiAutoSuggestionEnabled, autoSuggestEmojis)
binding.commandBar.setText("")
disableAutoSuggest(language)
}
@@ -244,7 +239,7 @@ class KeyboardUIManager(
binding.commandOptionsBar.visibility = View.VISIBLE
binding.toolbarBar.visibility = View.GONE
- val isUserDarkMode = getIsDarkModeOrNot(context)
+ val isUserDarkMode = PreferencesHelper.getIsDarkModeOrNot(context)
binding.commandOptionsBar.setBackgroundColor(
ContextCompat.getColor(
context,
@@ -252,9 +247,9 @@ class KeyboardUIManager(
),
)
- val langAlias = getLanguageAlias(language)
+ val langAlias = LanguageMappingConstants.getLanguageAlias(language)
- updateButtonVisibility(ScribeState.SELECT_COMMAND, false, null)
+ updateButtonVisibility(GeneralKeyboardIME.ScribeState.SELECT_COMMAND, false, null)
binding.translateBtn.setOnClickListener { listener.onTranslateClicked() }
binding.conjugateBtn.setOnClickListener { listener.onConjugateClicked() }
@@ -267,14 +262,14 @@ class KeyboardUIManager(
button.background = ContextCompat.getDrawable(context, R.drawable.button_background_rounded)
button.backgroundTintList = ContextCompat.getColorStateList(context, R.color.theme_scribe_blue)
button.setTextColor(buttonTextColor)
- button.textSize = GeneralKeyboardIME.SUGGESTION_SIZE
+ button.textSize = GeneralKeyboardIME.Companion.SUGGESTION_SIZE
}
- binding.translateBtn.text = translatePlaceholder[langAlias] ?: "Translate"
- binding.conjugateBtn.text = conjugatePlaceholder[langAlias] ?: "Conjugate"
- binding.pluralBtn.text = pluralPlaceholder[langAlias] ?: "Plural"
+ binding.translateBtn.text = LanguageMappingConstants.translatePlaceholder[langAlias] ?: "Translate"
+ binding.conjugateBtn.text = LanguageMappingConstants.conjugatePlaceholder[langAlias] ?: "Conjugate"
+ binding.pluralBtn.text = LanguageMappingConstants.pluralPlaceholder[langAlias] ?: "Plural"
- val separatorColor = (if (isUserDarkMode) GeneralKeyboardIME.DARK_THEME else GeneralKeyboardIME.LIGHT_THEME).toColorInt()
+ val separatorColor = (if (isUserDarkMode) GeneralKeyboardIME.Companion.DARK_THEME else GeneralKeyboardIME.Companion.LIGHT_THEME).toColorInt()
binding.separator2.setBackgroundColor(separatorColor)
binding.separator3.setBackgroundColor(separatorColor)
@@ -302,7 +297,7 @@ class KeyboardUIManager(
*/
@SuppressLint("InflateParams")
private fun setupToolbarView(
- currentState: ScribeState,
+ currentState: GeneralKeyboardIME.ScribeState,
language: String,
conjugateOutput: Map>>?,
conjugateLabels: Set?,
@@ -311,7 +306,7 @@ class KeyboardUIManager(
) {
binding.commandOptionsBar.visibility = View.GONE
binding.toolbarBar.visibility = View.VISIBLE
- val isDarkMode = getIsDarkModeOrNot(context)
+ val isDarkMode = PreferencesHelper.getIsDarkModeOrNot(context)
binding.toolbarBar.setBackgroundColor(
ContextCompat.getColor(
context,
@@ -325,7 +320,7 @@ class KeyboardUIManager(
var hintWord: String? = null
var promptText: String? = null
- if (currentState == ScribeState.SELECT_VERB_CONJUNCTION) {
+ if (currentState == GeneralKeyboardIME.ScribeState.SELECT_VERB_CONJUNCTION) {
binding.conjugateGridContainer.visibility = View.VISIBLE
binding.keyboardView.visibility = View.GONE
@@ -462,7 +457,7 @@ class KeyboardUIManager(
// Original logic: Invalid state actually uses the toolbarBar layout initially.
binding.invalidInfoBar.visibility = View.GONE
- val isDarkMode = getIsDarkModeOrNot(context)
+ val isDarkMode = PreferencesHelper.getIsDarkModeOrNot(context)
// Restore original logic: Set background on toolbarBar, not invalidInfoBar.
binding.toolbarBar.setBackgroundColor(
@@ -483,10 +478,10 @@ class KeyboardUIManager(
private fun setupAlreadyPluralView() {
binding.commandOptionsBar.visibility = View.GONE
binding.toolbarBar.visibility = View.VISIBLE
- val isDarkMode = getIsDarkModeOrNot(context)
+ val isDarkMode = PreferencesHelper.getIsDarkModeOrNot(context)
binding.toolbarBar.setBackgroundColor(if (isDarkMode) "#1E1E1E".toColorInt() else "#d2d4da".toColorInt())
binding.ivInfo.visibility = View.VISIBLE
- binding.promptText.text = "$ALREADY_PLURAL_MSG: "
+ binding.promptText.text = "${ENInterfaceVariables.ALREADY_PLURAL_MSG}: "
binding.commandBar.hint = ""
binding.scribeKeyToolbar.foreground = AppCompatResources.getDrawable(context, R.drawable.ic_scribe_icon_vector)
}
@@ -502,20 +497,21 @@ class KeyboardUIManager(
*/
@SuppressLint("SetTextI18n")
fun updateCommandBarHintAndPrompt(
- currentState: ScribeState,
+ currentState: GeneralKeyboardIME.ScribeState,
language: String,
text: String? = null,
isUserDarkMode: Boolean? = null,
word: String? = null,
currentVerbForConjugation: String? = null,
) {
- val resolvedIsDarkMode = isUserDarkMode ?: getIsDarkModeOrNot(context)
+ val resolvedIsDarkMode = isUserDarkMode ?: PreferencesHelper.getIsDarkModeOrNot(context)
val commandBarEditText = binding.commandBar
val promptTextView = binding.promptText
- commandBarHintColor = if (resolvedIsDarkMode) context.getColor(R.color.hint_white) else context.getColor(R.color.hint_black)
- commandBarTextColor = if (resolvedIsDarkMode) context.getColor(white) else Color.BLACK
- val backgroundColor = if (resolvedIsDarkMode) R.color.command_bar_color_dark else white
+ commandBarHintColor = if (resolvedIsDarkMode) context.getColor(R.color.hint_white) else context.getColor(
+ R.color.hint_black)
+ commandBarTextColor = if (resolvedIsDarkMode) context.getColor(R.color.white) else Color.BLACK
+ val backgroundColor = if (resolvedIsDarkMode) R.color.command_bar_color_dark else R.color.white
binding.commandBarLayout.backgroundTintList = ContextCompat.getColorStateList(context, backgroundColor)
val promptTextStr = HintUtils.getPromptText(currentState, language, context, text)
@@ -523,7 +519,7 @@ class KeyboardUIManager(
promptTextView.setTextColor(commandBarTextColor)
promptTextView.setBackgroundColor(context.getColor(backgroundColor))
- if (currentState == ScribeState.SELECT_VERB_CONJUNCTION) {
+ if (currentState == GeneralKeyboardIME.ScribeState.SELECT_VERB_CONJUNCTION) {
val verbInfinitive = currentVerbForConjugation ?: ""
commandBarEditText.setText(": $verbInfinitive")
commandBarEditText.setTextColor(commandBarTextColor)
@@ -559,7 +555,7 @@ class KeyboardUIManager(
*/
fun setupCurrencySymbol(language: String) {
val currencySymbol = PreferencesHelper.getDefaultCurrencySymbol(context, language)
- keyboardView.setKeyLabel(currencySymbol, "", KeyboardBase.CODE_CURRENCY)
+ keyboardView.setKeyLabel(currencySymbol, "", KeyboardBase.Companion.CODE_CURRENCY)
}
/**
@@ -582,11 +578,11 @@ class KeyboardUIManager(
* and whether auto-suggestions are currently active.
*/
fun updateButtonVisibility(
- currentState: ScribeState,
+ currentState: GeneralKeyboardIME.ScribeState,
isAutoSuggestEnabled: Boolean,
autoSuggestEmojis: MutableList?,
) {
- if (currentState != ScribeState.IDLE) {
+ if (currentState != GeneralKeyboardIME.ScribeState.IDLE) {
setupDefaultButtonVisibility()
return
}
@@ -708,11 +704,11 @@ class KeyboardUIManager(
* @param autoSuggestEmojis The list of emojis to display.
*/
fun updateEmojiSuggestion(
- currentState: ScribeState,
+ currentState: GeneralKeyboardIME.ScribeState,
isAutoSuggestEnabled: Boolean,
autoSuggestEmojis: MutableList?,
) {
- if (currentState != ScribeState.IDLE) return
+ if (currentState != GeneralKeyboardIME.ScribeState.IDLE) return
val tabletButtons = listOf(binding.emojiBtnTablet1, binding.emojiBtnTablet2, binding.emojiBtnTablet3)
val phoneButtons = listOf(binding.emojiBtnPhone1, binding.emojiBtnPhone2)
@@ -777,8 +773,8 @@ class KeyboardUIManager(
* @param button The button to style.
*/
private fun handleTextSizeForSuggestion(button: Button) {
- button.textSize = GeneralKeyboardIME.SUGGESTION_SIZE
- val isUserDarkMode = getIsDarkModeOrNot(context)
+ button.textSize = GeneralKeyboardIME.Companion.SUGGESTION_SIZE
+ val isUserDarkMode = PreferencesHelper.getIsDarkModeOrNot(context)
val colorRes = if (isUserDarkMode) R.color.white else android.R.color.black
button.setTextColor(ContextCompat.getColor(context, colorRes))
}
@@ -794,7 +790,7 @@ class KeyboardUIManager(
cursorAtStart: Boolean = false,
) {
if (cursorAtStart) {
- val hintWithCursor = GeneralKeyboardIME.CUSTOM_CURSOR + text
+ val hintWithCursor = GeneralKeyboardIME.Companion.CUSTOM_CURSOR + text
val spannable = SpannableString(hintWithCursor)
spannable.setSpan(
ForegroundColorSpan(commandBarTextColor),
@@ -804,7 +800,7 @@ class KeyboardUIManager(
)
binding.commandBar.setText(spannable, TextView.BufferType.SPANNABLE)
} else {
- val textWithCursor = text + GeneralKeyboardIME.CUSTOM_CURSOR
+ val textWithCursor = text + GeneralKeyboardIME.Companion.CUSTOM_CURSOR
binding.commandBar.setText(textWithCursor)
}
binding.commandBar.setSelection(binding.commandBar.text.length)
@@ -818,8 +814,8 @@ class KeyboardUIManager(
internal fun getCommandBarTextWithoutCursor(): String {
val currentText = binding.commandBar.text.toString()
return when {
- currentText.startsWith(GeneralKeyboardIME.CUSTOM_CURSOR) -> currentText.drop(1)
- currentText.endsWith(GeneralKeyboardIME.CUSTOM_CURSOR) -> currentText.dropLast(1)
+ currentText.startsWith(GeneralKeyboardIME.Companion.CUSTOM_CURSOR) -> currentText.drop(1)
+ currentText.endsWith(GeneralKeyboardIME.Companion.CUSTOM_CURSOR) -> currentText.dropLast(1)
else -> currentText
}
}
diff --git a/app/src/main/java/be/scri/views/KeyboardView.kt b/app/src/keyboards/java/be/scri/views/KeyboardView.kt
similarity index 100%
rename from app/src/main/java/be/scri/views/KeyboardView.kt
rename to app/src/keyboards/java/be/scri/views/KeyboardView.kt
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index da738c606..36cb3f27e 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -32,111 +32,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/test/kotlin/be/scri/helpers/ui/KeyboardUIManagerTest.kt b/app/src/test/kotlin/be/scri/helpers/ui/KeyboardUIManagerTest.kt
index 04d1cf85a..353aa484c 100644
--- a/app/src/test/kotlin/be/scri/helpers/ui/KeyboardUIManagerTest.kt
+++ b/app/src/test/kotlin/be/scri/helpers/ui/KeyboardUIManagerTest.kt
@@ -13,8 +13,9 @@ import androidx.appcompat.widget.AppCompatImageView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.test.core.app.ApplicationProvider
import be.scri.databinding.InputMethodViewBinding
-import be.scri.helpers.ui.KeyboardUIManager.KeyboardUIListener
+import be.scri.ui.KeyboardUIManager.KeyboardUIListener
import be.scri.services.GeneralKeyboardIME.ScribeState
+import be.scri.ui.KeyboardUIManager
import be.scri.views.KeyboardView
import io.mockk.every
import io.mockk.mockk