java类android.text.method.MetaKeyKeyListener的实例源码

TerminalKeyboard.java 文件源码 项目:javaide 阅读 25 收藏 0 点赞 0 评论 0
/**
     * Use this to monitor key events being delivered to the application.
     * We get first crack at them, and can either resume them or let them
     * continue to the app.
     */
    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
//        Log.v("SpartacusRex","SOFT : onKeyUp "+keyCode +" "+event.getMetaState());

        // If we want to do transformations on text being entered with a hard
        // keyboard, we need to process the up events to update the meta key
        // state we are tracking.
        if (PROCESS_HARD_KEYS) {
            if (mPredictionOn) {
                mMetaState = MetaKeyKeyListener.handleKeyUp(mMetaState,
                        keyCode, event);
            }
        }

        return super.onKeyUp(keyCode, event);
    }
TextView.java 文件源码 项目:Tada 阅读 24 收藏 0 点赞 0 评论 0
@Override
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
    if (mTemporaryDetach) {
        // If we are temporarily in the detach state, then do nothing.
        super.onFocusChanged(focused, direction, previouslyFocusedRect);
        return;
    }

    if (mEditor != null) mEditor.onFocusChanged(focused, direction);

    if (focused) {
        if (mText instanceof Spannable) {
            Spannable sp = (Spannable) mText;
            MetaKeyKeyListener.resetMetaState(sp);
        }
    }

    startStopMarquee(focused);

    if (mTransformation != null) {
        mTransformation.onFocusChanged(this, mText, focused, direction, previouslyFocusedRect);
    }

    super.onFocusChanged(focused, direction, previouslyFocusedRect);
}
QtActivity.java 文件源码 项目:uds 阅读 24 收藏 0 点赞 0 评论 0
@Override
    public boolean onKeyDown(int keyCode, KeyEvent event)
    {
        if (!m_started)
            return false;
        m_metaState = MetaKeyKeyListener.handleKeyDown(m_metaState, keyCode, event);
        int c = event.getUnicodeChar(MetaKeyKeyListener.getMetaState(m_metaState));
        int lc=c;
        m_metaState = MetaKeyKeyListener.adjustMetaAfterKeypress(m_metaState);

        if ((c & KeyCharacterMap.COMBINING_ACCENT) != 0)
        {
            c = c & KeyCharacterMap.COMBINING_ACCENT_MASK;
            int composed = KeyEvent.getDeadChar(m_lastChar, c);
            c = composed;
        }
        m_lastChar = lc;
//        if (keyCode != KeyEvent.KEYCODE_BACK)
                QtApplication.keyDown(keyCode, c, event.getMetaState());
        return true;
    }
ArrowKeyMovementMethod.java 文件源码 项目:JotaTextEditor 阅读 19 收藏 0 点赞 0 评论 0
private boolean up(TextView widget, Spannable buffer) {
        boolean cap = (MetaKeyKeyListener.getMetaState(buffer,
                        KeyEvent.META_SHIFT_ON) == 1) ||
                      (JotaTextKeyListener.getMetaStateSelecting(buffer) != 0);
        boolean alt = MetaKeyKeyListener.getMetaState(buffer,
                        KeyEvent.META_ALT_ON) == 1;
        Layout layout = widget.getLayout();

        if (cap) {
            if (alt) {
//                Selection.extendSelection(buffer, 0);
                widget.movePage(true,true);
                return true;
            } else {
                return Selection.extendUp(buffer, layout);
            }
        } else {
            if (alt) {
//                Selection.setSelection(buffer, 0);
                widget.movePage(true,false);
                return true;
            } else {
                return Selection.moveUp(buffer, layout);
            }
        }
    }
ArrowKeyMovementMethod.java 文件源码 项目:JotaTextEditor 阅读 32 收藏 0 点赞 0 评论 0
private boolean down(TextView widget, Spannable buffer) {
        boolean cap = (MetaKeyKeyListener.getMetaState(buffer,
                        KeyEvent.META_SHIFT_ON) == 1) ||
                      (JotaTextKeyListener.getMetaStateSelecting(buffer) != 0);
        boolean alt = MetaKeyKeyListener.getMetaState(buffer,
                        KeyEvent.META_ALT_ON) == 1;
        Layout layout = widget.getLayout();

        if (cap) {
            if (alt) {
//                Selection.extendSelection(buffer, buffer.length());
                widget.movePage(false,true);
                return true;
            } else {
                return Selection.extendDown(buffer, layout);
            }
        } else {
            if (alt) {
//                Selection.setSelection(buffer, buffer.length());
                widget.movePage(false,false);
                return true;
            } else {
                return Selection.moveDown(buffer, layout);
            }
        }
    }
