diff options
author | 2012-06-12 11:23:22 -0700 | |
---|---|---|
committer | 2012-06-12 11:23:22 -0700 | |
commit | 9224b437b00f60f589636b4ff97c4c8cf944e033 (patch) | |
tree | c559f01c3d7ac330b7b26e0be80b3f81b1d35411 /java/src/com/android/inputmethod/latin/RichInputConnection.java | |
parent | 4c8cee05ac21db9db1fd6a40251658596d83348e (diff) | |
parent | 2010aad741bc1a7266913bcb8b8348d6e401c95b (diff) | |
download | latinime-9224b437b00f60f589636b4ff97c4c8cf944e033.tar.gz latinime-9224b437b00f60f589636b4ff97c4c8cf944e033.tar.xz latinime-9224b437b00f60f589636b4ff97c4c8cf944e033.zip |
Merge "Move two methods in a more appropriate place"
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; + } } |