am b084da2a: Merge changes I5092942a,I931c553f
* commit 'b084da2ae6622488779ddb3a66081610bfe96a66': [IL80] Reverse a test for clarity. [IL79] Some refactoringmain
commit
a8b37414f8
|
@ -912,8 +912,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
composingSpanEnd, mInputLogic.mConnection);
|
composingSpanEnd, mInputLogic.mConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mInputLogic.onUpdateSelection(mSettings.getCurrent(), oldSelStart, oldSelEnd,
|
// If the keyboard is not visible, we don't need to do all the housekeeping work, as it
|
||||||
newSelStart, newSelEnd, composingSpanStart, composingSpanEnd)) {
|
// will be reset when the keyboard shows up anyway.
|
||||||
|
// TODO: revisit this when LatinIME supports hardware keyboards.
|
||||||
|
// NOTE: the test harness subclasses LatinIME and overrides isInputViewShown().
|
||||||
|
// TODO: find a better way to simulate actual execution.
|
||||||
|
if (isInputViewShown() &&
|
||||||
|
mInputLogic.onUpdateSelection(mSettings.getCurrent(), oldSelStart, oldSelEnd,
|
||||||
|
newSelStart, newSelEnd, composingSpanStart, composingSpanEnd)) {
|
||||||
mKeyboardSwitcher.updateShiftState();
|
mKeyboardSwitcher.updateShiftState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -195,7 +195,16 @@ public final class InputLogic {
|
||||||
final int oldSelStart, final int oldSelEnd,
|
final int oldSelStart, final int oldSelEnd,
|
||||||
final int newSelStart, final int newSelEnd,
|
final int newSelStart, final int newSelEnd,
|
||||||
final int composingSpanStart, final int composingSpanEnd) {
|
final int composingSpanStart, final int composingSpanEnd) {
|
||||||
final boolean selectionChanged = oldSelStart != newSelStart || oldSelEnd != newSelEnd;
|
if (mConnection.isBelatedExpectedUpdate(oldSelStart, newSelStart, oldSelEnd, newSelEnd)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// TODO: the following is probably better done in resetEntireInputState().
|
||||||
|
// it should only happen when the cursor moved, and the very purpose of the
|
||||||
|
// test below is to narrow down whether this happened or not. Likewise with
|
||||||
|
// the call to updateShiftState.
|
||||||
|
// We set this to NONE because after a cursor move, we don't want the space
|
||||||
|
// state-related special processing to kick in.
|
||||||
|
mSpaceState = SpaceState.NONE;
|
||||||
|
|
||||||
// if composingSpanStart and composingSpanEnd are -1, it means there is no composing
|
// if composingSpanStart and composingSpanEnd are -1, it means there is no composing
|
||||||
// span in the view - we can use that to narrow down whether the cursor was moved
|
// span in the view - we can use that to narrow down whether the cursor was moved
|
||||||
|
@ -204,57 +213,39 @@ public final class InputLogic {
|
||||||
// the state. TODO: rescind this policy: the framework never removes the composing
|
// the state. TODO: rescind this policy: the framework never removes the composing
|
||||||
// span on its own accord while editing. This test is useless.
|
// span on its own accord while editing. This test is useless.
|
||||||
final boolean noComposingSpan = composingSpanStart == -1 && composingSpanEnd == -1;
|
final boolean noComposingSpan = composingSpanStart == -1 && composingSpanEnd == -1;
|
||||||
|
final boolean selectionChanged = oldSelStart != newSelStart || oldSelEnd != newSelEnd;
|
||||||
|
|
||||||
// If the keyboard is not visible, we don't need to do all the housekeeping work, as it
|
// TODO: is it still necessary to test for composingSpan related stuff?
|
||||||
// will be reset when the keyboard shows up anyway.
|
final boolean selectionChangedOrSafeToReset = selectionChanged
|
||||||
// TODO: revisit this when LatinIME supports hardware keyboards.
|
|| (!mWordComposer.isComposingWord()) || noComposingSpan;
|
||||||
// NOTE: the test harness subclasses LatinIME and overrides isInputViewShown().
|
final boolean hasOrHadSelection = (oldSelStart != oldSelEnd || newSelStart != newSelEnd);
|
||||||
// TODO: find a better way to simulate actual execution.
|
final int moveAmount = newSelStart - oldSelStart;
|
||||||
// TODO: remove the #isInputViewShown() call from here.
|
if (selectionChangedOrSafeToReset && (hasOrHadSelection
|
||||||
if (mLatinIME.isInputViewShown() && !mConnection.isBelatedExpectedUpdate(oldSelStart,
|
|| !mWordComposer.moveCursorByAndReturnIfInsideComposingWord(moveAmount))) {
|
||||||
newSelStart, oldSelEnd, newSelEnd)) {
|
// If we are composing a word and moving the cursor, we would want to set a
|
||||||
// TODO: the following is probably better done in resetEntireInputState().
|
// suggestion span for recorrection to work correctly. Unfortunately, that
|
||||||
// it should only happen when the cursor moved, and the very purpose of the
|
// would involve the keyboard committing some new text, which would move the
|
||||||
// test below is to narrow down whether this happened or not. Likewise with
|
// cursor back to where it was. Latin IME could then fix the position of the cursor
|
||||||
// the call to updateShiftState.
|
// again, but the asynchronous nature of the calls results in this wreaking havoc
|
||||||
// We set this to NONE because after a cursor move, we don't want the space
|
// with selection on double tap and the like.
|
||||||
// state-related special processing to kick in.
|
// Another option would be to send suggestions each time we set the composing
|
||||||
mSpaceState = SpaceState.NONE;
|
// text, but that is probably too expensive to do, so we decided to leave things
|
||||||
|
// as is.
|
||||||
// TODO: is it still necessary to test for composingSpan related stuff?
|
resetEntireInputState(settingsValues, newSelStart, newSelEnd);
|
||||||
final boolean selectionChangedOrSafeToReset = selectionChanged
|
} else {
|
||||||
|| (!mWordComposer.isComposingWord()) || noComposingSpan;
|
// resetEntireInputState calls resetCachesUponCursorMove, but forcing the
|
||||||
final boolean hasOrHadSelection = (oldSelStart != oldSelEnd
|
// composition to end. But in all cases where we don't reset the entire input
|
||||||
|| newSelStart != newSelEnd);
|
// state, we still want to tell the rich input connection about the new cursor
|
||||||
final int moveAmount = newSelStart - oldSelStart;
|
// position so that it can update its caches.
|
||||||
if (selectionChangedOrSafeToReset && (hasOrHadSelection
|
mConnection.resetCachesUponCursorMoveAndReturnSuccess(
|
||||||
|| !mWordComposer.moveCursorByAndReturnIfInsideComposingWord(moveAmount))) {
|
newSelStart, newSelEnd, false /* shouldFinishComposition */);
|
||||||
// If we are composing a word and moving the cursor, we would want to set a
|
|
||||||
// suggestion span for recorrection to work correctly. Unfortunately, that
|
|
||||||
// would involve the keyboard committing some new text, which would move the
|
|
||||||
// cursor back to where it was. Latin IME could then fix the position of the cursor
|
|
||||||
// again, but the asynchronous nature of the calls results in this wreaking havoc
|
|
||||||
// with selection on double tap and the like.
|
|
||||||
// Another option would be to send suggestions each time we set the composing
|
|
||||||
// text, but that is probably too expensive to do, so we decided to leave things
|
|
||||||
// as is.
|
|
||||||
resetEntireInputState(settingsValues, newSelStart, newSelEnd);
|
|
||||||
} else {
|
|
||||||
// resetEntireInputState calls resetCachesUponCursorMove, but forcing the
|
|
||||||
// composition to end. But in all cases where we don't reset the entire input
|
|
||||||
// state, we still want to tell the rich input connection about the new cursor
|
|
||||||
// position so that it can update its caches.
|
|
||||||
mConnection.resetCachesUponCursorMoveAndReturnSuccess(
|
|
||||||
newSelStart, newSelEnd, false /* shouldFinishComposition */);
|
|
||||||
}
|
|
||||||
|
|
||||||
// We moved the cursor. If we are touching a word, we need to resume suggestion.
|
|
||||||
mLatinIME.mHandler.postResumeSuggestions();
|
|
||||||
// Reset the last recapitalization.
|
|
||||||
mRecapitalizeStatus.deactivate();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
// We moved the cursor. If we are touching a word, we need to resume suggestion.
|
||||||
|
mLatinIME.mHandler.postResumeSuggestions();
|
||||||
|
// Reset the last recapitalization.
|
||||||
|
mRecapitalizeStatus.deactivate();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue