1
0
Fork 0

fixed some more issues with automatic MainView showing, as well as showing with OK on XP3900

This commit is contained in:
sspanak 2024-04-20 10:20:12 +03:00 committed by Dimo Karaivanov
parent 2e019409e8
commit 0c6c463d96
6 changed files with 26 additions and 20 deletions

View file

@ -28,7 +28,7 @@ abstract public class AbstractHandler extends InputMethodService {
// UI
abstract protected View createMainView();
abstract protected void createSuggestionBar(View mainView);
abstract protected void forceShowWindow(boolean forceHarder);
abstract protected boolean forceShowWindow();
abstract protected void renderMainView();
abstract protected void setStatusIcon(InputMode mode);
abstract protected void setStatusText(String status);

View file

@ -30,12 +30,12 @@ public abstract class HotkeyHandler extends TypingHandler {
@Override public boolean onOK() {
suggestionOps.cancelDelayedAccept();
if (forceShowWindow()) {
return true;
}
if (!suggestionOps.isEmpty()) {
if (shouldBeVisible() && !isInputViewShown()) {
forceShowWindow(true);
} else {
onAcceptSuggestionManually(suggestionOps.acceptCurrent(), KeyEvent.KEYCODE_ENTER);
}
onAcceptSuggestionManually(suggestionOps.acceptCurrent(), KeyEvent.KEYCODE_ENTER);
return true;
}
@ -44,7 +44,7 @@ public abstract class HotkeyHandler extends TypingHandler {
if (action == TextField.IME_ACTION_ENTER) {
boolean actionPerformed = appHacks.onEnter();
if (actionPerformed) {
forceShowWindow(false);
forceShowWindow();
}
return actionPerformed;
}
@ -230,7 +230,7 @@ public abstract class HotkeyHandler extends TypingHandler {
DictionaryLoader.autoLoad(this, mLanguage);
}
forceShowWindow(false);
forceShowWindow();
return true;
}
@ -252,7 +252,7 @@ public abstract class HotkeyHandler extends TypingHandler {
UI.toastShortSingle(this, mInputMode.getClass().getSimpleName(), mInputMode.toString());
}
forceShowWindow(false);
forceShowWindow();
return true;
}

View file

@ -38,7 +38,7 @@ public class TraditionalT9 extends HotkeyHandler {
String message = intent != null ? intent.getStringExtra(PopupDialog.INTENT_CLOSE) : null;
if (message != null) {
forceShowWindow(false);
forceShowWindow();
if (!message.isEmpty()) {
UI.toastLong(this, message);
}
@ -173,9 +173,10 @@ public class TraditionalT9 extends HotkeyHandler {
* WARNING! Calling this may cause a restart, which will cause InputMode to be recreated. Depending
* on how much time the restart takes, this may erase the current user input.
*/
protected void forceShowWindow(boolean forceHarder) {
@Override
protected boolean forceShowWindow() {
if (isInputViewShown() || !shouldBeVisible()) {
return;
return false;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
@ -185,10 +186,13 @@ public class TraditionalT9 extends HotkeyHandler {
}
// Sonim XP3900 is quite stubborn and wouldn't show the MainView the regular way.
// Sending DPAD_CENTER seems to be the only way of doing it.
if (forceHarder && !isInputViewShown() && DeviceInfo.noTouchScreen(this)) {
// Sending DPAD_CENTER seems to be the only way of doing it. But, we only want to do this
// when there is no text to avoid undesired submitting of something.
if (!isInputViewShown() && DeviceInfo.noTouchScreen(this) && textField.isEmpty()) {
sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_CENTER);
}
return true;
}

View file

@ -155,6 +155,7 @@ public abstract class TypingHandler extends KeyPadHandler {
}
if (!mInputMode.onNumber(key, hold, repeat)) {
forceShowWindow();
return false;
}
@ -190,7 +191,7 @@ public abstract class TypingHandler extends KeyPadHandler {
textField.setText(text);
autoCorrectSpace(text, true, -1);
forceShowWindow(false);
forceShowWindow();
return true;
}
@ -273,6 +274,7 @@ public abstract class TypingHandler extends KeyPadHandler {
private void onAcceptSuggestionsDelayed(String word) {
onAcceptSuggestionManually(word, -1);
forceShowWindow();
}
protected void onAcceptSuggestionManually(String word, int fromKey) {
@ -327,7 +329,7 @@ public abstract class TypingHandler extends KeyPadHandler {
String trimmedWord = suggestionOps.getCurrent(mInputMode.getSequenceLength());
appHacks.setComposingTextWithHighlightedStem(trimmedWord, mInputMode);
forceShowWindow(false);
forceShowWindow();
}

View file

@ -147,7 +147,7 @@ public class InputType {
ArrayList<Integer> allowedModes = new ArrayList<>();
if (field == null) {
allowedModes.add(InputMode.MODE_123);
allowedModes.add(InputMode.MODE_PASSTHROUGH);
return allowedModes;
}