Example usage for android.view KeyCharacterMap COMBINING_ACCENT

List of usage examples for android.view KeyCharacterMap COMBINING_ACCENT

Introduction

In this page you can find the example usage for android.view KeyCharacterMap COMBINING_ACCENT.

Prototype

int COMBINING_ACCENT

To view the source code for android.view KeyCharacterMap COMBINING_ACCENT.

Click Source Link

Usage

From source file:research.sg.edu.edapp.kb.KbSoftKeyboard.java

/**
 * This translates incoming hard key events in to edit operations on an
 * InputConnection.  It is only needed when using the
 * PROCESS_HARD_KEYS option.//from   ww  w .  j  ava 2 s.  c  om
 */

private boolean translateKeyDown(int keyCode, KeyEvent event) {
    mMetaState = MetaKeyKeyListener.handleKeyDown(mMetaState, keyCode, event);
    int c = event.getUnicodeChar(MetaKeyKeyListener.getMetaState(mMetaState));
    mMetaState = MetaKeyKeyListener.adjustMetaAfterKeypress(mMetaState);
    InputConnection ic = getCurrentInputConnection();
    if (c == 0 || ic == null) {
        return false;
    }

    boolean dead = false;

    if ((c & KeyCharacterMap.COMBINING_ACCENT) != 0) {
        dead = true;
        c = c & KeyCharacterMap.COMBINING_ACCENT_MASK;
    }

    if (mComposing.length() > 0) {
        char accent = mComposing.charAt(mComposing.length() - 1);
        int composed = KeyEvent.getDeadChar(accent, c);

        if (composed != 0) {
            c = composed;
            mComposing.setLength(mComposing.length() - 1);
        }
    }

    Log.d("Cum", "Cum");
    onKey(c, null);

    return true;
}

From source file:com.strathclyde.highlightingkeyboard.SoftKeyboardService.java

/**
 * This translates incoming hard key events in to edit operations on an
 * InputConnection.  It is only needed when using the
 * PROCESS_HARD_KEYS option./*from   ww  w . j ava 2s.co m*/
 */
private boolean translateKeyDown(int keyCode, KeyEvent event) {
    mMetaState = MetaKeyKeyListener.handleKeyDown(mMetaState, keyCode, event);
    int c = event.getUnicodeChar(MetaKeyKeyListener.getMetaState(mMetaState));
    mMetaState = MetaKeyKeyListener.adjustMetaAfterKeypress(mMetaState);
    //InputConnection ic = ic;
    if (c == 0 || ic == null) {
        return false;
    }

    if ((c & KeyCharacterMap.COMBINING_ACCENT) != 0) {
        c = c & KeyCharacterMap.COMBINING_ACCENT_MASK;
    }

    if (mComposing.length() > 0) {
        char accent = mComposing.charAt(mComposing.length() - 1);
        int composed = KeyEvent.getDeadChar(accent, c);

        if (composed != 0) {
            c = composed;
            mComposing.setLength(mComposing.length() - 1);
        }
    }

    onKey(c, null);

    return true;
}

From source file:com.android.contacts.activities.PeopleActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    // TODO move to the fragment

    // Bring up the search UI if the user starts typing
    final int unicodeChar = event.getUnicodeChar();
    if ((unicodeChar != 0)
            // If COMBINING_ACCENT is set, it's not a unicode character.
            && ((unicodeChar & KeyCharacterMap.COMBINING_ACCENT) == 0)
            && !Character.isWhitespace(unicodeChar)) {
        if (mActionBarAdapter.isSelectionMode()) {
            // Ignore keyboard input when in selection mode.
            return true;
        }//from   ww  w.  ja v  a2s .c om
        String query = new String(new int[] { unicodeChar }, 0, 1);
        if (!mActionBarAdapter.isSearchMode()) {
            mActionBarAdapter.setSearchMode(true);
            mActionBarAdapter.setQueryString(query);
            return true;
        }
    }

    return super.onKeyDown(keyCode, event);
}