Skip to content
Open
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
4 changes: 4 additions & 0 deletions app/src/keyboards/java/be/scri/helpers/KeyHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ class KeyHandler(
handleModeChangeKey()
true
}
KeyboardBase.KEYCODE_FLOAT_TOGGLE -> {
ime.toggleFloatingMode()
true
}
KeyboardBase.KEYCODE_SPACE -> handleSpaceKeyPress(previousWasLastKeySpace)
in KeyboardBase.NAVIGATION_KEYS -> {
handleNavigationKey(code)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,16 @@ object KeyboardLanguageMappingConstants {
"RU" to RUInterfaceVariables.PLURAL_KEY_LBL,
"SV" to SVInterfaceVariables.PLURAL_KEY_LBL,
)

val floatPlaceholder =
mapOf(
"EN" to "Float",
"ES" to "Flotante",
"DE" to "Schweben",
"IT" to "Fluttuante",
"FR" to "Flottant",
"PT" to "Flutuante",
"RU" to "Плавающая",
"SV" to "Flytande",
)
}
42 changes: 38 additions & 4 deletions app/src/keyboards/java/be/scri/helpers/ui/KeyboardUIManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ class KeyboardUIManager(

fun onCloseClicked()

fun onFloatClicked()

fun isFloatingModeActive(): Boolean

fun onEmojiSelected(emoji: String)

fun onSuggestionClicked(suggestion: String)
Expand All @@ -73,13 +77,17 @@ class KeyboardUIManager(
fun processLinguisticSuggestions(word: String)

fun isNumericKeyboardActive(): Boolean

fun getKeyboardWidth(): Int
}

var keyboardView: KeyboardView = binding.keyboardView
var keyboard: KeyboardBase? = null

// UI Elements
var pluralBtn: Button? = binding.pluralBtn
var floatBtn: Button? = null
var separatorFloat: View? = null
var emojiBtnPhone1: Button? = binding.emojiBtnPhone1
var emojiSpacePhone: View? = binding.emojiSpacePhone
var emojiBtnPhone2: Button? = binding.emojiBtnPhone2
Expand Down Expand Up @@ -210,6 +218,7 @@ class KeyboardUIManager(
listOf(binding.translateBtn, binding.conjugateBtn, binding.pluralBtn).forEachIndexed { index, button ->
button.visibility = View.VISIBLE
button.background = null
button.foreground = null
button.setTextColor(textColor)
button.text = HintUtils.getBaseAutoSuggestions(language).getOrNull(index)
button.isAllCaps = false
Expand Down Expand Up @@ -279,11 +288,31 @@ class KeyboardUIManager(
button.backgroundTintList = ContextCompat.getColorStateList(context, R.color.theme_scribe_blue)
button.setTextColor(buttonTextColor)
button.textSize = GeneralKeyboardIME.SUGGESTION_SIZE
button.isAllCaps = false
}

binding.translateBtn.text = translatePlaceholder[langAlias] ?: "Translate"
binding.conjugateBtn.text = conjugatePlaceholder[langAlias] ?: "Conjugate"
binding.pluralBtn.text = pluralPlaceholder[langAlias] ?: "Plural"
val isFloating = listener.isFloatingModeActive()
if (isFloating) {
binding.translateBtn.text = ""
binding.conjugateBtn.text = ""
binding.pluralBtn.text = ""

binding.translateBtn.foreground = ContextCompat.getDrawable(context, R.drawable.ic_translate_command)
binding.conjugateBtn.foreground = ContextCompat.getDrawable(context, R.drawable.ic_conjugate_command)
binding.pluralBtn.foreground = ContextCompat.getDrawable(context, R.drawable.ic_plural_command)

binding.translateBtn.foregroundGravity = android.view.Gravity.CENTER
binding.conjugateBtn.foregroundGravity = android.view.Gravity.CENTER
binding.pluralBtn.foregroundGravity = android.view.Gravity.CENTER
} else {
binding.translateBtn.text = translatePlaceholder[langAlias] ?: "Translate"
binding.conjugateBtn.text = conjugatePlaceholder[langAlias] ?: "Conjugate"
binding.pluralBtn.text = pluralPlaceholder[langAlias] ?: "Plural"

binding.translateBtn.foreground = null
binding.conjugateBtn.foreground = null
binding.pluralBtn.foreground = null
}

val separatorColor = (if (isUserDarkMode) GeneralKeyboardIME.DARK_THEME else GeneralKeyboardIME.LIGHT_THEME).toColorInt()
binding.separator2.setBackgroundColor(separatorColor)
Expand Down Expand Up @@ -600,7 +629,8 @@ class KeyboardUIManager(
*/
fun initializeKeyboard(xmlId: Int) {
val enterKeyType = listener.getCurrentEnterKeyType()
keyboard = KeyboardBase(context, xmlId, enterKeyType)
val width = listener.getKeyboardWidth()
keyboard = KeyboardBase(context, xmlId, enterKeyType, width)
keyboardView.setKeyboard(keyboard!!)
keyboardView.mOnKeyboardActionListener = listener.onKeyboardActionListener()
keyboardView.requestLayout()
Expand Down Expand Up @@ -668,6 +698,10 @@ class KeyboardUIManager(
binding.separator4.visibility = View.GONE
binding.separator5.visibility = View.GONE
binding.separator6.visibility = View.GONE

binding.translateBtn.foreground = null
binding.conjugateBtn.foreground = null
pluralBtn?.foreground = null
}

/**
Expand Down
Loading
Loading