aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/LatinIME.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java29
1 files changed, 25 insertions, 4 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 4f8852b87..d9e63da1b 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -82,6 +82,7 @@ import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Locale;
+import java.util.TreeSet;
/**
* Input method implementation for Qwerty'ish keyboard.
@@ -167,6 +168,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
private int mDeleteCount;
private long mLastKeyTime;
private int mActionId;
+ private TreeSet<Long> mCurrentlyPressedHardwareKeys = CollectionUtils.newTreeSet();
// Member variables for remembering the current device orientation.
private int mDisplayOrientation;
@@ -721,6 +723,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
resetComposingState(true /* alsoResetLastComposedWord */);
mDeleteCount = 0;
mSpaceState = SPACE_STATE_NONE;
+ mCurrentlyPressedHardwareKeys.clear();
if (mSuggestionStripView != null) {
// This will set the punctuation suggestions if next word suggestion is off;
@@ -1484,7 +1487,10 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
Stats.onAutoCorrection("", mWordComposer.getTypedWord(), " ", mWordComposer);
}
}
- if (mWordComposer.size() <= 1) {
+ final int wordComposerSize = mWordComposer.size();
+ // Since isComposingWord() is true, the size is at least 1.
+ final int lastChar = mWordComposer.getCodeAt(wordComposerSize - 1);
+ if (wordComposerSize <= 1) {
// We auto-correct the previous (typed, not gestured) string iff it's one character
// long. The reason for this is, even in the middle of gesture typing, you'll still
// tap one-letter words and you want them auto-corrected (typically, "i" in English
@@ -1498,8 +1504,14 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
}
mExpectingUpdateSelection = true;
// The following is necessary for the case where the user typed something but didn't
- // manual pick it and didn't input any separator.
- mSpaceState = SPACE_STATE_PHANTOM;
+ // manual pick it and didn't input any separator: we want to put a space between what
+ // has been entered and the coming gesture input result, so we go into phantom space
+ // state, which will be promoted to a space when the gesture result is committed. But if
+ // the current input ends in a word connector on the other hand, then we want to have
+ // the next input stick to the current input so we don't switch to phantom space state.
+ if (!mSettings.getCurrent().isWordConnector(lastChar)) {
+ mSpaceState = SPACE_STATE_PHANTOM;
+ }
} else {
final int codePointBeforeCursor = mConnection.getCodePointBeforeCursor();
if (mSettings.getCurrent().isUsuallyFollowedBySpace(codePointBeforeCursor)) {
@@ -2417,15 +2429,24 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
// Hooks for hardware keyboard
@Override
public boolean onKeyDown(final int keyCode, final KeyEvent event) {
+ if (!ProductionFlag.IS_HARDWARE_KEYBOARD_SUPPORTED) return super.onKeyDown(keyCode, event);
// onHardwareKeyEvent, like onKeyDown returns true if it handled the event, false if
// it doesn't know what to do with it and leave it to the application. For example,
// hardware key events for adjusting the screen's brightness are passed as is.
- if (mEventInterpreter.onHardwareKeyEvent(event)) return true;
+ if (mEventInterpreter.onHardwareKeyEvent(event)) {
+ final long keyIdentifier = event.getDeviceId() << 32 + event.getKeyCode();
+ mCurrentlyPressedHardwareKeys.add(keyIdentifier);
+ return true;
+ }
return super.onKeyDown(keyCode, event);
}
@Override
public boolean onKeyUp(final int keyCode, final KeyEvent event) {
+ final long keyIdentifier = event.getDeviceId() << 32 + event.getKeyCode();
+ if (mCurrentlyPressedHardwareKeys.remove(keyIdentifier)) {
+ return true;
+ }
return super.onKeyUp(keyCode, event);
}