aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-02-22 00:15:10 -0800
committerJean Chalard <jchalard@google.com>2012-02-22 00:59:01 -0800
commitbdf89ce5feedb03e67b43f530b1eb9bd44203c63 (patch)
tree3e29381e9e6cba04005a9720b2a0746880d25636 /java/src
parent2aa16dd81f50aa7737bd77b3ca9cfcf27b6cc048 (diff)
downloadlatinime-bdf89ce5feedb03e67b43f530b1eb9bd44203c63.tar.gz
latinime-bdf89ce5feedb03e67b43f530b1eb9bd44203c63.tar.xz
latinime-bdf89ce5feedb03e67b43f530b1eb9bd44203c63.zip
Rename cancelAutoCorrect to cancelCommit (A6)
Also remove a test in debug mode that would check for absence of a situation which is now expected. Change-Id: Ia5be350bc98a604b3bf8f6057652c5534f6a19af
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LastComposedWord.java2
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java23
2 files changed, 7 insertions, 18 deletions
diff --git a/java/src/com/android/inputmethod/latin/LastComposedWord.java b/java/src/com/android/inputmethod/latin/LastComposedWord.java
index cc1221bcb..ab624b2cb 100644
--- a/java/src/com/android/inputmethod/latin/LastComposedWord.java
+++ b/java/src/com/android/inputmethod/latin/LastComposedWord.java
@@ -72,7 +72,7 @@ public class LastComposedWord {
mActive = false;
}
- public boolean canCancelAutoCorrect() {
+ public boolean canCancelCommit() {
return mActive && !TextUtils.isEmpty(mCommittedWord);
}
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 6935f1946..840fd5df4 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1431,16 +1431,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
ic.deleteSurroundingText(1, 0);
}
} else {
- // We should be very careful about auto-correction cancellation and suggestion
- // resuming here. The behavior needs to be different according to text field types,
- // and it would be much clearer to test for them explicitly here rather than
- // relying on implicit values like "whether the suggestion strip is displayed".
- if (mLastComposedWord.canCancelAutoCorrect()) {
+ if (mLastComposedWord.canCancelCommit()) {
Utils.Stats.onAutoCorrectionCancellation();
- cancelAutoCorrect(ic);
+ cancelCommit(ic);
return;
}
-
if (SPACE_STATE_DOUBLE == spaceState) {
if (revertDoubleSpaceWhileInBatchEdit(ic)) {
// No need to reset mSpaceState, it has already be done (that's why we
@@ -2001,7 +1996,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
}
// TODO: figure out here if this is an auto-correct or if the best word is actually
// what user typed. Note: currently this is done much later in
- // LastComposedWord#canCancelAutoCorrect by string equality of the remembered
+ // LastComposedWord#didCommitTypedWord by string equality of the remembered
// strings.
mLastComposedWord = mWordComposer.commitWord(commitType, bestWord.toString(),
separatorCode);
@@ -2166,8 +2161,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
}
// "ic" must not be null
- // TODO: rename this method to cancelCommit.
- private void cancelAutoCorrect(final InputConnection ic) {
+ private void cancelCommit(final InputConnection ic) {
final String originallyTypedWord = mLastComposedWord.mTypedWord;
final CharSequence committedWord = mLastComposedWord.mCommittedWord;
final int cancelLength = committedWord.length();
@@ -2176,21 +2170,16 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
// TODO: should we check our saved separator against the actual contents of the text view?
if (DEBUG) {
if (mWordComposer.isComposingWord()) {
- throw new RuntimeException("cancelAutoCorrect, but we are composing a word");
+ throw new RuntimeException("cancelCommit, but we are composing a word");
}
final String wordBeforeCursor =
ic.getTextBeforeCursor(cancelLength + separatorLength, 0)
.subSequence(0, cancelLength).toString();
if (!TextUtils.equals(committedWord, wordBeforeCursor)) {
- throw new RuntimeException("cancelAutoCorrect check failed: we thought we were "
+ throw new RuntimeException("cancelCommit check failed: we thought we were "
+ "reverting \"" + committedWord
+ "\", but before the cursor we found \"" + wordBeforeCursor + "\"");
}
- if (TextUtils.equals(originallyTypedWord, wordBeforeCursor)) {
- throw new RuntimeException("cancelAutoCorrect check failed: we wanted to cancel "
- + "auto correction and revert to \"" + originallyTypedWord
- + "\" but we found this very string before the cursor");
- }
}
ic.deleteSurroundingText(cancelLength + separatorLength, 0);
if (0 == separatorLength || mLastComposedWord.didCommitTypedWord()) {