ArrowKeyMovementMethod.java 文件源码 项目:JotaTextEditor 阅读 25 收藏 0 点赞 0 评论 0
private boolean left(TextView widget, Spannable buffer) {
    boolean cap = (MetaKeyKeyListener.getMetaState(buffer,
                    KeyEvent.META_SHIFT_ON) == 1) ||
                  (JotaTextKeyListener.getMetaStateSelecting(buffer) != 0);
    boolean alt = MetaKeyKeyListener.getMetaState(buffer,
                    KeyEvent.META_ALT_ON) == 1;
    Layout layout = widget.getLayout();

    if (cap) {
        if (alt) {
            return Selection.extendToLeftEdge(buffer, layout);
        } else {
            return Selection.extendLeft(buffer, layout);
        }
    } else {
        if (alt) {
            return Selection.moveToLeftEdge(buffer, layout);
        } else {
            return Selection.moveLeft(buffer, layout);
        }
    }
}
ArrowKeyMovementMethod.java 文件源码 项目:JotaTextEditor 阅读 22 收藏 0 点赞 0 评论 0
private boolean right(TextView widget, Spannable buffer) {
    boolean cap = (MetaKeyKeyListener.getMetaState(buffer,
                    KeyEvent.META_SHIFT_ON) == 1) ||
                  (JotaTextKeyListener.getMetaStateSelecting(buffer) != 0);
    boolean alt = MetaKeyKeyListener.getMetaState(buffer,
                    KeyEvent.META_ALT_ON) == 1;
    Layout layout = widget.getLayout();

    if (cap) {
        if (alt) {
            return Selection.extendToRightEdge(buffer, layout);
        } else {
            return Selection.extendRight(buffer, layout);
        }
    } else {
        if (alt) {
            return Selection.moveToRightEdge(buffer, layout);
        } else {
            return Selection.moveRight(buffer, layout);
        }
    }
}
ArrowKeyMovementMethod.java 文件源码 项目:JotaTextEditor 阅读 21 收藏 0 点赞 0 评论 0
private boolean movehome(TextView widget, Spannable buffer, KeyEvent event) {
    boolean cap = (MetaKeyKeyListener.getMetaState(buffer,
                    KeyEvent.META_SHIFT_ON) == 1) ||
                  (JotaTextKeyListener.getMetaStateSelecting(buffer) != 0);
    Layout layout = widget.getLayout();

    boolean ctrl = (event.getMetaState() & mShortcutCtrlKey)!=0;

    if ( ctrl ){
        if (cap) {
            Selection.extendSelection(buffer, 0);
            return true;
        } else {
            Selection.setSelection(buffer, 0);
            return true;
        }
    }else{
        if (cap) {
            return Selection.extendToLeftEdge(buffer, layout);
        } else {
            return Selection.moveToLeftEdge(buffer, layout);
        }
    }
}
ArrowKeyMovementMethod.java 文件源码 项目:JotaTextEditor 阅读 23 收藏 0 点赞 0 评论 0
private boolean moveend(TextView widget, Spannable buffer, KeyEvent event) {
    boolean cap = (MetaKeyKeyListener.getMetaState(buffer,
                    KeyEvent.META_SHIFT_ON) == 1) ||
                  (JotaTextKeyListener.getMetaStateSelecting(buffer) != 0);
    Layout layout = widget.getLayout();

    boolean ctrl = (event.getMetaState() & mShortcutCtrlKey)!=0;

    if ( ctrl ){
        if (cap) {
            Selection.extendSelection(buffer, buffer.length());
            return true;
        } else {
            Selection.setSelection(buffer, buffer.length());
            return true;
        }
    }else{
        if (cap) {
            return Selection.extendToRightEdge(buffer, layout);
        } else {
            return Selection.moveToRightEdge(buffer, layout);
        }
    }
}
TerminalKeyboard.java 文件源码 项目:ZShaolin 阅读 27 收藏 0 点赞 0 评论 0
/**
     * Use this to monitor key events being delivered to the application.
     * We get first crack at them, and can either resume them or let them
     * continue to the app.
     */
    @Override public boolean onKeyUp(int keyCode, KeyEvent event) {
//        Log.v("SpartacusRex","SOFT : onKeyUp "+keyCode +" "+event.getMetaState());

        // If we want to do transformations on text being entered with a hard
        // keyboard, we need to process the up events to update the meta key
        // state we are tracking.
        if (PROCESS_HARD_KEYS) {
            if (mPredictionOn) {
                mMetaState = MetaKeyKeyListener.handleKeyUp(mMetaState,
                        keyCode, event);
            }
        }

        return super.onKeyUp(keyCode, event);
    }
