Search in sources :

Example 11 with Event

use of com.android.inputmethod.event.Event in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class InputLogic method onCodeInput.

/**
     * React to a code input. It may be a code point to insert, or a symbolic value that influences
     * the keyboard behavior.
     *
     * Typically, this is called whenever a key is pressed on the software keyboard. This is not
     * the entry point for gesture input; see the onBatchInput* family of functions for this.
     *
     * @param settingsValues the current settings values.
     * @param event the event to handle.
     * @param keyboardShiftMode the current shift mode of the keyboard, as returned by
     *     {@link com.android.inputmethod.keyboard.KeyboardSwitcher#getKeyboardShiftMode()}
     * @return the complete transaction object
     */
public InputTransaction onCodeInput(final SettingsValues settingsValues, @Nonnull final Event event, final int keyboardShiftMode, final int currentKeyboardScriptId, final LatinIME.UIHandler handler) {
    mWordBeingCorrectedByCursor = null;
    final Event processedEvent = mWordComposer.processEvent(event);
    final InputTransaction inputTransaction = new InputTransaction(settingsValues, processedEvent, SystemClock.uptimeMillis(), mSpaceState, getActualCapsMode(settingsValues, keyboardShiftMode));
    if (processedEvent.mKeyCode != Constants.CODE_DELETE || inputTransaction.mTimestamp > mLastKeyTime + Constants.LONG_PRESS_MILLISECONDS) {
        mDeleteCount = 0;
    }
    mLastKeyTime = inputTransaction.mTimestamp;
    mConnection.beginBatchEdit();
    if (!mWordComposer.isComposingWord()) {
        // TODO: is this useful? It doesn't look like it should be done here, but rather after
        // a word is committed.
        mIsAutoCorrectionIndicatorOn = false;
    }
    // TODO: Consolidate the double-space period timer, mLastKeyTime, and the space state.
    if (processedEvent.mCodePoint != Constants.CODE_SPACE) {
        cancelDoubleSpacePeriodCountdown();
    }
    Event currentEvent = processedEvent;
    while (null != currentEvent) {
        if (currentEvent.isConsumed()) {
            handleConsumedEvent(currentEvent, inputTransaction);
        } else if (currentEvent.isFunctionalKeyEvent()) {
            handleFunctionalEvent(currentEvent, inputTransaction, currentKeyboardScriptId, handler);
        } else {
            handleNonFunctionalEvent(currentEvent, inputTransaction, handler);
        }
        currentEvent = currentEvent.mNextEvent;
    }
    // the backspace key.
    if (!mConnection.hasSlowInputConnection() && !mWordComposer.isComposingWord() && (settingsValues.isWordCodePoint(processedEvent.mCodePoint) || processedEvent.mKeyCode == Constants.CODE_DELETE)) {
        mWordBeingCorrectedByCursor = getWordAtCursor(settingsValues, currentKeyboardScriptId);
    }
    if (!inputTransaction.didAutoCorrect() && processedEvent.mKeyCode != Constants.CODE_SHIFT && processedEvent.mKeyCode != Constants.CODE_CAPSLOCK && processedEvent.mKeyCode != Constants.CODE_SWITCH_ALPHA_SYMBOL)
        mLastComposedWord.deactivate();
    if (Constants.CODE_DELETE != processedEvent.mKeyCode) {
        mEnteredText = null;
    }
    mConnection.endBatchEdit();
    return inputTransaction;
}
Also used : InputTransaction(com.android.inputmethod.event.InputTransaction) KeyEvent(android.view.KeyEvent) Event(com.android.inputmethod.event.Event)

Example 12 with Event

use of com.android.inputmethod.event.Event in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class InputLogicTestsDeadKeys method testDeadCircumflexDeadDiaeresis.

