@@ -8,6 +8,7 @@ import android.content.Context
88import android.content.Intent
99import android.database.sqlite.SQLiteException
1010import android.graphics.Color
11+ import android.graphics.Typeface
1112import android.graphics.drawable.GradientDrawable
1213import android.graphics.drawable.LayerDrawable
1314import android.graphics.drawable.RippleDrawable
@@ -1766,16 +1767,25 @@ abstract class GeneralKeyboardIME(
17661767 private fun setSuggestionButton (
17671768 button : Button ,
17681769 text : String ,
1770+ isExactMatch : Boolean = false,
17691771 ) {
17701772 val isUserDarkMode = getIsDarkModeOrNot(applicationContext)
1771- val textColor = if (isUserDarkMode) Color .WHITE else " #1E1E1E" .toColorInt()
1773+ val textColor =
1774+ if (isExactMatch) {
1775+ ContextCompat .getColor(applicationContext, R .color.theme_scribe_blue)
1776+ } else if (isUserDarkMode) {
1777+ Color .WHITE
1778+ } else {
1779+ " #1E1E1E" .toColorInt()
1780+ }
17721781 button.text = text
17731782 button.isAllCaps = false
17741783 button.visibility = View .VISIBLE
17751784 button.textSize = SUGGESTION_SIZE
17761785 button.setOnClickListener(null )
17771786 button.background = null
17781787 button.setTextColor(textColor)
1788+ button.setTypeface(button.typeface, if (isExactMatch) Typeface .BOLD else Typeface .NORMAL )
17791789 button.setOnClickListener {
17801790 currentInputConnection?.commitText(" $text " , 1 )
17811791 moveToIdleState()
@@ -1788,7 +1798,10 @@ abstract class GeneralKeyboardIME(
17881798 * Updates autocomplete UI with a new list of suggestions.
17891799 * Clears it if not idle or no completions.
17901800 */
1791- fun updateAutocompleteSuggestions (completions : List <String >? ) {
1801+ fun updateAutocompleteSuggestions (
1802+ completions : List <String >? ,
1803+ currentWord : String? = null,
1804+ ) {
17921805 if (currentState != ScribeState .IDLE ) {
17931806 uiManager.disableAutoSuggest(language)
17941807 return
@@ -1802,9 +1815,9 @@ abstract class GeneralKeyboardIME(
18021815 val completion2 = completions.getOrNull(1 ) ? : " "
18031816 val completion3 = completions.getOrNull(2 ) ? : " "
18041817
1805- setAutocompleteButton(uiManager.binding.conjugateBtn, completion1)
1806- setAutocompleteButton(uiManager.binding.translateBtn, completion2)
1807- setAutocompleteButton(uiManager.pluralBtn!! , completion3)
1818+ setAutocompleteButton(uiManager.binding.conjugateBtn, completion1, currentWord )
1819+ setAutocompleteButton(uiManager.binding.translateBtn, completion2, currentWord )
1820+ setAutocompleteButton(uiManager.pluralBtn!! , completion3, currentWord )
18081821
18091822 uiManager.binding.separator1.visibility = View .VISIBLE
18101823 uiManager.binding.separator2.visibility = View .VISIBLE
@@ -1813,12 +1826,16 @@ abstract class GeneralKeyboardIME(
18131826 /* *
18141827 * Sets up an autocomplete button with the given suggestion text.
18151828 * When clicked, it replaces the current word with the suggestion.
1829+ * If the suggestion exactly matches what the user has already typed,
1830+ * the button is highlighted to signal that pressing it is a no-op.
18161831 */
18171832 private fun setAutocompleteButton (
18181833 button : Button ,
18191834 text : String ,
1835+ currentWord : String? = null,
18201836 ) {
1821- setSuggestionButton(button, text)
1837+ val isExactMatch = text.isNotBlank() && text.equals(currentWord, ignoreCase = true )
1838+ setSuggestionButton(button, text, isExactMatch)
18221839 if (text.isBlank()) {
18231840 button.setOnClickListener(null )
18241841 return
0 commit comments