PCKeyboard.java 文件源码 项目:behe-keyboard 阅读 24 收藏 0 点赞 0 评论 0
/**
 * 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;
    }

    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;
}
TerminalKeyboard.java 文件源码 项目:javaide 阅读 27 收藏 0 点赞 0 评论 0
/**
     * 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;
    }
SoftKeyboard.java 文件源码 项目:tibetan-keyboard 阅读 16 收藏 0 点赞 0 评论 0
/**
 * 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;
    }

    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;
}
SoftKeyboard.java 文件源码 项目:tibetan-keyboard 阅读 19 收藏 0 点赞 0 评论 0
/**
 * Use this to monitor key events being delivered to the application.
 * We get first crack at them, and can either resume them or let them
 * continue to the app.
 */
@Override public boolean onKeyUp(int keyCode, KeyEvent event) {
    // If we want to do transformations on text being entered with a hard
    // keyboard, we need to process the up events to update the meta key
    // state we are tracking.
    if (PROCESS_HARD_KEYS) {
        if (mPredictionOn) {
            mMetaState = MetaKeyKeyListener.handleKeyUp(mMetaState,
                    keyCode, event);
        }
    }

    return super.onKeyUp(keyCode, event);
}
SoftKeyboard.java 文件源码 项目:accentype-android 阅读 25 收藏 0 点赞 0 评论 0
/**
 * 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;
    }

    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;
}
SoftKeyboard.java 文件源码 项目:accentype-android 阅读 20 收藏 0 点赞 0 评论 0
/**
 * Use this to monitor key events being delivered to the application.
 * We get first crack at them, and can either resume them or let them
 * continue to the app.
 */
@Override public boolean onKeyUp(int keyCode, KeyEvent event) {
    // If we want to do transformations on text being entered with a hard
    // keyboard, we need to process the up events to update the meta key
    // state we are tracking.
    if (PROCESS_HARD_KEYS) {
        if (mPredictionOn) {
            mMetaState = MetaKeyKeyListener.handleKeyUp(mMetaState,
                    keyCode, event);
        }
    }

    return super.onKeyUp(keyCode, event);
}
SoftKeyboard.java 文件源码 项目:literatim 阅读 21 收藏 0 点赞 0 评论 0
/**
 * 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;
    }

    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;
}
SoftKeyboard.java 文件源码 项目:literatim 阅读 17 收藏 0 点赞 0 评论 0
/**
 * Use this to monitor key events being delivered to the application.
 * We get first crack at them, and can either resume them or let them
 * continue to the app.
 */
@Override public boolean onKeyUp(int keyCode, KeyEvent event) {
    // If we want to do transformations on text being entered with a hard
    // keyboard, we need to process the up events to update the meta key
    // state we are tracking.
    if (PROCESS_HARD_KEYS) {
        if (mPredictionOn) {
            mMetaState = MetaKeyKeyListener.handleKeyUp(mMetaState,
                    keyCode, event);
        }
    }

    return super.onKeyUp(keyCode, event);
}
TextView.java 文件源码 项目:Tada 阅读 22 收藏 0 点赞 0 评论 0
public void afterTextChanged(Editable buffer) {
    if (DEBUG_EXTRACT) Log.v(LOG_TAG, "afterTextChanged: " + buffer);
    TextView.this.sendAfterTextChanged(buffer);

    if (MetaKeyKeyListener.getMetaState(buffer, MetaKeyKeyListener.META_SELECTING) != 0) {
        MetaKeyKeyListener.stopSelecting(TextView.this, buffer);
    }
}
QtActivity.java 文件源码 项目:uds 阅读 22 收藏 0 点赞 0 评论 0
@Override
public boolean onKeyUp(int keyCode, KeyEvent event)
{
    if (!m_started)
        return false;
    m_metaState = MetaKeyKeyListener.handleKeyUp(m_metaState, keyCode, event);
    QtApplication.keyUp(keyCode, event.getUnicodeChar(), event.getMetaState());
    return true;
}
SoftKeyboard.java 文件源码 项目:accentype-android 阅读 18 收藏 0 点赞 0 评论 0
/**
 * 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;
    }

    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;
}
SoftKeyboard.java 文件源码 项目:accentype-android 阅读 14 收藏 0 点赞 0 评论 0
/**
 * Use this to monitor key events being delivered to the application.
 * We get first crack at them, and can either resume them or let them
 * continue to the app.
 */
