am cbed462d: [CB12] Reset the combining state when resetting the composer
* commit 'cbed462d192d0c5af9614f5f997b2768f3d0eb56': [CB12] Reset the combining state when resetting the composermain
commit
8e73ea1aa5
|
@ -40,4 +40,9 @@ public interface Combiner {
|
||||||
* @return A CharSequence representing the feedback to show users. It may include styles.
|
* @return A CharSequence representing the feedback to show users. It may include styles.
|
||||||
*/
|
*/
|
||||||
CharSequence getCombiningStateFeedback();
|
CharSequence getCombiningStateFeedback();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the state of this combiner, for example when the cursor was moved.
|
||||||
|
*/
|
||||||
|
void reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,14 @@ public class CombinerChain {
|
||||||
mStateFeedback = new SpannableStringBuilder();
|
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.
|
* Pass a new event through the whole chain.
|
||||||
* @param previousEvents the list of previous events in this composition
|
* @param previousEvents the list of previous events in this composition
|
||||||
|
|
|
@ -62,6 +62,11 @@ public class DeadKeyCombiner implements Combiner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset() {
|
||||||
|
mDeadSequence.setLength(0);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getCombiningStateFeedback() {
|
public CharSequence getCombiningStateFeedback() {
|
||||||
return mDeadSequence;
|
return mDeadSequence;
|
||||||
|
|
|
@ -127,6 +127,7 @@ public final class WordComposer {
|
||||||
* Clear out the keys registered so far.
|
* Clear out the keys registered so far.
|
||||||
*/
|
*/
|
||||||
public void reset() {
|
public void reset() {
|
||||||
|
mCombinerChain.reset();
|
||||||
mTypedWord.setLength(0);
|
mTypedWord.setLength(0);
|
||||||
mEvents.clear();
|
mEvents.clear();
|
||||||
mAutoCorrection = null;
|
mAutoCorrection = null;
|
||||||
|
@ -246,6 +247,8 @@ public final class WordComposer {
|
||||||
* @return true if the cursor is still inside the composing word, false otherwise.
|
* @return true if the cursor is still inside the composing word, false otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean moveCursorByAndReturnIfInsideComposingWord(final int expectedMoveAmount) {
|
public boolean moveCursorByAndReturnIfInsideComposingWord(final int expectedMoveAmount) {
|
||||||
|
// TODO: should uncommit the composing feedback
|
||||||
|
mCombinerChain.reset();
|
||||||
int actualMoveAmountWithinWord = 0;
|
int actualMoveAmountWithinWord = 0;
|
||||||
int cursorPos = mCursorPositionWithinWord;
|
int cursorPos = mCursorPositionWithinWord;
|
||||||
final int[] codePoints;
|
final int[] codePoints;
|
||||||
|
@ -485,6 +488,7 @@ public final class WordComposer {
|
||||||
mIsBatchMode = false;
|
mIsBatchMode = false;
|
||||||
mPreviousWordForSuggestion = committedWord.toString();
|
mPreviousWordForSuggestion = committedWord.toString();
|
||||||
mTypedWord.setLength(0);
|
mTypedWord.setLength(0);
|
||||||
|
mCombinerChain.reset();
|
||||||
mEvents.clear();
|
mEvents.clear();
|
||||||
mCodePointSize = 0;
|
mCodePointSize = 0;
|
||||||
mTrailingSingleQuotesCount = 0;
|
mTrailingSingleQuotesCount = 0;
|
||||||
|
@ -512,6 +516,7 @@ public final class WordComposer {
|
||||||
Collections.copy(mEvents, lastComposedWord.mEvents);
|
Collections.copy(mEvents, lastComposedWord.mEvents);
|
||||||
mInputPointers.set(lastComposedWord.mInputPointers);
|
mInputPointers.set(lastComposedWord.mInputPointers);
|
||||||
mTypedWord.setLength(0);
|
mTypedWord.setLength(0);
|
||||||
|
mCombinerChain.reset();
|
||||||
mTypedWord.append(lastComposedWord.mTypedWord);
|
mTypedWord.append(lastComposedWord.mTypedWord);
|
||||||
refreshSize();
|
refreshSize();
|
||||||
mCapitalizedMode = lastComposedWord.mCapitalizedMode;
|
mCapitalizedMode = lastComposedWord.mCapitalizedMode;
|
||||||
|
|
|
@ -23,10 +23,16 @@ import java.util.ArrayList;
|
||||||
public class CombinerChain {
|
public class CombinerChain {
|
||||||
private StringBuilder mComposingWord = new StringBuilder();
|
private StringBuilder mComposingWord = new StringBuilder();
|
||||||
public CombinerChain(final Combiner... combinerList) {}
|
public CombinerChain(final Combiner... combinerList) {}
|
||||||
|
|
||||||
public void processEvent(final ArrayList<Event> previousEvents, final Event newEvent) {
|
public void processEvent(final ArrayList<Event> previousEvents, final Event newEvent) {
|
||||||
mComposingWord.append(newEvent.getTextToCommit());
|
mComposingWord.append(newEvent.getTextToCommit());
|
||||||
}
|
}
|
||||||
|
|
||||||
public CharSequence getComposingWordWithCombiningFeedback() {
|
public CharSequence getComposingWordWithCombiningFeedback() {
|
||||||
return mComposingWord;
|
return mComposingWord;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
mComposingWord.setLength(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue