Show visual feedback when will autocorrect

This commit is contained in:
Aleksandras Kostarevas 2023-11-02 17:56:56 +02:00
parent b0ba33babe
commit 8bb38c7ae3
2 changed files with 10 additions and 4 deletions

View File

@ -176,6 +176,8 @@ fun RowScope.SuggestionItem(words: SuggestedWords, idx: Int, isPrimary: Boolean,
null
}
val actualIsPrimary = isPrimary && (words.mWillAutoCorrect || ((wordInfo?.isExactMatch) == true))
val iconColor = MaterialTheme.colorScheme.onBackground
val topSuggestionIcon = painterResource(id = R.drawable.transformer_suggestion)
val textButtonModifier = when (wordInfo?.mOriginatesFromTransformerLM) {
@ -188,7 +190,7 @@ fun RowScope.SuggestionItem(words: SuggestedWords, idx: Int, isPrimary: Boolean,
) {
draw(
topSuggestionIcon.intrinsicSize,
alpha = if(isPrimary){ 1.0f } else { 0.66f } / 1.25f,
alpha = if(actualIsPrimary){ 1.0f } else { 0.66f } / 1.25f,
colorFilter = ColorFilter.tint(color = iconColor)
)
}
@ -197,12 +199,12 @@ fun RowScope.SuggestionItem(words: SuggestedWords, idx: Int, isPrimary: Boolean,
else -> Modifier
}
val textModifier = when (isPrimary) {
val textModifier = when (actualIsPrimary) {
true -> Modifier
false -> Modifier.alpha(0.75f)
}
val textStyle = when (isPrimary) {
val textStyle = when (actualIsPrimary) {
true -> suggestionStylePrimary
false -> suggestionStyleAlternative
}.copy(color = MaterialTheme.colorScheme.onBackground)

View File

@ -240,9 +240,13 @@ public class LanguageModel extends Dictionary {
for(int i=0; i<maxResults; i++) {
if(outStrings[i] == null) continue;
int currKind = kind;
String word = outStrings[i].trim();
if(word.equals(partialWord)) {
currKind |= SuggestedWords.SuggestedWordInfo.KIND_FLAG_EXACT_MATCH;
}
suggestions.add(new SuggestedWords.SuggestedWordInfo( word, context, (int)(outProbabilities[i] * 100.0f), kind, this, 0, 0 ));
suggestions.add(new SuggestedWords.SuggestedWordInfo( word, context, (int)(outProbabilities[i] * 100.0f), currKind, this, 0, 0 ));
}
/*