Java Code Examples for android.text.method.MetaKeyKeyListener#adjustMetaAfterKeypress()

The following examples show how to use android.text.method.MetaKeyKeyListener#adjustMetaAfterKeypress() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TerminalKeyboard.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
     * This translates incoming hard key events in to edit operations on an
     * InputConnection.  It is only needed when using the
     * PROCESS_HARD_KEYS option.
     */
    private boolean translateKeyDown(int keyCode, KeyEvent event) {
//        Log.v("SpartacusRex","SOFT : translateKeyDown "+keyCode);

        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);
            }
        }

        onKey(c, null);

        return true;
    }
 
Example 2
Source File: ArrowKeyMovementMethod.java    From PowerFileExplorer with GNU General Public License v3.0 5 votes vote down vote up
public boolean onKeyDown(TextView widget, Spannable buffer, int keyCode, KeyEvent event) {
    if (executeDown(widget, buffer, keyCode,event)) {
        MetaKeyKeyListener.adjustMetaAfterKeypress(buffer);
        resetLockedMeta(buffer);
        return true;
    }

    return false;
}
 
Example 3
Source File: SoftKeyboard.java    From AndroidKeyboard with GNU General Public License v3.0 5 votes vote down vote up
/**
 * This translates incoming hard key events in to edit operations on an
 * InputConnection.  It is only needed when using the
 * PROCESS_HARD_KEYS option.
 */
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;
    }

    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;
}
 
Example 4
Source File: ArrowKeyMovementMethod.java    From JotaTextEditor with Apache License 2.0 5 votes vote down vote up
public boolean onKeyDown(TextView widget, Spannable buffer, int keyCode, KeyEvent event) {
    if (executeDown(widget, buffer, keyCode,event)) {
        MetaKeyKeyListener.adjustMetaAfterKeypress(buffer);
        resetLockedMeta(buffer);
        return true;
    }

    return false;
}
 
Example 5
Source File: ArrowKeyMovementMethod.java    From PowerFileExplorer with GNU General Public License v3.0 4 votes vote down vote up
private boolean executeDown(TextView widget, Spannable buffer, int keyCode , KeyEvent event) {
    boolean handled = false;

    if ( keyCode == KEYCODE_PAGE_UP ){
        handled |= volup(widget, buffer);
    }else if ( keyCode == KEYCODE_PAGE_DOWN){
        handled |= voldown(widget, buffer);
    }else if ( keyCode == KEYCODE_MOVE_HOME){
        handled |= movehome(widget, buffer ,event);
    }else if ( keyCode == KEYCODE_MOVE_END){
        handled |= moveend(widget, buffer , event);
    }else{
        switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_UP:
            handled |= up(widget, buffer);
            break;

        case KeyEvent.KEYCODE_DPAD_DOWN:
            handled |= down(widget, buffer);
            break;

        case KeyEvent.KEYCODE_DPAD_LEFT:
            handled |= left(widget, buffer);
            break;

        case KeyEvent.KEYCODE_DPAD_RIGHT:
            handled |= right(widget, buffer);
            break;

        case KeyEvent.KEYCODE_DPAD_CENTER:
            if (JotaTextKeyListener.getMetaStateSelecting(buffer) != 0) {
                if (widget.showContextMenu()) {
                    handled = true;
                }
            }
            break;
        case KeyEvent.KEYCODE_VOLUME_UP:
            if ( sUseVolumeKey ){
                handled |= volup(widget, buffer);
            }
            break;
        case KeyEvent.KEYCODE_VOLUME_DOWN:
            if ( sUseVolumeKey ){
                handled |= voldown(widget, buffer);
            }
            break;
        }
    }
    if (handled) {
        MetaKeyKeyListener.adjustMetaAfterKeypress(buffer);
        resetLockedMeta(buffer);
    }

    return handled;
}
 
