Example usage for android.text.method MetaKeyKeyListener getMetaState

List of usage examples for android.text.method MetaKeyKeyListener getMetaState

Introduction

In this page you can find the example usage for android.text.method MetaKeyKeyListener getMetaState.

Prototype

public static final int getMetaState(long state) 

Source Link

Document

Gets the state of the meta keys.

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.//  www  .j  a  v  a  2  s.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 = 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 . ja  v a  2  s. 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;
}