diff options
author | 2012-07-05 19:11:28 -0700 | |
---|---|---|
committer | 2012-07-05 19:11:28 -0700 | |
commit | 29eeef75ec6987f7cd82c70ba162376b77e4fde5 (patch) | |
tree | bad560a19fd675260343ff95c83021f5000d4d55 /java/src | |
parent | d81e7d24d384a2bb1aeda65d9b423e4b1d23f185 (diff) | |
parent | f254e3fec7744dc1eb2cc09ac157986c3b2b5408 (diff) | |
download | latinime-29eeef75ec6987f7cd82c70ba162376b77e4fde5.tar.gz latinime-29eeef75ec6987f7cd82c70ba162376b77e4fde5.tar.xz latinime-29eeef75ec6987f7cd82c70ba162376b77e4fde5.zip |
Merge "Fix a bug where the caps mode would not be changed"
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 10 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/RichInputConnection.java | 17 |
2 files changed, 19 insertions, 8 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index e7d1c53bd..80dda9c19 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -144,7 +144,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private LastComposedWord mLastComposedWord = LastComposedWord.NOT_A_COMPOSED_WORD; private WordComposer mWordComposer = new WordComposer(); - private RichInputConnection mConnection = new RichInputConnection(); + private RichInputConnection mConnection = new RichInputConnection(this); // Keep track of the last selection range to decide if we need to show word alternatives private static final int NOT_A_CURSOR_POSITION = -1; @@ -537,7 +537,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (mDisplayOrientation != conf.orientation) { mDisplayOrientation = conf.orientation; mHandler.startOrientationChanging(); - mConnection.beginBatchEdit(getCurrentInputConnection()); + mConnection.beginBatchEdit(); commitTyped(LastComposedWord.NOT_A_SEPARATOR); mConnection.finishComposingText(); mConnection.endBatchEdit(); @@ -1213,7 +1213,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mDeleteCount = 0; } mLastKeyTime = when; - mConnection.beginBatchEdit(getCurrentInputConnection()); + mConnection.beginBatchEdit(); if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.latinIME_onCodeInput(primaryCode, x, y); @@ -1298,7 +1298,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen @Override public void onTextInput(CharSequence text) { - mConnection.beginBatchEdit(getCurrentInputConnection()); + mConnection.beginBatchEdit(); commitTyped(LastComposedWord.NOT_A_SEPARATOR); text = specificTldProcessingOnTextInput(text); if (SPACE_STATE_PHANTOM == mSpaceState) { @@ -1819,7 +1819,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mKeyboardSwitcher.updateShiftState(); resetComposingState(true /* alsoResetLastComposedWord */); final CompletionInfo completionInfo = mApplicationSpecifiedCompletions[index]; - mConnection.beginBatchEdit(getCurrentInputConnection()); + mConnection.beginBatchEdit(); mConnection.commitCompletion(completionInfo); mConnection.endBatchEdit(); if (ProductionFlag.IS_EXPERIMENTAL) { diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java index 40d327ebb..a37f480b7 100644 --- a/java/src/com/android/inputmethod/latin/RichInputConnection.java +++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java @@ -16,6 +16,7 @@ package com.android.inputmethod.latin; +import android.inputmethodservice.InputMethodService; import android.text.TextUtils; import android.util.Log; import android.view.KeyEvent; @@ -41,16 +42,18 @@ public class RichInputConnection { private static final Pattern spaceRegex = Pattern.compile("\\s+"); private static final int INVALID_CURSOR_POSITION = -1; + private final InputMethodService mParent; InputConnection mIC; int mNestLevel; - public RichInputConnection() { + public RichInputConnection(final InputMethodService parent) { + mParent = parent; mIC = null; mNestLevel = 0; } - public void beginBatchEdit(final InputConnection newInputConnection) { + public void beginBatchEdit() { if (++mNestLevel == 1) { - mIC = newInputConnection; + mIC = mParent.getCurrentInputConnection(); if (null != mIC) mIC.beginBatchEdit(); } else { if (DBG) { @@ -84,16 +87,19 @@ public class RichInputConnection { } public int getCursorCapsMode(final int inputType) { + mIC = mParent.getCurrentInputConnection(); if (null == mIC) return Constants.TextUtils.CAP_MODE_OFF; return mIC.getCursorCapsMode(inputType); } public CharSequence getTextBeforeCursor(final int i, final int j) { + mIC = mParent.getCurrentInputConnection(); if (null != mIC) return mIC.getTextBeforeCursor(i, j); return null; } public CharSequence getTextAfterCursor(final int i, final int j) { + mIC = mParent.getCurrentInputConnection(); if (null != mIC) return mIC.getTextAfterCursor(i, j); return null; } @@ -104,6 +110,7 @@ public class RichInputConnection { } public void performEditorAction(final int actionId) { + mIC = mParent.getCurrentInputConnection(); if (null != mIC) mIC.performEditorAction(actionId); } @@ -133,6 +140,7 @@ public class RichInputConnection { } public CharSequence getPreviousWord(final String sentenceSeperators) { + mIC = mParent.getCurrentInputConnection(); //TODO: Should fix this. This could be slow! if (null == mIC) return null; CharSequence prev = mIC.getTextBeforeCursor(LOOKBACK_CHARACTER_NUM, 0); @@ -194,6 +202,7 @@ public class RichInputConnection { } public CharSequence getThisWord(String sentenceSeperators) { + mIC = mParent.getCurrentInputConnection(); if (null == mIC) return null; final CharSequence prev = mIC.getTextBeforeCursor(LOOKBACK_CHARACTER_NUM, 0); return getThisWord(prev, sentenceSeperators); @@ -233,6 +242,7 @@ public class RichInputConnection { } private int getCursorPosition() { + mIC = mParent.getCurrentInputConnection(); if (null == mIC) return INVALID_CURSOR_POSITION; final ExtractedText extracted = mIC.getExtractedText(new ExtractedTextRequest(), 0); if (extracted == null) { @@ -250,6 +260,7 @@ public class RichInputConnection { * @return a range containing the text surrounding the cursor */ public Range getWordRangeAtCursor(String sep, int additionalPrecedingWordsCount) { + mIC = mParent.getCurrentInputConnection(); if (mIC == null || sep == null) { return null; } |