public void testDeadCircumflexDeadDiaeresis() {
    final int MODIFIER_LETTER_CIRCUMFLEX_ACCENT = 0x02C6;
    final int MODIFIER_LETTER_DIAERESIS = 0xA8;
    final String EXPECTED_RESULT = "r̂̈";
    final EventList events = new EventList().addCodePoint(MODIFIER_LETTER_CIRCUMFLEX_ACCENT, true).addCodePoint(MODIFIER_LETTER_DIAERESIS, true).addCodePoint('r', false);
    for (final Event event : events) {
        mLatinIME.onEvent(event);
    }
    assertEquals("both circumflex and diaeresis on r", EXPECTED_RESULT, mEditText.getText().toString());
}
Also used : Event(com.android.inputmethod.event.Event)

Example 13 with Event

use of com.android.inputmethod.event.Event in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class InputLogicTestsDeadKeys method testDeadCircumflexBackspace.

public void testDeadCircumflexBackspace() {
    final int MODIFIER_LETTER_CIRCUMFLEX_ACCENT = 0x02C6;
    final String EXPECTED_RESULT = "ae";
    final EventList events = new EventList().addCodePoint('a', false).addCodePoint(MODIFIER_LETTER_CIRCUMFLEX_ACCENT, true).addKey(Constants.CODE_DELETE).addCodePoint('e', false);
    for (final Event event : events) {
        mLatinIME.onEvent(event);
    }
    assertEquals("dead circumflex backspace", EXPECTED_RESULT, mEditText.getText().toString());
}
Also used : Event(com.android.inputmethod.event.Event)

Example 14 with Event

use of com.android.inputmethod.event.Event in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class InputLogicTestsDeadKeys method testDeadCircumflexDoubleDeadDiaeresisBackspace.

public void testDeadCircumflexDoubleDeadDiaeresisBackspace() {
    final int MODIFIER_LETTER_CIRCUMFLEX_ACCENT = 0x02C6;
    final int MODIFIER_LETTER_DIAERESIS = 0xA8;
    final String EXPECTED_RESULT = "ˆu";
    final EventList events = new EventList().addCodePoint(MODIFIER_LETTER_CIRCUMFLEX_ACCENT, true).addCodePoint(MODIFIER_LETTER_DIAERESIS, true).addCodePoint(MODIFIER_LETTER_DIAERESIS, true).addKey(Constants.CODE_DELETE).addCodePoint('u', false);
    for (final Event event : events) {
        mLatinIME.onEvent(event);
    }
    assertEquals("dead circumflex, double dead diaeresis, backspace, u", EXPECTED_RESULT, mEditText.getText().toString());
}
Also used : Event(com.android.inputmethod.event.Event)

Example 15 with Event

use of com.android.inputmethod.event.Event in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class InputLogicTestsDeadKeys method testDeadCircumflexFeedback.

public void testDeadCircumflexFeedback() {
    final int MODIFIER_LETTER_CIRCUMFLEX_ACCENT = 0x02C6;
    final String EXPECTED_RESULT = "aˆ";
    final EventList events = new EventList().addCodePoint('a', false).addCodePoint(MODIFIER_LETTER_CIRCUMFLEX_ACCENT, true);
    for (final Event event : events) {
        mLatinIME.onEvent(event);
    }
    assertEquals("dead circumflex gives feedback", EXPECTED_RESULT, mEditText.getText().toString());
}
Also used : Event(com.android.inputmethod.event.Event)

Aggregations

Event (com.android.inputmethod.event.Event)21 KeyEvent (android.view.KeyEvent)6 InputTransaction (com.android.inputmethod.event.InputTransaction)3 Point (android.graphics.Point)1 SpannableString (android.text.SpannableString)1 Key (com.android.inputmethod.keyboard.Key)1 MainKeyboardView (com.android.inputmethod.keyboard.MainKeyboardView)1 SuggestedWords (com.android.inputmethod.latin.SuggestedWords)1 Nonnull (javax.annotation.Nonnull)1