[AC7] Actually auto-commit.
Bug: 9059617 Change-Id: I7e5d89a9037b9181a0a6456c12043b4bfda8fe4bmain
parent
7bcb151342
commit
e8754aba1c
|
@ -186,7 +186,7 @@ public final class BinaryDictionary extends Dictionary {
|
||||||
// flags too and pass mOutputTypes[j] instead of kind
|
// flags too and pass mOutputTypes[j] instead of kind
|
||||||
suggestions.add(new SuggestedWordInfo(new String(mOutputCodePoints, start, len),
|
suggestions.add(new SuggestedWordInfo(new String(mOutputCodePoints, start, len),
|
||||||
score, kind, this /* sourceDict */,
|
score, kind, this /* sourceDict */,
|
||||||
mSpaceIndices[0] /* indexOfTouchPointOfSecondWord */,
|
mSpaceIndices[j] /* indexOfTouchPointOfSecondWord */,
|
||||||
mOutputAutoCommitFirstWordConfidence[0]));
|
mOutputAutoCommitFirstWordConfidence[0]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,6 +105,17 @@ public final class InputPointers {
|
||||||
mTimes.append(times, startPos, length);
|
mTimes.append(times, startPos, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shift to the left by elementCount, discarding elementCount pointers at the start.
|
||||||
|
* @param elementCount how many elements to shift.
|
||||||
|
*/
|
||||||
|
public void shift(final int elementCount) {
|
||||||
|
mXCoordinates.shift(elementCount);
|
||||||
|
mYCoordinates.shift(elementCount);
|
||||||
|
mPointerIds.shift(elementCount);
|
||||||
|
mTimes.shift(elementCount);
|
||||||
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
final int defaultCapacity = mDefaultCapacity;
|
final int defaultCapacity = mDefaultCapacity;
|
||||||
mXCoordinates.reset(defaultCapacity);
|
mXCoordinates.reset(defaultCapacity);
|
||||||
|
|
|
@ -1847,10 +1847,18 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdateBatchInput(final InputPointers batchPointers) {
|
public void onUpdateBatchInput(final InputPointers batchPointers) {
|
||||||
final SuggestedWordInfo candidate = mSuggestedWords.getAutoCommitCandidate();
|
if (mSettings.getCurrent().mPhraseGestureEnabled) {
|
||||||
if (null != candidate) {
|
final SuggestedWordInfo candidate = mSuggestedWords.getAutoCommitCandidate();
|
||||||
if (candidate.mSourceDict.shouldAutoCommit(candidate)) {
|
if (null != candidate) {
|
||||||
// TODO: implement auto-commit
|
if (candidate.mSourceDict.shouldAutoCommit(candidate)) {
|
||||||
|
final String[] commitParts = candidate.mWord.split(" ", 2);
|
||||||
|
batchPointers.shift(candidate.mIndexOfTouchPointOfSecondWord);
|
||||||
|
promotePhantomSpace();
|
||||||
|
mConnection.commitText(commitParts[0], 0);
|
||||||
|
mSpaceState = SPACE_STATE_PHANTOM;
|
||||||
|
mKeyboardSwitcher.updateShiftState();
|
||||||
|
mWordComposer.setCapitalizedModeAtStartComposingTime(getActualCapsMode());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mInputUpdater.onUpdateBatchInput(batchPointers);
|
mInputUpdater.onUpdateBatchInput(batchPointers);
|
||||||
|
@ -1863,12 +1871,23 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
if (TextUtils.isEmpty(batchInputText)) {
|
if (TextUtils.isEmpty(batchInputText)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mWordComposer.setBatchInputWord(batchInputText);
|
|
||||||
mConnection.beginBatchEdit();
|
mConnection.beginBatchEdit();
|
||||||
if (SPACE_STATE_PHANTOM == mSpaceState) {
|
if (SPACE_STATE_PHANTOM == mSpaceState) {
|
||||||
promotePhantomSpace();
|
promotePhantomSpace();
|
||||||
}
|
}
|
||||||
mConnection.setComposingText(batchInputText, 1);
|
if (mSettings.getCurrent().mPhraseGestureEnabled) {
|
||||||
|
// Find the last space
|
||||||
|
final int indexOfLastSpace = batchInputText.lastIndexOf(Constants.CODE_SPACE) + 1;
|
||||||
|
if (0 != indexOfLastSpace) {
|
||||||
|
mConnection.commitText(batchInputText.substring(0, indexOfLastSpace), 1);
|
||||||
|
}
|
||||||
|
final String lastWord = batchInputText.substring(indexOfLastSpace);
|
||||||
|
mWordComposer.setBatchInputWord(lastWord);
|
||||||
|
mConnection.setComposingText(lastWord, 1);
|
||||||
|
} else {
|
||||||
|
mWordComposer.setBatchInputWord(batchInputText);
|
||||||
|
mConnection.setComposingText(batchInputText, 1);
|
||||||
|
}
|
||||||
mExpectingUpdateSelection = true;
|
mExpectingUpdateSelection = true;
|
||||||
mConnection.endBatchEdit();
|
mConnection.endBatchEdit();
|
||||||
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
|
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
|
||||||
|
|
|
@ -132,6 +132,15 @@ public final class ResizableIntArray {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shift to the left by elementCount, discarding elementCount pointers at the start.
|
||||||
|
* @param elementCount how many elements to shift.
|
||||||
|
*/
|
||||||
|
public void shift(final int elementCount) {
|
||||||
|
System.arraycopy(mArray, elementCount, mArray, 0, mLength - elementCount);
|
||||||
|
mLength -= elementCount;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
|
|
@ -244,4 +244,20 @@ public class InputPointersTests extends AndroidTestCase {
|
||||||
expecteds[i + expectedPos], actuals[i + actualPos]);
|
expecteds[i + expectedPos], actuals[i + actualPos]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testShift() {
|
||||||
|
final InputPointers src = new InputPointers(DEFAULT_CAPACITY);
|
||||||
|
final int limit = 100;
|
||||||
|
final int shiftAmount = 20;
|
||||||
|
for (int i = 0; i < limit; i++) {
|
||||||
|
src.addPointer(i, i * 2, i * 3, i * 4);
|
||||||
|
}
|
||||||
|
src.shift(shiftAmount);
|
||||||
|
for (int i = 0; i < limit - shiftAmount; ++i) {
|
||||||
|
assertEquals("xCoordinates at " + i, i + shiftAmount, src.getXCoordinates()[i]);
|
||||||
|
assertEquals("yCoordinates at " + i, (i + shiftAmount) * 2, src.getYCoordinates()[i]);
|
||||||
|
assertEquals("pointerIds at " + i, (i + shiftAmount) * 3, src.getPointerIds()[i]);
|
||||||
|
assertEquals("times at " + i, (i + shiftAmount) * 4, src.getTimes()[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -340,4 +340,18 @@ public class ResizableIntArrayTests extends AndroidTestCase {
|
||||||
expecteds[i + expectedPos], actuals[i + actualPos]);
|
expecteds[i + expectedPos], actuals[i + actualPos]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testShift() {
|
||||||
|
final ResizableIntArray src = new ResizableIntArray(DEFAULT_CAPACITY);
|
||||||
|
final int limit = DEFAULT_CAPACITY * 10;
|
||||||
|
final int shiftAmount = 20;
|
||||||
|
for (int i = 0; i < limit; ++i) {
|
||||||
|
src.add(i, i);
|
||||||
|
assertEquals("length after add at " + i, i + 1, src.getLength());
|
||||||
|
}
|
||||||
|
src.shift(shiftAmount);
|
||||||
|
for (int i = 0; i < limit - shiftAmount; ++i) {
|
||||||
|
assertEquals("value at " + i, i + shiftAmount, src.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue