Merge "Don't recapitalize just at the start of input"
This commit is contained in:
commit
4c91142771
2 changed files with 21 additions and 7 deletions
|
@ -134,7 +134,7 @@ public final class InputLogic {
|
||||||
resetComposingState(true /* alsoResetLastComposedWord */);
|
resetComposingState(true /* alsoResetLastComposedWord */);
|
||||||
mDeleteCount = 0;
|
mDeleteCount = 0;
|
||||||
mSpaceState = SpaceState.NONE;
|
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();
|
mCurrentlyPressedHardwareKeys.clear();
|
||||||
mSuggestedWords = SuggestedWords.EMPTY;
|
mSuggestedWords = SuggestedWords.EMPTY;
|
||||||
// In some cases (namely, after rotation of the device) editorInfo.initialSelStart is lying
|
// 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 */);
|
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.
|
// We moved the cursor. If we are touching a word, we need to resume suggestion.
|
||||||
mLatinIME.mHandler.postResumeSuggestions();
|
mLatinIME.mHandler.postResumeSuggestions();
|
||||||
// Stop the last recapitalization, if started.
|
// Stop the last recapitalization, if started.
|
||||||
|
@ -369,10 +371,6 @@ public final class InputLogic {
|
||||||
final int keyboardShiftMode,
|
final int keyboardShiftMode,
|
||||||
// TODO: remove this argument
|
// TODO: remove this argument
|
||||||
final LatinIME.UIHandler handler) {
|
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,
|
final InputTransaction inputTransaction = new InputTransaction(settingsValues, event,
|
||||||
SystemClock.uptimeMillis(), mSpaceState,
|
SystemClock.uptimeMillis(), mSpaceState,
|
||||||
getActualCapsMode(settingsValues, keyboardShiftMode));
|
getActualCapsMode(settingsValues, keyboardShiftMode));
|
||||||
|
@ -1138,8 +1136,8 @@ public final class InputLogic {
|
||||||
* @param settingsValues The current settings values.
|
* @param settingsValues The current settings values.
|
||||||
*/
|
*/
|
||||||
private void performRecapitalization(final SettingsValues settingsValues) {
|
private void performRecapitalization(final SettingsValues settingsValues) {
|
||||||
if (!mConnection.hasSelection()) {
|
if (!mConnection.hasSelection() || !mRecapitalizeStatus.mIsEnabled()) {
|
||||||
return; // No selection
|
return; // No selection or recapitalize is disabled for now
|
||||||
}
|
}
|
||||||
final int selectionStart = mConnection.getExpectedSelectionStart();
|
final int selectionStart = mConnection.getExpectedSelectionStart();
|
||||||
final int selectionEnd = mConnection.getExpectedSelectionEnd();
|
final int selectionEnd = mConnection.getExpectedSelectionEnd();
|
||||||
|
|
|
@ -63,6 +63,7 @@ public class RecapitalizeStatus {
|
||||||
private int[] mSortedSeparators;
|
private int[] mSortedSeparators;
|
||||||
private String mStringAfter;
|
private String mStringAfter;
|
||||||
private boolean mIsStarted;
|
private boolean mIsStarted;
|
||||||
|
private boolean mIsEnabled = true;
|
||||||
|
|
||||||
private static final int[] EMPTY_STORTED_SEPARATORS = {};
|
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,
|
public void start(final int cursorStart, final int cursorEnd, final String string,
|
||||||
final Locale locale, final int[] sortedSeparators) {
|
final Locale locale, final int[] sortedSeparators) {
|
||||||
|
if (!mIsEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
mCursorStartBefore = cursorStart;
|
mCursorStartBefore = cursorStart;
|
||||||
mStringBefore = string;
|
mStringBefore = string;
|
||||||
mCursorStartAfter = cursorStart;
|
mCursorStartAfter = cursorStart;
|
||||||
|
@ -107,6 +111,18 @@ public class RecapitalizeStatus {
|
||||||
return mIsStarted;
|
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) {
|
public boolean isSetAt(final int cursorStart, final int cursorEnd) {
|
||||||
return cursorStart == mCursorStartAfter && cursorEnd == mCursorEndAfter;
|
return cursorStart == mCursorStartAfter && cursorEnd == mCursorEndAfter;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue