aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/event
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-08-01 14:15:33 +0900
committerJean Chalard <jchalard@google.com>2014-08-04 12:41:07 +0900
commite0bad8e988a23553181fb670f8a2589a79f22c40 (patch)
tree6130ed94671d88523622f775d3e0b1cf773ec0e2 /java/src/com/android/inputmethod/event
parentc4696b2eb6b25eea4d5c869683104ab99aec0421 (diff)
downloadlatinime-e0bad8e988a23553181fb670f8a2589a79f22c40.tar.gz
latinime-e0bad8e988a23553181fb670f8a2589a79f22c40.tar.xz
latinime-e0bad8e988a23553181fb670f8a2589a79f22c40.zip
[HW12] Use the consumed status of the Event.
Change-Id: I1619f6132f8f71bc1291fd6a5604a5e1e3431ae2
Diffstat (limited to 'java/src/com/android/inputmethod/event')
-rw-r--r--java/src/com/android/inputmethod/event/CombinerChain.java18
-rw-r--r--java/src/com/android/inputmethod/event/DeadKeyCombiner.java8
-rw-r--r--java/src/com/android/inputmethod/event/Event.java4
3 files changed, 25 insertions, 5 deletions
diff --git a/java/src/com/android/inputmethod/event/CombinerChain.java b/java/src/com/android/inputmethod/event/CombinerChain.java
index f69bf4fd0..2d2731f21 100644
--- a/java/src/com/android/inputmethod/event/CombinerChain.java
+++ b/java/src/com/android/inputmethod/event/CombinerChain.java
@@ -82,6 +82,13 @@ public class CombinerChain {
}
}
+ private void updateStateFeedback() {
+ mStateFeedback.clear();
+ for (int i = mCombiners.size() - 1; i >= 0; --i) {
+ mStateFeedback.append(mCombiners.get(i).getCombiningStateFeedback());
+ }
+ }
+
/**
* Process an event through the combining chain, and return a processed event to apply.
* @param previousEvents the list of previous events in this composition
@@ -97,7 +104,13 @@ public class CombinerChain {
// A combiner can never return more than one event; it can return several
// code points, but they should be encapsulated within one event.
event = combiner.processEvent(modifiablePreviousEvents, event);
+ if (event.isConsumed()) {
+ // If the event is consumed, then we don't pass it to subsequent combiners:
+ // they should not see it at all.
+ break;
+ }
}
+ updateStateFeedback();
return event;
}
@@ -121,10 +134,7 @@ public class CombinerChain {
}
}
}
- mStateFeedback.clear();
- for (int i = mCombiners.size() - 1; i >= 0; --i) {
- mStateFeedback.append(mCombiners.get(i).getCombiningStateFeedback());
- }
+ updateStateFeedback();
}
/**
diff --git a/java/src/com/android/inputmethod/event/DeadKeyCombiner.java b/java/src/com/android/inputmethod/event/DeadKeyCombiner.java
index d816247d8..4f3f4d25f 100644
--- a/java/src/com/android/inputmethod/event/DeadKeyCombiner.java
+++ b/java/src/com/android/inputmethod/event/DeadKeyCombiner.java
@@ -36,10 +36,16 @@ public class DeadKeyCombiner implements Combiner {
@Nonnull
public Event processEvent(final ArrayList<Event> previousEvents, final Event event) {
if (TextUtils.isEmpty(mDeadSequence)) {
+ // No dead char is currently being tracked: this is the most common case.
if (event.isDead()) {
+ // The event was a dead key. Start tracking it.
mDeadSequence.appendCodePoint(event.mCodePoint);
+ return Event.createConsumedEvent(event);
}
- return Event.createConsumedEvent(event);
+ // Regular keystroke when not keeping track of a dead key. Simply said, there are
+ // no dead keys at all in the current input, so this combiner has nothing to do and
+ // simply returns the event as is. The majority of events will go through this path.
+ return event;
} else {
// TODO: Allow combining for several dead chars rather than only the first one.
// The framework doesn't know how to do this now.
diff --git a/java/src/com/android/inputmethod/event/Event.java b/java/src/com/android/inputmethod/event/Event.java
index 98c827423..f02f7885a 100644
--- a/java/src/com/android/inputmethod/event/Event.java
+++ b/java/src/com/android/inputmethod/event/Event.java
@@ -227,6 +227,7 @@ public class Event {
* @return an identical event marked as consumed.
*/
public static Event createConsumedEvent(final Event source) {
+ // A consumed event should not input any text at all, so we pass the empty string as text.
return new Event(source.mEventType, source.mText, source.mCodePoint, source.mKeyCode,
source.mX, source.mY, source.mSuggestedWordInfo, source.mFlags | FLAG_CONSUMED,
source.mNextEvent);
@@ -267,6 +268,9 @@ public class Event {
}
public CharSequence getTextToCommit() {
+ if (isConsumed()) {
+ return ""; // A consumed event should input no text.
+ }
switch (mEventType) {
case EVENT_TYPE_MODE_KEY:
case EVENT_TYPE_NOT_HANDLED: