Skip to content

Commit becd3bb

Browse files
committed
fixed suggestion bar visibility issues
1 parent e8660d2 commit becd3bb

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

app/src/main/java/io/github/sspanak/tt9/db/mindReading/MindReader.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ public void guessNext(@NonNull InputMode inputMode, @NonNull Language language,
8888

8989
loadingId = 0;
9090

91+
// @todo: Thai no longer works
92+
// @todo: Chinese no longer works
9193
// @todo: this fails for ABC. Fix it!
9294
if (setContextSync(inputMode, language, surroundingText, lastWord)) {
9395
runInThread(() -> {
@@ -196,7 +198,7 @@ public void processContext(@Nullable InputMode inputMode, @NonNull Language lang
196198

197199

198200
private String adjustWordTextCase(@NonNull String word) {
199-
if (autoTextCase == null) {
201+
if (autoTextCase == null || (wordContext.language != null && !wordContext.language.hasUpperCase())) {
200202
return word;
201203
}
202204

app/src/main/java/io/github/sspanak/tt9/ime/TypingHandler.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ protected boolean onNumber(int key, boolean hold, int repeat) {
198198
// First pass, analyze the incoming key press and decide whether it could be the start of
199199
// a new word. In case we do accept it, we preserve the suggestion list instead of clearing,
200200
// to prevent flashing while the next suggestions are being loaded.
201+
202+
// @todo: accept first-letter-completed on space
201203
if (mInputMode.shouldAcceptPreviousSuggestion(suggestionOps.getCurrent(), key, hold)) {
202204
// WARNING! Ensure the code after "acceptIncompleteAndKeepList()" does not depend on
203205
// the suggestions in SuggestionOps, since we don't clear that list.

app/src/main/java/io/github/sspanak/tt9/ime/helpers/SuggestionOps.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,32 +104,32 @@ public void clear() {
104104

105105

106106
public void addGuesses(@NonNull ArrayList<String> guesses) {
107-
setVisibility(settings, guesses, true);
107+
setVisibility(settings, isEmpty() && guesses.isEmpty(), true);
108108
if (suggestionBar != null) {
109109
suggestionBar.prependGuesses(guesses);
110110
}
111111
}
112112

113113

114-
public void set(ArrayList<String> suggestions) {
114+
public void set(@Nullable ArrayList<String> suggestions) {
115115
set(suggestions, 0, false);
116116
}
117117

118118

119-
public void set(ArrayList<String> suggestions, boolean containsGenerated) {
119+
public void set(@Nullable ArrayList<String> suggestions, boolean containsGenerated) {
120120
set(suggestions, 0, containsGenerated);
121121
}
122122

123123

124-
public void set(ArrayList<String> suggestions, int selectIndex, boolean containsGenerated) {
125-
setVisibility(settings, suggestions, false);
124+
public void set(@Nullable ArrayList<String> suggestions, int selectIndex, boolean containsGenerated) {
125+
setVisibility(settings, suggestions == null || suggestions.isEmpty(), false);
126126
if (suggestionBar != null) {
127127
suggestionBar.setMany(suggestions, selectIndex, containsGenerated);
128128
}
129129
}
130130

131131

132-
public void setClipboardItems(LinkedList<CharSequence> clips) {
132+
public void setClipboardItems(@NonNull LinkedList<CharSequence> clips) {
133133
ArrayList<String> clipStrings = new ArrayList<>(clips.size());
134134
for (int i = clips.size() - 1; i >= 0; i--) {
135135
String preview = Clipboard.getPreview(i, SuggestionsBar.CLIPBOARD_SUGGESTION_SUFFIX);
@@ -138,7 +138,7 @@ public void setClipboardItems(LinkedList<CharSequence> clips) {
138138
}
139139
}
140140

141-
setVisibility(settings, clipStrings, true);
141+
setVisibility(settings, clipStrings.isEmpty(), true);
142142
if (suggestionBar != null) {
143143
suggestionBar.setMany(clipStrings, 0, false);
144144
}
@@ -296,15 +296,15 @@ public void setColorScheme() {
296296
}
297297

298298

299-
private void setVisibility(@Nullable SettingsStore settings, @Nullable ArrayList<String> newSuggestions, boolean forceVisible) {
299+
private void setVisibility(@Nullable SettingsStore settings, boolean willBeEmpty, boolean forceVisible) {
300300
final boolean areSuggestionsVisible = isInputLimited || forceVisible || (settings != null && settings.getShowSuggestions());
301301

302302
if (suggestionBar != null) {
303303
suggestionBar.setVisible(areSuggestionsVisible);
304304
}
305305

306306
if (statusBar != null) {
307-
statusBar.setShown(newSuggestions == null || newSuggestions.isEmpty() || !areSuggestionsVisible);
307+
statusBar.setShown(willBeEmpty || !areSuggestionsVisible);
308308
}
309309
}
310310
}

0 commit comments

Comments
 (0)