diff options
author | 2012-06-08 21:56:44 +0900 | |
---|---|---|
committer | 2012-06-12 10:29:55 +0900 | |
commit | 2010aad741bc1a7266913bcb8b8348d6e401c95b (patch) | |
tree | b7d35be28a3866f93454585ee5b135349b8bacfd /java/src/com/android/inputmethod/latin/RichInputConnection.java | |
parent | a32eb2721390d5964c83c787ad30fd3f61b936b0 (diff) | |
download | latinime-2010aad741bc1a7266913bcb8b8348d6e401c95b.tar.gz latinime-2010aad741bc1a7266913bcb8b8348d6e401c95b.tar.xz latinime-2010aad741bc1a7266913bcb8b8348d6e401c95b.zip |
Move two methods in a more appropriate place
Change-Id: I512b04e23490413a44b1ca0517102fe2d9138df3
Diffstat (limited to 'java/src/com/android/inputmethod/latin/RichInputConnection.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/RichInputConnection.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java index 5ca4a84b9..227990acc 100644 --- a/java/src/com/android/inputmethod/latin/RichInputConnection.java +++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java @@ -393,4 +393,30 @@ public class RichInputConnection { } return true; } + + public boolean revertSwapPunctuation() { + // Here we test whether we indeed have a space and something else before us. This should not + // be needed, but it's there just in case something went wrong. + final CharSequence textBeforeCursor = getTextBeforeCursor(2, 0); + // NOTE: This does not work with surrogate pairs. Hopefully when the keyboard is able to + // enter surrogate pairs this code will have been removed. + if (TextUtils.isEmpty(textBeforeCursor) + || (Keyboard.CODE_SPACE != textBeforeCursor.charAt(1))) { + // We may only come here if the application is changing the text while we are typing. + // This is quite a broken case, but not logically impossible, so we shouldn't crash, + // but some debugging log may be in order. + Log.d(TAG, "Tried to revert a swap of punctuation but we didn't " + + "find a space just before the cursor."); + return false; + } + deleteSurroundingText(2, 0); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_deleteSurroundingText(2); + } + commitText(" " + textBeforeCursor.subSequence(0, 1), 1); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_revertSwapPunctuation(); + } + return true; + } } |