am 534e25f2: am 4ac33aca: am b7dfacd3: Merge "Send backspace as an event when TYPE_NULL."
* commit '534e25f2e71cdc79f98aac851f7fcc6639eec166': Send backspace as an event when TYPE_NULL.main
commit
5e0699bc0c
|
@ -103,6 +103,10 @@ public final class InputAttributes {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isTypeNull() {
|
||||||
|
return InputType.TYPE_NULL == mInputType;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isSameInputType(final EditorInfo editorInfo) {
|
public boolean isSameInputType(final EditorInfo editorInfo) {
|
||||||
return editorInfo.inputType == mInputType;
|
return editorInfo.inputType == mInputType;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1521,7 +1521,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
mSubtypeState.switchSubtype(token, mRichImm);
|
mSubtypeState.switchSubtype(token, mRichImm);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendDownUpKeyEventForBackwardCompatibility(final int code) {
|
private void sendDownUpKeyEvent(final int code) {
|
||||||
final long eventTime = SystemClock.uptimeMillis();
|
final long eventTime = SystemClock.uptimeMillis();
|
||||||
mConnection.sendKeyEvent(new KeyEvent(eventTime, eventTime,
|
mConnection.sendKeyEvent(new KeyEvent(eventTime, eventTime,
|
||||||
KeyEvent.ACTION_DOWN, code, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0,
|
KeyEvent.ACTION_DOWN, code, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0,
|
||||||
|
@ -1538,7 +1538,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
// TODO: Remove this special handling of digit letters.
|
// TODO: Remove this special handling of digit letters.
|
||||||
// For backward compatibility. See {@link InputMethodService#sendKeyChar(char)}.
|
// For backward compatibility. See {@link InputMethodService#sendKeyChar(char)}.
|
||||||
if (code >= '0' && code <= '9') {
|
if (code >= '0' && code <= '9') {
|
||||||
sendDownUpKeyEventForBackwardCompatibility(code - '0' + KeyEvent.KEYCODE_0);
|
sendDownUpKeyEvent(code - '0' + KeyEvent.KEYCODE_0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1547,7 +1547,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
// a hardware keyboard event on pressing enter or delete. This is bad for many
|
// a hardware keyboard event on pressing enter or delete. This is bad for many
|
||||||
// reasons (there are race conditions with commits) but some applications are
|
// reasons (there are race conditions with commits) but some applications are
|
||||||
// relying on this behavior so we continue to support it for older apps.
|
// relying on this behavior so we continue to support it for older apps.
|
||||||
sendDownUpKeyEventForBackwardCompatibility(KeyEvent.KEYCODE_ENTER);
|
sendDownUpKeyEvent(KeyEvent.KEYCODE_ENTER);
|
||||||
} else {
|
} else {
|
||||||
final String text = new String(new int[] { code }, 0, 1);
|
final String text = new String(new int[] { code }, 0, 1);
|
||||||
mConnection.commitText(text, text.length());
|
mConnection.commitText(text, text.length());
|
||||||
|
@ -2104,12 +2104,16 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
}
|
}
|
||||||
final int lengthToDelete = Character.isSupplementaryCodePoint(
|
final int lengthToDelete = Character.isSupplementaryCodePoint(
|
||||||
mConnection.getCodePointBeforeCursor()) ? 2 : 1;
|
mConnection.getCodePointBeforeCursor()) ? 2 : 1;
|
||||||
if (mAppWorkAroundsUtils.isBeforeJellyBean()) {
|
if (mAppWorkAroundsUtils.isBeforeJellyBean() ||
|
||||||
// Backward compatibility mode. Before Jelly bean, the keyboard would simulate
|
currentSettings.mInputAttributes.isTypeNull()) {
|
||||||
// a hardware keyboard event on pressing enter or delete. This is bad for many
|
// There are two possible reasons to send a key event: either the field has
|
||||||
// reasons (there are race conditions with commits) but some applications are
|
// type TYPE_NULL, in which case the keyboard should send events, or we are
|
||||||
// relying on this behavior so we continue to support it for older apps.
|
// running in backward compatibility mode. Before Jelly bean, the keyboard
|
||||||
sendDownUpKeyEventForBackwardCompatibility(KeyEvent.KEYCODE_DEL);
|
// would simulate a hardware keyboard event on pressing enter or delete. This
|
||||||
|
// is bad for many reasons (there are race conditions with commits) but some
|
||||||
|
// applications are relying on this behavior so we continue to support it for
|
||||||
|
// older apps, so we retain this behavior if the app has target SDK < JellyBean.
|
||||||
|
sendDownUpKeyEvent(KeyEvent.KEYCODE_DEL);
|
||||||
} else {
|
} else {
|
||||||
mConnection.deleteSurroundingText(lengthToDelete, 0);
|
mConnection.deleteSurroundingText(lengthToDelete, 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue