aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-06-04 15:38:41 +0900
committerJean Chalard <jchalard@google.com>2014-06-04 16:29:31 +0900
commitc84b10840e1439a0432dc92cca29a5f6af1646fb (patch)
treee75ae0e1c6287b65ca06fad99c8e54fdd58dffd5
parent4a1113b6b065931322df8bba375864274a898acf (diff)
downloadlatinime-c84b10840e1439a0432dc92cca29a5f6af1646fb.tar.gz
latinime-c84b10840e1439a0432dc92cca29a5f6af1646fb.tar.xz
latinime-c84b10840e1439a0432dc92cca29a5f6af1646fb.zip
Don't recapitalize just at the start of input
Bug: 13283555 Change-Id: Iab0466425dc44779d110f2cd29d725d22eb04827
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java12
-rw-r--r--java/src/com/android/inputmethod/latin/utils/RecapitalizeStatus.java16
2 files changed, 21 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 55cc135d3..dbbe1a0c5 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -134,7 +134,7 @@ public final class InputLogic {
resetComposingState(true /* alsoResetLastComposedWord */);
mDeleteCount = 0;
mSpaceState = SpaceState.NONE;
- mRecapitalizeStatus.stop(); // In case a recapitalization is started
+ mRecapitalizeStatus.disable(); // Do not perform recapitalize until the cursor is moved once
mCurrentlyPressedHardwareKeys.clear();
mSuggestedWords = SuggestedWords.EMPTY;
// In some cases (namely, after rotation of the device) editorInfo.initialSelStart is lying
@@ -345,6 +345,8 @@ public final class InputLogic {
newSelStart, newSelEnd, false /* shouldFinishComposition */);
}
+ // The cursor has been moved : we now accept to perform recapitalization
+ mRecapitalizeStatus.enable();
// We moved the cursor. If we are touching a word, we need to resume suggestion.
mLatinIME.mHandler.postResumeSuggestions();
// Stop the last recapitalization, if started.
@@ -369,10 +371,6 @@ public final class InputLogic {
final int keyboardShiftMode,
// TODO: remove this argument
final LatinIME.UIHandler handler) {
- // TODO: rework the following to not squash the keycode and the code point into the same
- // var because it's confusing. Instead the switch() should handle this in a readable manner.
- final int code =
- Event.NOT_A_CODE_POINT == event.mCodePoint ? event.mKeyCode : event.mCodePoint;
final InputTransaction inputTransaction = new InputTransaction(settingsValues, event,
SystemClock.uptimeMillis(), mSpaceState,
getActualCapsMode(settingsValues, keyboardShiftMode));
@@ -1138,8 +1136,8 @@ public final class InputLogic {
* @param settingsValues The current settings values.
*/
private void performRecapitalization(final SettingsValues settingsValues) {
- if (!mConnection.hasSelection()) {
- return; // No selection
+ if (!mConnection.hasSelection() || !mRecapitalizeStatus.mIsEnabled()) {
+ return; // No selection or recapitalize is disabled for now
}
final int selectionStart = mConnection.getExpectedSelectionStart();
final int selectionEnd = mConnection.getExpectedSelectionEnd();
diff --git a/java/src/com/android/inputmethod/latin/utils/RecapitalizeStatus.java b/java/src/com/android/inputmethod/latin/utils/RecapitalizeStatus.java
index b38a9131a..e3cac97f0 100644
--- a/java/src/com/android/inputmethod/latin/utils/RecapitalizeStatus.java
+++ b/java/src/com/android/inputmethod/latin/utils/RecapitalizeStatus.java
@@ -63,6 +63,7 @@ public class RecapitalizeStatus {
private int[] mSortedSeparators;
private String mStringAfter;
private boolean mIsStarted;
+ private boolean mIsEnabled = true;
private static final int[] EMPTY_STORTED_SEPARATORS = {};
@@ -74,6 +75,9 @@ public class RecapitalizeStatus {
public void start(final int cursorStart, final int cursorEnd, final String string,
final Locale locale, final int[] sortedSeparators) {
+ if (!mIsEnabled) {
+ return;
+ }
mCursorStartBefore = cursorStart;
mStringBefore = string;
mCursorStartAfter = cursorStart;
@@ -107,6 +111,18 @@ public class RecapitalizeStatus {
return mIsStarted;
}
+ public void enable() {
+ mIsEnabled = true;
+ }
+
+ public void disable() {
+ mIsEnabled = false;
+ }
+
+ public boolean mIsEnabled() {
+ return mIsEnabled;
+ }
+
public boolean isSetAt(final int cursorStart, final int cursorEnd) {
return cursorStart == mCursorStartAfter && cursorEnd == mCursorEndAfter;
}