am 70ff0c21: Merge "Fix a bug on rotation with selection."
* commit '70ff0c212262309e381d00636bf66d231a2a9dfb': Fix a bug on rotation with selection.main
commit
04ef4ce21c
|
@ -640,14 +640,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfigurationChanged(final Configuration conf) {
|
public void onConfigurationChanged(final Configuration conf) {
|
||||||
// If orientation changed while predicting, commit the change
|
|
||||||
final SettingsValues settingsValues = mSettings.getCurrent();
|
final SettingsValues settingsValues = mSettings.getCurrent();
|
||||||
if (settingsValues.mDisplayOrientation != conf.orientation) {
|
if (settingsValues.mDisplayOrientation != conf.orientation) {
|
||||||
mHandler.startOrientationChanging();
|
mHandler.startOrientationChanging();
|
||||||
mInputLogic.mConnection.beginBatchEdit();
|
mInputLogic.finishInput();
|
||||||
mInputLogic.commitTyped(mSettings.getCurrent(), LastComposedWord.NOT_A_SEPARATOR);
|
|
||||||
mInputLogic.mConnection.finishComposingText();
|
|
||||||
mInputLogic.mConnection.endBatchEdit();
|
|
||||||
}
|
}
|
||||||
PersonalizationDictionarySessionRegistrar.onConfigurationChanged(this, conf,
|
PersonalizationDictionarySessionRegistrar.onConfigurationChanged(this, conf,
|
||||||
mDictionaryFacilitator);
|
mDictionaryFacilitator);
|
||||||
|
|
|
@ -891,4 +891,8 @@ public final class RichInputConnection {
|
||||||
public boolean hasSelection() {
|
public boolean hasSelection() {
|
||||||
return mExpectedSelEnd != mExpectedSelStart;
|
return mExpectedSelEnd != mExpectedSelStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCursorPositionKnown() {
|
||||||
|
return INVALID_CURSOR_POSITION != mExpectedSelStart;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -319,8 +319,16 @@ public final class InputLogic {
|
||||||
|| !mWordComposer.isComposingWord(); // safe to reset
|
|| !mWordComposer.isComposingWord(); // safe to reset
|
||||||
final boolean hasOrHadSelection = (oldSelStart != oldSelEnd || newSelStart != newSelEnd);
|
final boolean hasOrHadSelection = (oldSelStart != oldSelEnd || newSelStart != newSelEnd);
|
||||||
final int moveAmount = newSelStart - oldSelStart;
|
final int moveAmount = newSelStart - oldSelStart;
|
||||||
if (selectionChangedOrSafeToReset && (hasOrHadSelection
|
// As an added small gift from the framework, it happens upon rotation when there
|
||||||
|| !mWordComposer.moveCursorByAndReturnIfInsideComposingWord(moveAmount))) {
|
// is a selection that we get a wrong cursor position delivered to startInput() that
|
||||||
|
// does not get reflected in the oldSel{Start,End} parameters to the next call to
|
||||||
|
// onUpdateSelection. In this case, we may have set a composition, and when we're here
|
||||||
|
// we realize we shouldn't have. In theory, in this case, selectionChangedOrSafeToReset
|
||||||
|
// should be true, but that is if the framework had taken that wrong cursor position
|
||||||
|
// into account, which means we have to reset the entire composing state whenever there
|
||||||
|
// is or was a selection regardless of whether it changed or not.
|
||||||
|
if (hasOrHadSelection || (selectionChangedOrSafeToReset
|
||||||
|
&& !mWordComposer.moveCursorByAndReturnIfInsideComposingWord(moveAmount))) {
|
||||||
// If we are composing a word and moving the cursor, we would want to set a
|
// 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
|
// suggestion span for recorrection to work correctly. Unfortunately, that
|
||||||
// would involve the keyboard committing some new text, which would move the
|
// would involve the keyboard committing some new text, which would move the
|
||||||
|
@ -1922,9 +1930,11 @@ public final class InputLogic {
|
||||||
final boolean tryResumeSuggestions, final int remainingTries,
|
final boolean tryResumeSuggestions, final int remainingTries,
|
||||||
// TODO: remove these arguments
|
// TODO: remove these arguments
|
||||||
final LatinIME.UIHandler handler) {
|
final LatinIME.UIHandler handler) {
|
||||||
|
final boolean shouldFinishComposition = mConnection.hasSelection()
|
||||||
|
|| !mConnection.isCursorPositionKnown();
|
||||||
if (!mConnection.resetCachesUponCursorMoveAndReturnSuccess(
|
if (!mConnection.resetCachesUponCursorMoveAndReturnSuccess(
|
||||||
mConnection.getExpectedSelectionStart(), mConnection.getExpectedSelectionEnd(),
|
mConnection.getExpectedSelectionStart(), mConnection.getExpectedSelectionEnd(),
|
||||||
false /* shouldFinishComposition */)) {
|
shouldFinishComposition)) {
|
||||||
if (0 < remainingTries) {
|
if (0 < remainingTries) {
|
||||||
handler.postResetCaches(tryResumeSuggestions, remainingTries - 1);
|
handler.postResetCaches(tryResumeSuggestions, remainingTries - 1);
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue