1
0
Fork 0

fixed incorrect force showing of the main view on start up, causing loss of control in Telegram, Waze and possibly other apps

This commit is contained in:
Dimo Karaivanov 2023-03-24 17:55:36 +02:00
parent 2df5932896
commit c6c8cd5058

View file

@ -8,6 +8,7 @@ import android.os.Message;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.View; import android.view.View;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -117,13 +118,6 @@ public class TraditionalT9 extends KeyPadHandler {
softKeyHandler.setDarkTheme(settings.getDarkTheme()); softKeyHandler.setDarkTheme(settings.getDarkTheme());
softKeyHandler.setSoftKeysVisibility(settings.getShowSoftKeys()); softKeyHandler.setSoftKeysVisibility(settings.getShowSoftKeys());
softKeyHandler.show(); softKeyHandler.show();
if (!isInputViewShown()) {
showWindow(true);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && mEditing != EDITING_STRICT_NUMERIC && mEditing != EDITING_DIALER) {
requestShowSelf(1);
}
} }
@ -163,7 +157,6 @@ public class TraditionalT9 extends KeyPadHandler {
protected void onStop() { protected void onStop() {
onFinishTyping(); onFinishTyping();
clearSuggestions(); clearSuggestions();
hideWindow();
softKeyHandler.hide(); softKeyHandler.hide();
} }
@ -269,6 +262,8 @@ public class TraditionalT9 extends KeyPadHandler {
* @return boolean * @return boolean
*/ */
protected boolean onNumber(int key, boolean hold, int repeat) { protected boolean onNumber(int key, boolean hold, int repeat) {
forceShowWindowIfHidden();
String currentWord = getComposingText(); String currentWord = getComposingText();
// Automatically accept the current word, when the next one is a space or whatnot, // Automatically accept the current word, when the next one is a space or whatnot,
@ -682,4 +677,21 @@ public class TraditionalT9 extends KeyPadHandler {
protected View createSoftKeyView() { protected View createSoftKeyView() {
return softKeyHandler.getView(); return softKeyHandler.getView();
} }
/**
* forceShowWindowIfHidden
* 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
* are invisible. This function forces the InputMethodManager to show our window.
*/
protected void forceShowWindowIfHidden() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P
&& mEditing != EDITING_STRICT_NUMERIC
&& mEditing != EDITING_DIALER
&& !isInputViewShown()
) {
requestShowSelf(InputMethodManager.SHOW_IMPLICIT);
}
}
} }