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.
|
// 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)
|
// 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.
|
// 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");
|
Logger.d("onBackspace", "backspace ignored");
|
||||||
mInputMode.reset();
|
mInputMode.reset();
|
||||||
return false;
|
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.
|
* 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() {
|
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) {
|
public boolean onBackspace(InputMode inputMode) {
|
||||||
if (isKindleInvertedTextField()) {
|
if (isKindleInvertedTextField()) {
|
||||||
inputMode.clearWordStem();
|
inputMode.clearWordStem();
|
||||||
return true;
|
|
||||||
} else if (isTermux()) {
|
} else if (isTermux()) {
|
||||||
return settings.getKeyBackspace() != KeyEvent.KEYCODE_BACK;
|
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
|
* getStringBeforeCursor
|
||||||
* A simplified helper that return up to 50 characters before the cursor and "just works".
|
* 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