From ea166f275048a182ac4950f58ec2e34b913688cf Mon Sep 17 00:00:00 2001 From: Aleksandras Kostarevas Date: Mon, 22 Apr 2024 10:40:32 -0400 Subject: [PATCH] Show single word in actionbar during update batch --- java/src/org/futo/inputmethod/latin/Suggest.java | 2 ++ .../org/futo/inputmethod/latin/uix/ActionBar.kt | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/java/src/org/futo/inputmethod/latin/Suggest.java b/java/src/org/futo/inputmethod/latin/Suggest.java index 13c6f71c6..e0fff635d 100644 --- a/java/src/org/futo/inputmethod/latin/Suggest.java +++ b/java/src/org/futo/inputmethod/latin/Suggest.java @@ -17,6 +17,7 @@ package org.futo.inputmethod.latin; import android.text.TextUtils; +import android.util.Log; import static org.futo.inputmethod.latin.define.DecoderSpecificConstants.SHOULD_AUTO_CORRECT_USING_NON_WHITE_LISTED_SUGGESTION; import static org.futo.inputmethod.latin.define.DecoderSpecificConstants.SHOULD_REMOVE_PREVIOUSLY_REJECTED_SUGGESTION; @@ -333,6 +334,7 @@ public final class Suggest { && TextUtils.equals(suggestionsContainer.get(0).mWord, wordComposer.getRejectedBatchModeSuggestion())) { final SuggestedWordInfo rejected = suggestionsContainer.remove(0); + Log.i(TAG, "Swipe: Swapping top candidate [ " + rejected.mWord + " ] as it was previously rejected by user"); suggestionsContainer.add(1, rejected); } SuggestedWordInfo.removeDups(null /* typedWord */, suggestionsContainer); diff --git a/java/src/org/futo/inputmethod/latin/uix/ActionBar.kt b/java/src/org/futo/inputmethod/latin/uix/ActionBar.kt index 78974bb90..b2022e6ca 100644 --- a/java/src/org/futo/inputmethod/latin/uix/ActionBar.kt +++ b/java/src/org/futo/inputmethod/latin/uix/ActionBar.kt @@ -288,6 +288,20 @@ fun RowScope.SuggestionItems(words: SuggestedWords, onClick: (i: Int) -> Unit, o return } + if(maxSuggestions == 1 || words.mInputStyle == SuggestedWords.INPUT_STYLE_UPDATE_BATCH) { + SuggestionItem( + words, + 0, + isPrimary = true, + onClick = { onClick(0) }, + onLongClick = { onLongClick(0) } + ) + + return + } else if(words.mInputStyle == SuggestedWords.INPUT_STYLE_TAIL_BATCH && maxSuggestions > 1) { + words.mSuggestedWordInfoList.removeAt(0); + } + var offset = 0