1
0
Fork 0

fixed the suggestions not being displayed, when attempting to type while the MainView is still hidden

This commit is contained in:
sspanak 2024-04-01 20:22:41 +03:00 committed by Dimo Karaivanov
parent f4caa24387
commit f69cdc8d9b
4 changed files with 13 additions and 9 deletions

View file

@ -95,7 +95,7 @@ public abstract class HotkeyHandler extends TypingHandler {
public boolean onKeyAddWord(boolean validateOnly) { public boolean onKeyAddWord(boolean validateOnly) {
if (!isInputViewShown() || mInputMode.isNumeric()) { if (shouldBeOff() || mInputMode.isNumeric()) {
return false; return false;
} }
@ -123,7 +123,7 @@ public abstract class HotkeyHandler extends TypingHandler {
public boolean onKeyChangeKeyboard(boolean validateOnly) { public boolean onKeyChangeKeyboard(boolean validateOnly) {
if (!isInputViewShown()) { if (shouldBeOff()) {
return false; return false;
} }
@ -200,6 +200,7 @@ public abstract class HotkeyHandler extends TypingHandler {
suggestionOps.scrollTo(backward ? -1 : 1); suggestionOps.scrollTo(backward ? -1 : 1);
mInputMode.setWordStem(suggestionOps.getCurrent(), true); mInputMode.setWordStem(suggestionOps.getCurrent(), true);
appHacks.setComposingTextWithHighlightedStem(suggestionOps.getCurrent(), mInputMode); appHacks.setComposingTextWithHighlightedStem(suggestionOps.getCurrent(), mInputMode);
return true; return true;
} }
@ -221,7 +222,6 @@ public abstract class HotkeyHandler extends TypingHandler {
setStatusText(mInputMode.toString()); setStatusText(mInputMode.toString());
renderMainView(); renderMainView();
forceShowWindowIfHidden();
if (!suggestionOps.isEmpty() || settings.isMainLayoutStealth()) { if (!suggestionOps.isEmpty() || settings.isMainLayoutStealth()) {
UI.toastShortSingle(this, mLanguage.getClass().getSimpleName(), mLanguage.getName()); UI.toastShortSingle(this, mLanguage.getClass().getSimpleName(), mLanguage.getName());
} }
@ -230,6 +230,7 @@ public abstract class HotkeyHandler extends TypingHandler {
DictionaryLoader.autoLoad(this, mLanguage); DictionaryLoader.autoLoad(this, mLanguage);
} }
forceShowWindowIfHidden();
return true; return true;
} }
@ -247,14 +248,14 @@ public abstract class HotkeyHandler extends TypingHandler {
nextInputMode(); nextInputMode();
renderMainView(); renderMainView();
setStatusIcon(mInputMode.getIcon()); setStatusIcon(mInputMode.getIcon());
forceShowWindowIfHidden();
forceShowWindowIfHidden();
return true; return true;
} }
public boolean onKeyShowSettings(boolean validateOnly) { public boolean onKeyShowSettings(boolean validateOnly) {
if (!isInputViewShown()) { if (shouldBeOff()) {
return false; return false;
} }

View file

@ -154,9 +154,11 @@ public class TraditionalT9 extends HotkeyHandler {
* Some applications may hide our window and it remains invisible until the screen is touched or OK is pressed. * Some applications may hide our window and it remains invisible until the screen is touched or OK is pressed.
* This is fine for touchscreen keyboards, but the hardware keyboard allows typing even when the window and the suggestions * This is fine for touchscreen keyboards, but the hardware keyboard allows typing even when the window and the suggestions
* are invisible. This function forces the InputMethodManager to show our window. * are invisible. This function forces the InputMethodManager to show our window.
* WARNING! While this is running, it is not possible to load or display suggestions,
* or change the composing text. Use with care, after all processing is done.
*/ */
protected void forceShowWindowIfHidden() { protected void forceShowWindowIfHidden() {
if (getInputMode().isPassthrough() || isInputViewShown()) { if (getInputMode().isPassthrough() || isInputViewShown() || settings.isMainLayoutStealth()) {
return; return;
} }

View file

@ -124,7 +124,6 @@ public abstract class TypingHandler extends KeyPadHandler {
*/ */
protected boolean onNumber(int key, boolean hold, int repeat) { protected boolean onNumber(int key, boolean hold, int repeat) {
suggestionOps.cancelDelayedAccept(); suggestionOps.cancelDelayedAccept();
forceShowWindowIfHidden();
// Automatically accept the previous word, when the next one is a space or punctuation, // Automatically accept the previous word, when the next one is a space or punctuation,
// instead of requiring "OK" before that. // instead of requiring "OK" before that.
@ -166,7 +165,6 @@ public abstract class TypingHandler extends KeyPadHandler {
} }
suggestionOps.cancelDelayedAccept(); suggestionOps.cancelDelayedAccept();
forceShowWindowIfHidden();
// accept the previously typed word (if any) // accept the previously typed word (if any)
String lastWord = suggestionOps.acceptIncomplete(); String lastWord = suggestionOps.acceptIncomplete();
@ -178,6 +176,7 @@ public abstract class TypingHandler extends KeyPadHandler {
textField.setText(text); textField.setText(text);
autoCorrectSpace(text, true, -1); autoCorrectSpace(text, true, -1);
forceShowWindowIfHidden();
return true; return true;
} }
@ -303,5 +302,7 @@ public abstract class TypingHandler extends KeyPadHandler {
// for a more intuitive experience. // for a more intuitive experience.
String trimmedWord = suggestionOps.getCurrent(mInputMode.getSequenceLength()); String trimmedWord = suggestionOps.getCurrent(mInputMode.getSequenceLength());
appHacks.setComposingTextWithHighlightedStem(trimmedWord, mInputMode); appHacks.setComposingTextWithHighlightedStem(trimmedWord, mInputMode);
forceShowWindowIfHidden();
} }
} }

View file

@ -102,7 +102,7 @@ public class Predictions {
boolean retryAllowed = !digitSequence.equals(EmojiLanguage.CUSTOM_EMOJI_SEQUENCE); boolean retryAllowed = !digitSequence.equals(EmojiLanguage.CUSTOM_EMOJI_SEQUENCE);
WordStoreAsync.getWords( WordStoreAsync.getWords(
(words) -> onDbWords(words, retryAllowed), (dbWords) -> onDbWords(dbWords, retryAllowed),
language, language,
digitSequence, digitSequence,
stem, stem,