diff --git a/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt b/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt index 70f30918..727bef1f 100644 --- a/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt +++ b/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt @@ -107,7 +107,6 @@ abstract class GeneralKeyboardIME( var nounTypeSuggestion: List? = null var checkIfPluralWord: Boolean = false private var currentEnterKeyType: Int? = null - private val commandCursor = "│" val prepAnnotationConversionDict = mapOf( "German" to mapOf("Acc" to "Akk"), @@ -459,24 +458,27 @@ abstract class GeneralKeyboardIME( * to provide appropriate hints and prompts to the user. */ private fun updateCommandBarHintAndPrompt(isUserDarkMode: Boolean? = null) { - val commandBarButton = keyboardBinding.commandBar + val commandBarEditText = keyboardBinding.commandBar val hintMessage = HintUtils.getCommandBarHint(currentState, language) val promptText = HintUtils.getPromptText(currentState, language, context = this) val promptTextView = keyboardBinding.promptText promptTextView.text = promptText - commandBarButton.hint = hintMessage + commandBarEditText.hint = hintMessage + + commandBarEditText.requestFocus() if (isUserDarkMode == true) { - commandBarButton.setHintTextColor(getColor(R.color.hint_white)) - commandBarButton.setTextColor(getColor(white)) - commandBarButton.backgroundTintList = ContextCompat.getColorStateList(this, R.color.command_bar_color_dark) + commandBarEditText.setHintTextColor(getColor(R.color.hint_white)) + commandBarEditText.setTextColor(getColor(white)) + keyboardBinding.commandBarLayout.backgroundTintList = + ContextCompat.getColorStateList(this, R.color.command_bar_color_dark) promptTextView.setTextColor(getColor(white)) promptTextView.setBackgroundColor(getColor(R.color.command_bar_color_dark)) keyboardBinding.promptTextBorder.setBackgroundColor(getColor(R.color.command_bar_color_dark)) } else { - commandBarButton.setHintTextColor(getColor(R.color.hint_black)) - commandBarButton.setTextColor(Color.BLACK) - commandBarButton.backgroundTintList = ContextCompat.getColorStateList(this, R.color.white) + commandBarEditText.setHintTextColor(getColor(R.color.hint_black)) + commandBarEditText.setTextColor(Color.BLACK) + keyboardBinding.commandBarLayout.backgroundTintList = ContextCompat.getColorStateList(this, white) promptTextView.setTextColor(Color.BLACK) promptTextView.setBackgroundColor(getColor(white)) keyboardBinding.promptTextBorder.setBackgroundColor(getColor(white)) @@ -1451,7 +1453,6 @@ abstract class GeneralKeyboardIME( ?.text .toString() .trim() - .dropLast(1) lateinit var commandModeOutput: String commandModeOutput = when (currentState) { @@ -1462,7 +1463,7 @@ abstract class GeneralKeyboardIME( commandModeOutput = "$commandModeOutput " } inputConnection.commitText(commandModeOutput, 1) - binding?.commandBar?.text = "" + binding?.commandBar?.setText("") } else { if (imeOptionsActionId != IME_ACTION_NONE) { inputConnection.performEditorAction(imeOptionsActionId) @@ -1561,9 +1562,10 @@ abstract class GeneralKeyboardIME( keyboard?.mShiftState = SHIFT_ON_ONE_CHAR } } else { - newText = "${commandBar.text.trim().dropLast(2)}$commandCursor" + newText = "${commandBar.text.trim().dropLast(1)}" } - commandBar.text = newText + commandBar.setText(newText) + commandBar.setSelection(newText.length) } } @@ -1649,13 +1651,14 @@ abstract class GeneralKeyboardIME( binding.commandBar.paddingBottom, ) } - val newText = "${commandBar.text.trim().dropLast(1)}$codeChar$commandCursor" - commandBar.text = newText + val newText = "${commandBar.text}$codeChar" + commandBar.setText(newText) + commandBar.setSelection(newText.length) } } else { // Handling space key logic. if (keyboardMode != keyboardLetters && code == KeyboardBase.KEYCODE_SPACE) { - binding?.commandBar?.text = " " + binding?.commandBar?.setText(" ") val originalText = inputConnection.getExtractedText(ExtractedTextRequest(), 0).text inputConnection.commitText(codeChar.toString(), 1) val newText = inputConnection.getExtractedText(ExtractedTextRequest(), 0).text diff --git a/app/src/main/res/drawable/ic_custom_cursor.xml b/app/src/main/res/drawable/ic_custom_cursor.xml new file mode 100644 index 00000000..9f7bcd90 --- /dev/null +++ b/app/src/main/res/drawable/ic_custom_cursor.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/layout-land/keyboard_view_keyboard.xml b/app/src/main/res/layout-land/keyboard_view_keyboard.xml index 6383efab..e4b21880 100644 --- a/app/src/main/res/layout-land/keyboard_view_keyboard.xml +++ b/app/src/main/res/layout-land/keyboard_view_keyboard.xml @@ -50,7 +50,7 @@ android:singleLine="true" android:ellipsize="end" app:layout_constraintBottom_toBottomOf="@+id/command_field" - app:layout_constraintEnd_toStartOf="@+id/command_bar" + app:layout_constraintEnd_toStartOf="@id/command_bar_layout" app:layout_constraintStart_toEndOf="@+id/scribe_key" app:layout_constraintTop_toTopOf="@+id/command_field" /> @@ -62,34 +62,43 @@ android:text="│" android:textFontWeight="500" android:textSize="16sp" - app:layout_constraintBaseline_toBaselineOf="@+id/command_bar" + app:layout_constraintBaseline_toBaselineOf="@id/prompt_text" app:layout_constraintBottom_toBottomOf="@+id/prompt_text" - app:layout_constraintEnd_toStartOf="@+id/command_bar" + app:layout_constraintEnd_toStartOf="@id/command_bar_layout" app:layout_constraintStart_toEndOf="@+id/prompt_text" app:layout_constraintTop_toTopOf="@+id/prompt_text" /> -