Example 6
Source File: Utf7ImeService.java    From android-unicode with MIT License 4 votes vote down vote up
private int getUnicodeChar(int keyCode, KeyEvent event) {
    mMetaState = MetaKeyKeyListener.handleKeyDown(mMetaState, keyCode, event);
    int c = event.getUnicodeChar(MetaKeyKeyListener.getMetaState(mMetaState));
    mMetaState = MetaKeyKeyListener.adjustMetaAfterKeypress(mMetaState);
    return c;
}
 
Example 7
Source File: ArrowKeyMovementMethod.java    From JotaTextEditor with Apache License 2.0 4 votes vote down vote up
private boolean executeDown(TextView widget, Spannable buffer, int keyCode , KeyEvent event) {
    boolean handled = false;

    if ( keyCode == KEYCODE_PAGE_UP ){
        handled |= volup(widget, buffer);
    }else if ( keyCode == KEYCODE_PAGE_DOWN){
        handled |= voldown(widget, buffer);
    }else if ( keyCode == KEYCODE_MOVE_HOME){
        handled |= movehome(widget, buffer ,event);
    }else if ( keyCode == KEYCODE_MOVE_END){
        handled |= moveend(widget, buffer , event);
    }else{
        switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_UP:
            handled |= up(widget, buffer);
            break;

        case KeyEvent.KEYCODE_DPAD_DOWN:
            handled |= down(widget, buffer);
            break;

        case KeyEvent.KEYCODE_DPAD_LEFT:
            handled |= left(widget, buffer);
            break;

        case KeyEvent.KEYCODE_DPAD_RIGHT:
            handled |= right(widget, buffer);
            break;

        case KeyEvent.KEYCODE_DPAD_CENTER:
            if (JotaTextKeyListener.getMetaStateSelecting(buffer) != 0) {
                if (widget.showContextMenu()) {
                    handled = true;
                }
            }
            break;
        case KeyEvent.KEYCODE_VOLUME_UP:
            if ( sUseVolumeKey ){
                handled |= volup(widget, buffer);
            }
            break;
        case KeyEvent.KEYCODE_VOLUME_DOWN:
            if ( sUseVolumeKey ){
                handled |= voldown(widget, buffer);
            }
            break;
        }
    }
    if (handled) {
        MetaKeyKeyListener.adjustMetaAfterKeypress(buffer);
        resetLockedMeta(buffer);
    }

    return handled;
}
 
Example 8
Source File: UnicodeIME.java    From io.appium.android.ime with Apache License 2.0 4 votes vote down vote up
private int getUnicodeChar(int keyCode, KeyEvent event) {
    metaState = MetaKeyKeyListener.handleKeyDown(metaState, keyCode, event);
    int c = event.getUnicodeChar(event.getMetaState());
    metaState = MetaKeyKeyListener.adjustMetaAfterKeypress(metaState);
    return c;
}
 
Example 9
Source File: UnicodeIME.java    From io.appium.settings with Apache License 2.0 4 votes vote down vote up
private int getUnicodeChar(int keyCode, KeyEvent event) {
    metaState = MetaKeyKeyListener.handleKeyDown(metaState, keyCode, event);
    int c = event.getUnicodeChar(event.getMetaState());
    metaState = MetaKeyKeyListener.adjustMetaAfterKeypress(metaState);
    return c;
}
 
Example 10
Source File: AppiumIME.java    From io.appium.settings with Apache License 2.0 4 votes vote down vote up
private int getUnicodeChar(int keyCode, KeyEvent event) {
    metaState = MetaKeyKeyListener.handleKeyDown(metaState, keyCode, event);
    int c = event.getUnicodeChar(event.getMetaState());
    metaState = MetaKeyKeyListener.adjustMetaAfterKeypress(metaState);
    return c;
}
 
Example 11
Source File: Utf7ImeService.java    From uiautomator-unicode-input-helper with Apache License 2.0 4 votes vote down vote up
private int getUnicodeChar(int keyCode, KeyEvent event) {
    mMetaState = MetaKeyKeyListener.handleKeyDown(mMetaState, keyCode, event);
    int c = event.getUnicodeChar(MetaKeyKeyListener.getMetaState(mMetaState));
    mMetaState = MetaKeyKeyListener.adjustMetaAfterKeypress(mMetaState);
    return c;
}