aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-03-20 17:55:30 +0900
committerJean Chalard <jchalard@google.com>2014-03-24 17:44:31 +0900
commitcbed462d192d0c5af9614f5f997b2768f3d0eb56 (patch)
tree32d4be045e1db74f09d6ebba22af42ee6ae817ac
parent628a64847c3313e36e21e6d2a4960c7aace989c7 (diff)
downloadlatinime-cbed462d192d0c5af9614f5f997b2768f3d0eb56.tar.gz
latinime-cbed462d192d0c5af9614f5f997b2768f3d0eb56.tar.xz
latinime-cbed462d192d0c5af9614f5f997b2768f3d0eb56.zip
[CB12] Reset the combining state when resetting the composer
Bug: 13406701 Change-Id: I490574b7ca4b953f67dd2c0ef97401297fade0a4
-rw-r--r--java/src/com/android/inputmethod/event/Combiner.java5
-rw-r--r--java/src/com/android/inputmethod/event/CombinerChain.java8
-rw-r--r--java/src/com/android/inputmethod/event/DeadKeyCombiner.java5
-rw-r--r--java/src/com/android/inputmethod/latin/WordComposer.java5
-rw-r--r--tools/dicttool/compat/com/android/inputmethod/event/CombinerChain.java6
5 files changed, 29 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/event/Combiner.java b/java/src/com/android/inputmethod/event/Combiner.java
index bdc761234..8b808c6b3 100644
--- a/java/src/com/android/inputmethod/event/Combiner.java
+++ b/java/src/com/android/inputmethod/event/Combiner.java
@@ -40,4 +40,9 @@ public interface Combiner {
* @return A CharSequence representing the feedback to show users. It may include styles.
*/
CharSequence getCombiningStateFeedback();
+
+ /**
+ * Reset the state of this combiner, for example when the cursor was moved.
+ */
+ void reset();
}
diff --git a/java/src/com/android/inputmethod/event/CombinerChain.java b/java/src/com/android/inputmethod/event/CombinerChain.java
index cf2a4d1a1..5ca9842c1 100644
--- a/java/src/com/android/inputmethod/event/CombinerChain.java
+++ b/java/src/com/android/inputmethod/event/CombinerChain.java
@@ -58,6 +58,14 @@ public class CombinerChain {
mStateFeedback = new SpannableStringBuilder();
}
+ public void reset() {
+ mCombinedText.setLength(0);
+ mStateFeedback.clear();
+ for (final Combiner c : mCombiners) {
+ c.reset();
+ }
+ }
+
/**
* Pass a new event through the whole chain.
* @param previousEvents the list of previous events in this composition
diff --git a/java/src/com/android/inputmethod/event/DeadKeyCombiner.java b/java/src/com/android/inputmethod/event/DeadKeyCombiner.java
index f891017a3..89e623a1d 100644
--- a/java/src/com/android/inputmethod/event/DeadKeyCombiner.java
+++ b/java/src/com/android/inputmethod/event/DeadKeyCombiner.java
@@ -63,6 +63,11 @@ public class DeadKeyCombiner implements Combiner {
}
@Override
+ public void reset() {
+ mDeadSequence.setLength(0);
+ }
+
+ @Override
public CharSequence getCombiningStateFeedback() {
return mDeadSequence;
}
diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java
index d55a773b4..78990e011 100644
--- a/java/src/com/android/inputmethod/latin/WordComposer.java
+++ b/java/src/com/android/inputmethod/latin/WordComposer.java
@@ -127,6 +127,7 @@ public final class WordComposer {
* Clear out the keys registered so far.
*/
public void reset() {
+ mCombinerChain.reset();
mTypedWord.setLength(0);
mEvents.clear();
mAutoCorrection = null;
@@ -246,6 +247,8 @@ public final class WordComposer {
* @return true if the cursor is still inside the composing word, false otherwise.
*/
public boolean moveCursorByAndReturnIfInsideComposingWord(final int expectedMoveAmount) {
+ // TODO: should uncommit the composing feedback
+ mCombinerChain.reset();
int actualMoveAmountWithinWord = 0;
int cursorPos = mCursorPositionWithinWord;
final int[] codePoints;
@@ -485,6 +488,7 @@ public final class WordComposer {
mIsBatchMode = false;
mPreviousWordForSuggestion = committedWord.toString();
mTypedWord.setLength(0);
+ mCombinerChain.reset();
mEvents.clear();
mCodePointSize = 0;
mTrailingSingleQuotesCount = 0;
@@ -512,6 +516,7 @@ public final class WordComposer {
Collections.copy(mEvents, lastComposedWord.mEvents);
mInputPointers.set(lastComposedWord.mInputPointers);
mTypedWord.setLength(0);
+ mCombinerChain.reset();
mTypedWord.append(lastComposedWord.mTypedWord);
refreshSize();
mCapitalizedMode = lastComposedWord.mCapitalizedMode;
diff --git a/tools/dicttool/compat/com/android/inputmethod/event/CombinerChain.java b/tools/dicttool/compat/com/android/inputmethod/event/CombinerChain.java
index e70ede4d3..b68df1ce7 100644
--- a/tools/dicttool/compat/com/android/inputmethod/event/CombinerChain.java
+++ b/tools/dicttool/compat/com/android/inputmethod/event/CombinerChain.java
@@ -23,10 +23,16 @@ import java.util.ArrayList;
public class CombinerChain {
private StringBuilder mComposingWord = new StringBuilder();
public CombinerChain(final Combiner... combinerList) {}
+
public void processEvent(final ArrayList<Event> previousEvents, final Event newEvent) {
mComposingWord.append(newEvent.getTextToCommit());
}
+
public CharSequence getComposingWordWithCombiningFeedback() {
return mComposingWord;
}
+
+ public void reset() {
+ mComposingWord.setLength(0);
+ }
}