fixed some more scenarios where the OK key was not working
This commit is contained in:
parent
32638aca46
commit
3c86d0b0cd
3 changed files with 23 additions and 11 deletions
|
|
@ -130,7 +130,7 @@ public class AppHacks {
|
|||
* onEnter
|
||||
* Tries to guess and send the correct confirmation key code or sequence of key codes,
|
||||
* depending on the connected application and input field. On invalid connection or field,
|
||||
* it does nothing.
|
||||
* it does nothing and return "false", signaling the system we have ignored the key press.
|
||||
*/
|
||||
public boolean onEnter() {
|
||||
if (settings.getFbMessengerHack() && isMessenger()) {
|
||||
|
|
@ -138,18 +138,18 @@ public class AppHacks {
|
|||
} else if (settings.getGoogleChatHack() && isGoogleChat()) {
|
||||
return onEnterGoogleChat();
|
||||
} else if (isTermux() || isMultilineTextInNonSystemApp()) {
|
||||
// 1. Termux supports only ENTER, so we convert DPAD_CENTER for it.
|
||||
// 2. Any extra installed apps are likely not designed for hardware keypads, so again,
|
||||
// we don't want to send DPAD_CENTER to them.
|
||||
// Termux supports only ENTER, so we convert DPAD_CENTER for it.
|
||||
// Any extra installed apps are likely not designed for hardware keypads, so again,
|
||||
// we don't want to send DPAD_CENTER to them.
|
||||
return sendDownUpKeyEvents(KeyEvent.KEYCODE_ENTER);
|
||||
}
|
||||
|
||||
// The rest of the cases are probably system apps or numeric fields, which should
|
||||
// now how to handle the incoming OK key code, be it ENTER or DPAD_CENTER.
|
||||
// As per the docs, we must return "false", to indicate that we have not "seen" the key press.
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* onEnterFbMessenger
|
||||
* Messenger responds only to ENTER, but not DPAD_CENTER, so we make sure to send the correct code,
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ public class TextField {
|
|||
|
||||
/**
|
||||
* setComposingTextWithHighlightedStem
|
||||
*
|
||||
* <p>
|
||||
* Sets the composing text, but makes the "stem" substring bold. If "highlightMore" is true,
|
||||
* the "stem" part will be in bold and italic.
|
||||
*/
|
||||
|
|
@ -263,12 +263,18 @@ public class TextField {
|
|||
return EditorInfo.IME_ACTION_NONE;
|
||||
}
|
||||
|
||||
if (field.actionId == EditorInfo.IME_ACTION_DONE) {
|
||||
// custom actions handling as in LatinIME. See the example in OpenBoard repo:
|
||||
// https://github.com/openboard-team/openboard/blob/master/app/src/main/java/org/dslul/openboard/inputmethod/latin/utils/InputTypeUtils.java#L107
|
||||
if (field.actionId == EditorInfo.IME_ACTION_DONE || field.actionLabel != null) {
|
||||
return IME_ACTION_ENTER;
|
||||
} else if (field.actionId > 0) {
|
||||
return field.actionId;
|
||||
}
|
||||
|
||||
// As in LatinIME, we want to perform an editor action, including in the case of "IME_ACTION_UNSPECIFIED".
|
||||
// Otherwise, we pass through the ENTER or DPAD_CENTER key press and let the app or the system decide what to do.
|
||||
// See the example below:
|
||||
// https://github.com/openboard-team/openboard/blob/c3772cd56e770975ea5570db903f93b199de8b32/app/src/main/java/org/dslul/openboard/inputmethod/latin/inputlogic/InputLogic.java#L756
|
||||
int standardAction = field.imeOptions & (EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION);
|
||||
switch (standardAction) {
|
||||
case EditorInfo.IME_ACTION_DONE:
|
||||
|
|
@ -277,10 +283,12 @@ public class TextField {
|
|||
case EditorInfo.IME_ACTION_PREVIOUS:
|
||||
case EditorInfo.IME_ACTION_SEARCH:
|
||||
case EditorInfo.IME_ACTION_SEND:
|
||||
case EditorInfo.IME_ACTION_UNSPECIFIED:
|
||||
return standardAction;
|
||||
default:
|
||||
return IME_ACTION_ENTER;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -20,9 +20,13 @@ public class SoftOkKey extends SoftKey {
|
|||
|
||||
@Override
|
||||
protected boolean handleRelease() {
|
||||
return
|
||||
validateTT9Handler()
|
||||
&& tt9.onKeyDown(KeyEvent.KEYCODE_ENTER, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER))
|
||||
&& tt9.onKeyUp(KeyEvent.KEYCODE_ENTER, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_ENTER));
|
||||
if (validateTT9Handler() && !tt9.onOK()) {
|
||||
// If no standard editor action was performed, it probably means we can only type a new line,
|
||||
// so we simulate the hardware ENTER key.
|
||||
tt9.sendDownUpKeyEvents(KeyEvent.KEYCODE_ENTER);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue