1
0
Fork 0

OK sends messages (#194)

* OK now performs the default application action correctly, when an action is allowed (e.g. send a message, go to a URL or the next form field)

* updated manual
This commit is contained in:
Dimo Karaivanov 2023-02-27 16:35:11 +02:00 committed by GitHub
parent c523f0f0f1
commit 9b0a3c64ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 1 deletions

View file

@ -61,6 +61,15 @@ _Predictive mode only._
- Clear the suggestion filter, if applied.
- When no filter is applied, accept the current word as-is, even if it does not fully match a suggestion, then jump before it.
#### D-pad Center (OK or ENTER):
- When suggestions are displayed, types the currently selected suggestion.
- Otherwise, performs the default action for the current application (e.g. send a message, go to a URL, or just type a new line).
_**NB:** Every application decides on its own what to do when OK is pressed and TT9 has no control over this._
_**NB2:** In messaging applications, you need to enable their "Send with ENTER" or similarly named setting, in order to send messages with OK. If the application has no such setting, it usually means it disallows sending messages this way._
#### 0-key:
- **In 123 mode:**
- **Press:** type "0".

View file

@ -192,7 +192,7 @@ public class TraditionalT9 extends KeyPadHandler {
public boolean onOK() {
if (isSuggestionViewHidden() && currentInputConnection != null) {
return sendDefaultEditorAction(false);
return performOKAction();
}
String word = mSuggestionView.getCurrentSuggestion();
@ -601,6 +601,20 @@ public class TraditionalT9 extends KeyPadHandler {
}
private boolean performOKAction() {
int action = textField.getAction();
switch (action) {
case EditorInfo.IME_ACTION_NONE:
return false;
case TextField.IME_ACTION_ENTER:
sendDownUpKeyEvents(KeyEvent.KEYCODE_ENTER);
return true;
default:
return currentInputConnection.performEditorAction(action);
}
}
private void showAddWord() {
if (currentInputConnection == null) {
return;

View file

@ -18,6 +18,8 @@ import io.github.sspanak.tt9.Logger;
import io.github.sspanak.tt9.ime.modes.InputMode;
public class TextField {
public static final int IME_ACTION_ENTER = EditorInfo.IME_MASK_ACTION + 1;
private static final Pattern beforeCursorWordRegex = Pattern.compile("(\\w+)(?!\n)$");
private static final Pattern afterCursorWordRegex = Pattern.compile("^(?<!\n)(\\w+)");
@ -297,4 +299,23 @@ public class TextField {
return styledWord;
}
public int getAction() {
if (field.actionId > 0) {
return field.actionId; // custom action, defined by the connected app
}
int standardAction = field.imeOptions & (EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION);
switch (standardAction) {
case EditorInfo.IME_ACTION_GO:
case EditorInfo.IME_ACTION_NEXT:
case EditorInfo.IME_ACTION_PREVIOUS:
case EditorInfo.IME_ACTION_SEARCH:
case EditorInfo.IME_ACTION_SEND:
return standardAction;
default:
return IME_ACTION_ENTER;
}
}
}