Skip to content

Commit d3e02c9

Browse files
committed
feat: Default Suggestions appear when nothing is typed
1 parent e6f1786 commit d3e02c9

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

app/src/main/java/be/scri/helpers/ui/HintUtils.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,19 @@ object HintUtils {
141141
else -> defaultHint
142142
}
143143

144+
fun getBaseAutoSuggestions(language: String): List<String> =
145+
when (language) {
146+
"English" -> ENInterfaceVariables.BASE_AUTOSUGGESTIONS
147+
"French" -> FRInterfaceVariables.BASE_AUTOSUGGESTIONS
148+
"German" -> DEInterfaceVariables.BASE_AUTOSUGGESTIONS
149+
"Italian" -> ITInterfaceVariables.BASE_AUTOSUGGESTIONS
150+
"Portuguese" -> PTInterfaceVariables.BASE_AUTOSUGGESTIONS
151+
"Russian" -> RUInterfaceVariables.BASE_AUTOSUGGESTIONS
152+
"Spanish" -> ESInterfaceVariables.BASE_AUTOSUGGESTIONS
153+
"Swedish" -> SVInterfaceVariables.BASE_AUTOSUGGESTIONS
154+
else -> ENInterfaceVariables.BASE_AUTOSUGGESTIONS
155+
}
156+
144157
/**
145158
* Retrieves the prompt text for the given state and language.
146159
* This text provides context to the user based on the current action.

app/src/main/java/be/scri/services/GeneralKeyboardIME.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,11 +587,12 @@ abstract class GeneralKeyboardIME(
587587

588588
val textColor = if (isUserDarkMode) Color.WHITE else "#1E1E1E".toColorInt()
589589

590-
listOf(binding.translateBtn, binding.conjugateBtn, binding.pluralBtn).forEach { button ->
590+
listOf(binding.translateBtn, binding.conjugateBtn, binding.pluralBtn).forEachIndexed { index, button ->
591591
button.visibility = View.VISIBLE
592592
button.background = null
593593
button.setTextColor(textColor)
594-
button.text = ""
594+
button.text = HintUtils.getBaseAutoSuggestions(language).getOrNull(index)
595+
button.isAllCaps = false
595596
button.textSize = SUGGESTION_SIZE
596597
button.setOnClickListener(null)
597598
}
@@ -1741,10 +1742,11 @@ abstract class GeneralKeyboardIME(
17411742

17421743
// Don't change button text if we're in TRANSLATE or SELECT_COMMAND state
17431744
if (currentState != ScribeState.TRANSLATE && currentState != ScribeState.SELECT_COMMAND) {
1744-
binding.translateBtn.text = ""
1745+
binding.translateBtn.text = HintUtils.getBaseAutoSuggestions(language)[0]
1746+
binding.conjugateBtn.text = HintUtils.getBaseAutoSuggestions(language)[1]
1747+
binding.pluralBtn.text = HintUtils.getBaseAutoSuggestions(language)[2]
17451748
binding.translateBtn.background = null
17461749
binding.translateBtn.setOnClickListener(null)
1747-
17481750
binding.conjugateBtn.setOnClickListener(null)
17491751
binding.pluralBtn.setOnClickListener(null)
17501752
}

0 commit comments

Comments
 (0)