aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-06-24 03:53:22 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-06-24 01:59:00 +0000
commitd700e5970049deee7f61aeb573ef42d7caa6ab0f (patch)
tree0284cf832d29d6dc6af1c0ee7c99de5e7b1aa947 /java
parent132bdd079c2d45105263be6e9b7da3106b49a99a (diff)
parentdebe0dacbdfa9100038ab82aacb69fe961d2eebd (diff)
downloadlatinime-d700e5970049deee7f61aeb573ef42d7caa6ab0f.tar.gz
latinime-d700e5970049deee7f61aeb573ef42d7caa6ab0f.tar.xz
latinime-d700e5970049deee7f61aeb573ef42d7caa6ab0f.zip
Merge "Some cleanup to accommodate a fix"
Diffstat (limited to 'java')
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java19
1 files changed, 12 insertions, 7 deletions
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index 9462c385d..faa558257 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -733,8 +733,7 @@ public final class InputLogic {
sendKeyCodePoint(settingsValues, codePoint);
- if (swapWeakSpace) {
- swapSwapperAndSpace(inputTransaction);
+ if (swapWeakSpace && swapSwapperAndSpace(inputTransaction)) {
mSpaceState = SpaceState.WEAK;
}
// In case the "add to dictionary" hint was still displayed.
@@ -810,8 +809,6 @@ public final class InputLogic {
if (Constants.CODE_SPACE == codePoint) {
if (maybeDoubleSpacePeriod(inputTransaction)) {
- inputTransaction.requireShiftUpdate(InputTransaction.SHIFT_UPDATE_NOW);
- inputTransaction.setRequiresUpdateSuggestions();
mSpaceState = SpaceState.DOUBLE;
} else if (!mSuggestedWords.isPunctuationSuggestions()) {
mSpaceState = SpaceState.WEAK;
@@ -823,8 +820,9 @@ public final class InputLogic {
}
} else {
if (swapWeakSpace) {
- swapSwapperAndSpace(inputTransaction);
- mSpaceState = SpaceState.SWAP_PUNCTUATION;
+ if (swapSwapperAndSpace(inputTransaction)) {
+ mSpaceState = SpaceState.SWAP_PUNCTUATION;
+ }
} else if ((SpaceState.PHANTOM == inputTransaction.mSpaceState
&& settingsValues.isUsuallyFollowedBySpace(codePoint))
|| (Constants.CODE_DOUBLE_QUOTE == codePoint
@@ -1008,8 +1006,9 @@ public final class InputLogic {
* This method will check that there are two characters before the cursor and that the first
* one is a space before it does the actual swapping.
* @param inputTransaction The transaction in progress.
+ * @return true if the swap has been performed, false if it was prevented by preliminary checks.
*/
- private void swapSwapperAndSpace(final InputTransaction inputTransaction) {
+ private boolean swapSwapperAndSpace(final InputTransaction inputTransaction) {
final CharSequence lastTwo = mConnection.getTextBeforeCursor(2, 0);
// It is guaranteed lastTwo.charAt(1) is a swapper - else this method is not called.
if (lastTwo != null && lastTwo.length() == 2 && lastTwo.charAt(0) == Constants.CODE_SPACE) {
@@ -1017,7 +1016,9 @@ public final class InputLogic {
final String text = lastTwo.charAt(1) + " ";
mConnection.commitText(text, 1);
inputTransaction.requireShiftUpdate(InputTransaction.SHIFT_UPDATE_NOW);
+ return true;
}
+ return false;
}
/*
@@ -1078,6 +1079,8 @@ public final class InputLogic {
*/
private boolean maybeDoubleSpacePeriod(final InputTransaction inputTransaction) {
if (!inputTransaction.mSettingsValues.mUseDoubleSpacePeriod) return false;
+ // This can't happen right now because we don't call this method when the code is not space
+ if (Constants.CODE_SPACE != inputTransaction.mEvent.mCodePoint) return false;
if (!isDoubleSpacePeriodCountdownActive(inputTransaction)) return false;
// We only do this when we see two spaces and an accepted code point before the cursor.
// The code point may be a surrogate pair but the two spaces may not, so we need 4 chars.
@@ -1099,6 +1102,8 @@ public final class InputLogic {
final String textToInsert = inputTransaction.mSettingsValues.mSpacingAndPunctuations
.mSentenceSeparatorAndSpace;
mConnection.commitText(textToInsert, 1);
+ inputTransaction.requireShiftUpdate(InputTransaction.SHIFT_UPDATE_NOW);
+ inputTransaction.setRequiresUpdateSuggestions();
return true;
}
return false;