use of com.android.inputmethod.event.Event in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class InputLogicTestsDeadKeys method testDeadDiaeresisSpace.
public void testDeadDiaeresisSpace() {
final int MODIFIER_LETTER_DIAERESIS = 0xA8;
final String EXPECTED_RESULT = "a¨e¨i";
final EventList events = new EventList().addCodePoint('a', false).addCodePoint(MODIFIER_LETTER_DIAERESIS, true).addCodePoint(Constants.CODE_SPACE, false).addCodePoint('e', false).addCodePoint(MODIFIER_LETTER_DIAERESIS, true).addCodePoint(Constants.CODE_ENTER, false).addCodePoint('i', false);
for (final Event event : events) {
mLatinIME.onEvent(event);
}
assertEquals("dead diaeresis space commits the dead char", EXPECTED_RESULT, mEditText.getText().toString());
}
use of com.android.inputmethod.event.Event in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class InputLogicTestsDeadKeys method testDeadCircumflexSimple.
public void testDeadCircumflexSimple() {
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).addCodePoint('e', false);
for (final Event event : events) {
mLatinIME.onEvent(event);
}
assertEquals("simple dead circumflex", EXPECTED_RESULT, mEditText.getText().toString());
}
use of com.android.inputmethod.event.Event in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class InputLogicTestsDeadKeys method testDeadCircumflexDeadDiaeresisBackspace.
public void testDeadCircumflexDeadDiaeresisBackspace() {
final int MODIFIER_LETTER_CIRCUMFLEX_ACCENT = 0x02C6;
final int MODIFIER_LETTER_DIAERESIS = 0xA8;
final String EXPECTED_RESULT = "û";
final EventList events = new EventList().addCodePoint(MODIFIER_LETTER_CIRCUMFLEX_ACCENT, true).addCodePoint(MODIFIER_LETTER_DIAERESIS, true).addKey(Constants.CODE_DELETE).addCodePoint('u', false);
for (final Event event : events) {
mLatinIME.onEvent(event);
}
assertEquals("dead circumflex, dead diaeresis, backspace, u", EXPECTED_RESULT, mEditText.getText().toString());
}
use of com.android.inputmethod.event.Event in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class InputTestsBase method typeInternal.
// type(int) and type(String): helper methods to send a code point resp. a string to LatinIME.
protected void typeInternal(final int codePoint, final boolean isKeyRepeat) {
// onPressKey and onReleaseKey are explicitly deactivated here, but they do happen in the
// code (although multitouch/slide input and other factors make the sequencing complicated).
// They are supposed to be entirely deconnected from the input logic from LatinIME point of
// view and only delegates to the parts of the code that care. So we don't include them here
// to keep these tests as pinpoint as possible and avoid bringing it too many dependencies,
// but keep them in mind if something breaks. Commenting them out as is should work.
//mLatinIME.onPressKey(codePoint, 0 /* repeatCount */, true /* isSinglePointer */);
final Key key = mKeyboard.getKey(codePoint);
final Event event;
if (key == null) {
event = Event.createSoftwareKeypressEvent(codePoint, Event.NOT_A_KEY_CODE, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, isKeyRepeat);
} else {
final int x = key.getX() + key.getWidth() / 2;
final int y = key.getY() + key.getHeight() / 2;
event = LatinIME.createSoftwareKeypressEvent(codePoint, x, y, isKeyRepeat);
}
mLatinIME.onEvent(event);
// Also see the comment at the top of this function about onReleaseKey
//mLatinIME.onReleaseKey(codePoint, false /* withSliding */);
}
use of com.android.inputmethod.event.Event in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class InputLogic method onPickSuggestionManually.
/**
* A suggestion was picked from the suggestion strip.
* @param settingsValues the current values of the settings.
* @param suggestionInfo the suggestion info.
* @param keyboardShiftState the shift state of the keyboard, as returned by
* {@link com.android.inputmethod.keyboard.KeyboardSwitcher#getKeyboardShiftMode()}
* @return the complete transaction object
*/
// Called from {@link SuggestionStripView} through the {@link SuggestionStripView#Listener}
// interface
public InputTransaction onPickSuggestionManually(final SettingsValues settingsValues, final SuggestedWordInfo suggestionInfo, final int keyboardShiftState, final int currentKeyboardScriptId, final LatinIME.UIHandler handler) {
final SuggestedWords suggestedWords = mSuggestedWords;
final String suggestion = suggestionInfo.mWord;
// If this is a punctuation picked from the suggestion strip, pass it to onCodeInput
if (suggestion.length() == 1 && suggestedWords.isPunctuationSuggestions()) {
// We still want to log a suggestion click.
StatsUtils.onPickSuggestionManually(mSuggestedWords, suggestionInfo, mDictionaryFacilitator);
// Word separators are suggested before the user inputs something.
// Rely on onCodeInput to do the complicated swapping/stripping logic consistently.
final Event event = Event.createPunctuationSuggestionPickedEvent(suggestionInfo);
return onCodeInput(settingsValues, event, keyboardShiftState, currentKeyboardScriptId, handler);
}
final Event event = Event.createSuggestionPickedEvent(suggestionInfo);
final InputTransaction inputTransaction = new InputTransaction(settingsValues, event, SystemClock.uptimeMillis(), mSpaceState, keyboardShiftState);
// Manual pick affects the contents of the editor, so we take note of this. It's important
// for the sequence of language switching.
inputTransaction.setDidAffectContents();
mConnection.beginBatchEdit();
if (SpaceState.PHANTOM == mSpaceState && suggestion.length() > 0 && // the current batch input text and there is no need for a phantom space.
!mWordComposer.isBatchMode()) {
final int firstChar = Character.codePointAt(suggestion, 0);
if (!settingsValues.isWordSeparator(firstChar) || settingsValues.isUsuallyPrecededBySpace(firstChar)) {
insertAutomaticSpaceIfOptionsAndTextAllow(settingsValues);
}
}
// the risk of calling commitCompletion twice because we don't know how the app will react.
if (suggestionInfo.isKindOf(SuggestedWordInfo.KIND_APP_DEFINED)) {
mSuggestedWords = SuggestedWords.getEmptyInstance();
mSuggestionStripViewAccessor.setNeutralSuggestionStrip();
inputTransaction.requireShiftUpdate(InputTransaction.SHIFT_UPDATE_NOW);
resetComposingState(true);
mConnection.commitCompletion(suggestionInfo.mApplicationSpecifiedCompletionInfo);
mConnection.endBatchEdit();
return inputTransaction;
}
commitChosenWord(settingsValues, suggestion, LastComposedWord.COMMIT_TYPE_MANUAL_PICK, LastComposedWord.NOT_A_SEPARATOR);
mConnection.endBatchEdit();
// Don't allow cancellation of manual pick
mLastComposedWord.deactivate();
// Space state must be updated before calling updateShiftState
mSpaceState = SpaceState.PHANTOM;
inputTransaction.requireShiftUpdate(InputTransaction.SHIFT_UPDATE_NOW);
// If we're not showing the "Touch again to save", then update the suggestion strip.
// That's going to be predictions (or punctuation suggestions), so INPUT_STYLE_NONE.
handler.postUpdateSuggestionStrip(SuggestedWords.INPUT_STYLE_NONE);
StatsUtils.onPickSuggestionManually(mSuggestedWords, suggestionInfo, mDictionaryFacilitator);
StatsUtils.onWordCommitSuggestionPickedManually(suggestionInfo.mWord, mWordComposer.isBatchMode());
return inputTransaction;
}
Aggregations