@Override public boolean onKeyUp(int keyCode, KeyEvent event) {
    // If we want to do transformations on text being entered with a hard
    // keyboard, we need to process the up events to update the meta key
    // state we are tracking.
    if (PROCESS_HARD_KEYS) {
        if (mPredictionOn) {
            mMetaState = MetaKeyKeyListener.handleKeyUp(mMetaState,
                    keyCode, event);
        }
    }

    return super.onKeyUp(keyCode, event);
}
TextView.java 文件源码 项目:JotaTextEditor 阅读 27 收藏 0 点赞 0 评论 0
public void afterTextChanged(Editable buffer) {
    if (DEBUG_EXTRACT) Log.v(TAG, "afterTextChanged: " + buffer);
    TextView.this.sendAfterTextChanged(buffer);

    if (JotaTextKeyListener.getMetaStateSelecting(buffer) != 0) {
        MetaKeyKeyListener.stopSelecting(TextView.this, buffer);
    }
}
ArrowKeyMovementMethod.java 文件源码 项目:JotaTextEditor 阅读 28 收藏 0 点赞 0 评论 0
public boolean doFunction(TextView widget, Spannable buffer, int function)
{
    boolean cap = (MetaKeyKeyListener.getMetaState(buffer,
            KeyEvent.META_SHIFT_ON) == 1) ||
          (JotaTextKeyListener.getMetaStateSelecting(buffer) != 0);

    Log.d("=========================>","cap="+cap);

    switch( function )
    {
        case TextView.FUNCTION_CURSOR_LEFT:
            return moveLeft(widget, buffer, cap);
        case TextView.FUNCTION_CURSOR_RIGHT:
            return moveRight(widget, buffer, cap);
        case TextView.FUNCTION_CURSOR_UP:
            return moveUp(widget, buffer, cap);
        case TextView.FUNCTION_CURSOR_DOWN:
            return moveDown(widget, buffer, cap);
        case TextView.FUNCTION_PAGE_UP:
            return movePageUp(widget, buffer, cap);
        case TextView.FUNCTION_PAGE_DOWN:
            return movePageDown(widget, buffer, cap);
        case TextView.FUNCTION_HOME:
            return moveHome(widget, buffer, cap);
        case TextView.FUNCTION_END:
            return moveEnd(widget, buffer, cap);
        case TextView.FUNCTION_TOP:
            return moveTop(widget, buffer, cap);
        case TextView.FUNCTION_BOTTOM:
            return moveBottom(widget, buffer, cap);
    }
    return false;
}
ArrowKeyMovementMethod.java 文件源码 项目:JotaTextEditor 阅读 20 收藏 0 点赞 0 评论 0
private boolean volup(TextView widget, Spannable buffer) {
    boolean cap = (MetaKeyKeyListener.getMetaState(buffer,
                    KeyEvent.META_SHIFT_ON) == 1) ||
                  (JotaTextKeyListener.getMetaStateSelecting(buffer) != 0);
    if (cap) {
        widget.movePage(true,true);
        return true;
    } else {
        widget.movePage(true,false);
        return true;
    }
}
ArrowKeyMovementMethod.java 文件源码 项目:JotaTextEditor 阅读 20 收藏 0 点赞 0 评论 0
private boolean voldown(TextView widget, Spannable buffer) {
    boolean cap = (MetaKeyKeyListener.getMetaState(buffer,
                    KeyEvent.META_SHIFT_ON) == 1) ||
                  (JotaTextKeyListener.getMetaStateSelecting(buffer) != 0);
    if (cap) {
        widget.movePage(false,true);
        return true;
    } else {
        widget.movePage(false,false);
        return true;
    }
}
ArrowKeyMovementMethod.java 文件源码 项目:JotaTextEditor 阅读 24 收藏 0 点赞 0 评论 0
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;
}
ArrowKeyMovementMethod.java 文件源码 项目:JotaTextEditor 阅读 26 收藏 0 点赞 0 评论 0
public static MovementMethod getInstance() {
    if (sInstance == null)
        sInstance = new ArrowKeyMovementMethod();

        try{
            Class<?> c = MetaKeyKeyListener.class;
            sMethod = c.getDeclaredMethod("resetLockedMeta", new Class[]{ Spannable.class });
            sMethod.setAccessible(true);

        }catch(Exception e){
    }
    return sInstance;
}
TerminalKeyboard.java 文件源码 项目:ZShaolin 阅读 24 收藏 0 点赞 0 评论 0
/**
     * 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;
    }
AnimalKeyboard.java 文件源码 项目:animal 阅读 20 收藏 0 点赞 0 评论 0
/**
 * 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;
    }

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


问题


面经


文章

微信
公众号

扫码关注公众号