fixed combined Back/Backspace key not navigating back when the cursor is at the beginning of the field; fixed general issues with navigating back in Amazon Kindle app
This commit is contained in:
parent
f13297f6b9
commit
c6c1874335
3 changed files with 13 additions and 12 deletions
|
|
@ -92,7 +92,8 @@ public abstract class TypingHandler extends KeyPadHandler {
|
|||
// otherwise, keyDown race condition occur for all keys.
|
||||
// 2. Allow the assigned key to function normally, when there is no text (e.g. "Back" navigates back)
|
||||
// 3. Some app may need special treatment, so let it be.
|
||||
if (mInputMode.isPassthrough() || !(textField.isThereText() || appHacks.onBackspace(mInputMode))) {
|
||||
boolean noTextBeforeCursor = textField.getStringBeforeCursor(1).isEmpty();
|
||||
if (mInputMode.isPassthrough() || noTextBeforeCursor || appHacks.onBackspace(mInputMode)) {
|
||||
Logger.d("onBackspace", "backspace ignored");
|
||||
mInputMode.reset();
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,17 @@ public class AppHacks {
|
|||
* weird side effects occur. Nevertheless, all other text fields in the app are fine, so we detect only these two particular ones.
|
||||
*/
|
||||
private boolean isKindleInvertedTextField() {
|
||||
return isAppField("com.amazon.kindle", EditorInfo.TYPE_CLASS_TEXT);
|
||||
int titleImeOptions = EditorInfo.IME_ACTION_NONE | EditorInfo.IME_ACTION_SEND | EditorInfo.IME_FLAG_NAVIGATE_NEXT;
|
||||
int titleAlternativeImeOptions = titleImeOptions | EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS; // sometimes the title field is different for no reason
|
||||
int authorImeOptions = EditorInfo.IME_ACTION_SEND | EditorInfo.IME_ACTION_GO | EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS;
|
||||
|
||||
return
|
||||
isAppField("com.amazon.kindle", EditorInfo.TYPE_CLASS_TEXT)
|
||||
&& (
|
||||
editorInfo.imeOptions == titleImeOptions
|
||||
|| editorInfo.imeOptions == titleAlternativeImeOptions
|
||||
|| editorInfo.imeOptions == authorImeOptions
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -107,7 +117,6 @@ public class AppHacks {
|
|||
public boolean onBackspace(InputMode inputMode) {
|
||||
if (isKindleInvertedTextField()) {
|
||||
inputMode.clearWordStem();
|
||||
return true;
|
||||
} else if (isTermux()) {
|
||||
return settings.getKeyBackspace() != KeyEvent.KEYCODE_BACK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,15 +137,6 @@ public class TextField {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* getStringAfterCursor
|
||||
* A simplified helper that return up to 50 characters after the cursor and "just works".
|
||||
*/
|
||||
public String getStringAfterCursor() {
|
||||
return getStringAfterCursor(50);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getStringBeforeCursor
|
||||
* A simplified helper that return up to 50 characters before the cursor and "just works".
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue