Merge "Add a next Event (B2)"

main
Jean Chalard 2013-01-09 22:23:04 -08:00 committed by Android (Google) Code Review
commit 424d76fbf5
3 changed files with 24 additions and 22 deletions

View File

@ -61,23 +61,26 @@ public class Event {
// ctrl, there is no code point associated so this should be NOT_A_CODE_POINT to avoid
// unintentional use of its value when it's not relevant.
final public int mCodePoint;
// The next event, if any. Null if there is no next event yet.
final public Event mNextEvent;
// This method is private - to create a new event, use one of the create* utility methods.
private Event(final int type, final int codePoint) {
private Event(final int type, final int codePoint, final Event next) {
mType = type;
mCodePoint = codePoint;
mNextEvent = next;
}
public static Event createDeadEvent(final int codePoint) {
return new Event(EVENT_DEAD, codePoint);
public static Event createDeadEvent(final int codePoint, final Event next) {
return new Event(EVENT_DEAD, codePoint, next);
}
public static Event createCommittableEvent(final int codePoint) {
return new Event(EVENT_COMMITTABLE, codePoint);
public static Event createCommittableEvent(final int codePoint, final Event next) {
return new Event(EVENT_COMMITTABLE, codePoint, next);
}
public static Event createNotHandledEvent() {
return new Event(EVENT_NOT_HANDLED, NOT_A_CODE_POINT);
return new Event(EVENT_NOT_HANDLED, NOT_A_CODE_POINT, null);
}
public boolean isCommittable() {

View File

@ -106,19 +106,17 @@ public class EventInterpreter {
}
private boolean onEvent(final Event event) {
if (event.isCommittable()) {
mLatinIme.onCodeInput(event.mCodePoint,
Constants.EXTERNAL_KEYBOARD_COORDINATE, Constants.EXTERNAL_KEYBOARD_COORDINATE);
return true;
Event currentlyProcessingEvent = event;
boolean processed = false;
while (null != currentlyProcessingEvent) {
if (currentlyProcessingEvent.isCommittable()) {
mLatinIme.onCodeInput(currentlyProcessingEvent.mCodePoint,
Constants.EXTERNAL_KEYBOARD_COORDINATE,
Constants.EXTERNAL_KEYBOARD_COORDINATE);
processed = true;
}
currentlyProcessingEvent = currentlyProcessingEvent.mNextEvent;
}
// TODO: Classify the event - input or non-input (see design doc)
// TODO: IF action event
// Send decoded action back to LatinIME
// ELSE
// Send input event to the combiner
// Get back new input material + visual feedback + combiner state
// Route the event to Latin IME
// ENDIF
return false;
return processed;
}
}

View File

@ -47,17 +47,18 @@ public class HardwareKeyboardEventDecoder implements HardwareEventDecoder {
// the key for 'A' or Space, but also Backspace or Ctrl or Caps Lock.
final int keyCode = keyEvent.getKeyCode();
if (KeyEvent.KEYCODE_DEL == keyCode) {
return Event.createCommittableEvent(Constants.CODE_DELETE);
return Event.createCommittableEvent(Constants.CODE_DELETE, null /* next */);
}
if (keyEvent.isPrintingKey() || KeyEvent.KEYCODE_SPACE == keyCode
|| KeyEvent.KEYCODE_ENTER == keyCode) {
if (0 != (codePointAndFlags & KeyCharacterMap.COMBINING_ACCENT)) {
// A dead key.
return Event.createDeadEvent(codePointAndFlags & KeyCharacterMap.COMBINING_ACCENT_MASK);
return Event.createDeadEvent(
codePointAndFlags & KeyCharacterMap.COMBINING_ACCENT_MASK, null /* next */);
} else {
// A committable character. This should be committed right away, taking into
// account the current state.
return Event.createCommittableEvent(codePointAndFlags);
return Event.createCommittableEvent(codePointAndFlags, null /* next */);
}
} else {
return Event.createNotHandledEvent();