Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b084da2a authored by Jean Chalard's avatar Jean Chalard Committed by Android (Google) Code Review
Browse files

Merge changes I5092942a,I931c553f

* changes:
  [IL80] Reverse a test for clarity.
  [IL79] Some refactoring
parents a3a85e8c f1e5b9b4
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -912,7 +912,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
                    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
        // 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();
        }
+41 −50
Original line number Diff line number Diff line
@@ -195,7 +195,16 @@ public final class InputLogic {
            final int oldSelStart, final int oldSelEnd,
            final int newSelStart, final int newSelEnd,
            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
        // span in the view - we can use that to narrow down whether the cursor was moved
@@ -204,28 +213,12 @@ public final class InputLogic {
        // the state. TODO: rescind this policy: the framework never removes the composing
        // span on its own accord while editing. This test is useless.
        final boolean noComposingSpan = composingSpanStart == -1 && composingSpanEnd == -1;

        // If the keyboard is not visible, we don't need to do all the housekeeping work, as it
        // 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.
        // TODO: remove the #isInputViewShown() call from here.
        if (mLatinIME.isInputViewShown() && !mConnection.isBelatedExpectedUpdate(oldSelStart,
                newSelStart, oldSelEnd, newSelEnd)) {
            // 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;
        final boolean selectionChanged = oldSelStart != newSelStart || oldSelEnd != newSelEnd;

        // TODO: is it still necessary to test for composingSpan related stuff?
        final boolean selectionChangedOrSafeToReset = selectionChanged
                || (!mWordComposer.isComposingWord()) || noComposingSpan;
            final boolean hasOrHadSelection = (oldSelStart != oldSelEnd
                    || newSelStart != newSelEnd);
        final boolean hasOrHadSelection = (oldSelStart != oldSelEnd || newSelStart != newSelEnd);
        final int moveAmount = newSelStart - oldSelStart;
        if (selectionChangedOrSafeToReset && (hasOrHadSelection
                || !mWordComposer.moveCursorByAndReturnIfInsideComposingWord(moveAmount))) {
@@ -254,8 +247,6 @@ public final class InputLogic {
        mRecapitalizeStatus.deactivate();
        return true;
    }
        return false;
    }

    /**
     * React to a code input. It may be a code point to insert, or a symbolic value that influences