diff options
Diffstat (limited to 'java/src/com/android/inputmethod/event')
-rw-r--r-- | java/src/com/android/inputmethod/event/Event.java | 34 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/event/InputTransaction.java | 15 |
2 files changed, 38 insertions, 11 deletions
diff --git a/java/src/com/android/inputmethod/event/Event.java b/java/src/com/android/inputmethod/event/Event.java index 31092f176..ed487e13f 100644 --- a/java/src/com/android/inputmethod/event/Event.java +++ b/java/src/com/android/inputmethod/event/Event.java @@ -120,6 +120,34 @@ public class Event { FLAG_DEAD, next); } + /** + * Create an input event with nothing but a code point. This is the most basic possible input + * event; it contains no information on many things the IME requires to function correctly, + * so avoid using it unless really nothing is known about this input. + * @param codePoint the code point. + * @return an event for this code point. + */ + public static Event createEventForCodePointFromUnknownSource(final int codePoint) { + // TODO: should we have a different type of event for this? After all, it's not a key press. + return new Event(EVENT_INPUT_KEYPRESS, codePoint, NOT_A_KEY_CODE, + Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, FLAG_NONE, null /* next */); + } + + /** + * Creates an input event with a code point and x, y coordinates. This is typically used when + * resuming a previously-typed word, when the coordinates are still known. + * @param codePoint the code point to input. + * @param x the X coordinate. + * @param y the Y coordinate. + * @return an event for this code point and coordinates. + */ + public static Event createEventForCodePointFromAlreadyTypedText(final int codePoint, + final int x, final int y) { + // TODO: should we have a different type of event for this? After all, it's not a key press. + return new Event(EVENT_INPUT_KEYPRESS, codePoint, NOT_A_KEY_CODE, x, y, FLAG_NONE, + null /* next */); + } + public static Event createNotHandledEvent() { return new Event(EVENT_NOT_HANDLED, NOT_A_CODE_POINT, NOT_A_KEY_CODE, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, FLAG_NONE, null); @@ -130,6 +158,12 @@ public class Event { return 0 != (FLAG_DEAD & mFlags); } + // Returns whether this is a fake key press from the suggestion strip. This happens with + // punctuation signs selected from the suggestion strip. + public boolean isSuggestionStripPress() { + return EVENT_INPUT_KEYPRESS == mType && Constants.SUGGESTION_STRIP_COORDINATE == mX; + } + // TODO: remove this method - we should not have to test this public boolean isCommittable() { return EVENT_INPUT_KEYPRESS == mType || EVENT_MODE_KEY == mType || EVENT_TOGGLE == mType; diff --git a/java/src/com/android/inputmethod/event/InputTransaction.java b/java/src/com/android/inputmethod/event/InputTransaction.java index 3f709a674..2e9014f20 100644 --- a/java/src/com/android/inputmethod/event/InputTransaction.java +++ b/java/src/com/android/inputmethod/event/InputTransaction.java @@ -33,11 +33,7 @@ public class InputTransaction { // Initial conditions public final SettingsValues mSettingsValues; - // If the key inserts a code point, mKeyCode is always equal to the code points. Otherwise, - // it's always a code that may not be a code point, typically a negative number. - public final int mKeyCode; - public final int mX; // Pressed x-coordinate, or one of Constants.*_COORDINATE - public final int mY; // Pressed y-coordinate, or one of Constants.*_COORDINATE + public final Event mEvent; public final long mTimestamp; public final int mSpaceState; public final int mShiftState; @@ -45,13 +41,10 @@ public class InputTransaction { // Outputs private int mRequiredShiftUpdate = SHIFT_NO_UPDATE; - public InputTransaction(final SettingsValues settingsValues, final int keyCode, - final int x, final int y, final long timestamp, final int spaceState, - final int shiftState) { + public InputTransaction(final SettingsValues settingsValues, final Event event, + final long timestamp, final int spaceState, final int shiftState) { mSettingsValues = settingsValues; - mKeyCode = keyCode; - mX = x; - mY = y; + mEvent = event; mTimestamp = timestamp; mSpaceState = spaceState; mShiftState = shiftState; |