Decompose accented characters
Characters like 'é' or 'î' are not resolved by getEvents(). For example,
getEvents("é") returns null.
However, it is possible to decompose them. For example,
getEvents("\u0301e") returns the events generating "é".
Thank you Philippe! ;)
This commit is contained in:
@@ -94,9 +94,13 @@ public class EventController {
|
||||
}
|
||||
|
||||
private boolean injectText(String text) {
|
||||
return injectText(text, true);
|
||||
}
|
||||
|
||||
private boolean injectText(String text, boolean decomposeOnFailure) {
|
||||
KeyEvent[] events = charMap.getEvents(text.toCharArray());
|
||||
if (events == null) {
|
||||
return false;
|
||||
return decomposeOnFailure ? injectDecomposition(text) : false;
|
||||
}
|
||||
for (KeyEvent event : events) {
|
||||
if (!injectEvent(event)) {
|
||||
@@ -106,6 +110,16 @@ public class EventController {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean injectDecomposition(String text) {
|
||||
for (char c : text.toCharArray()) {
|
||||
String composedText = KeyComposition.decompose(c);
|
||||
if (composedText == null || !injectText(composedText, false)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean injectMouse(int action, int buttons, Position position) {
|
||||
long now = SystemClock.uptimeMillis();
|
||||
if (action == MotionEvent.ACTION_DOWN) {
|
||||
|
||||
Reference in New Issue
Block a user