RussianIME 全程解析4

10 篇文章 0 订阅

7 deal with double click event

 

 

beacuse RussianIME has 31 characters,so one hardkey should have two character display function,how to deal with it,so just listen the keydown time ,and set one standard keydowntime max value,if people press one time,it will show A character,and if people press two times in the same hardkey quickly (keydown time is smaller than the max value),it will show B character.

The logic is

"if( bIsRussianHardboard == true && (System.currentTimeMillis() - iLastPressTime < MULTIPRESS_DELAY) && iLastKeycode == keyCode && !bIsReplaced && (KeyEvent.KEYCODE_Q == keyCode || KeyEvent.KEYCODE_P == keyCode || KeyEvent.KEYCODE_Z == keyCode || KeyEvent.KEYCODE_K == keyCode || KeyEvent.KEYCODE_L == keyCode || KeyEvent.KEYCODE_PERIOD == keyCode))"

{
                     bIsReplaced = true;
                     Log.i("isReplace", bIsReplaced + ";" );

                        iLastPressTime = -1;
                        final InputConnection ic = getCurrentInputConnection();
                        CharSequence lastChar = ic.getTextBeforeCursor(2, 0);
                        if (lastChar != null && lastChar.length() == 1
                                    && (lastChar.charAt(0)== '/u0419'||lastChar.charAt(0)== '/u042F'||lastChar.charAt(0)== '/u0416'||lastChar.charAt(0)== '/u0425'||lastChar.charAt(0)== '/u041B'||lastChar.charAt(0) ==KEYCODE_PERIOD))
                        {
                                Log.i("LASTCHAR", lastChar.charAt(0)+ ";");
                                hardCap = true;

                        }
                        else
                        {
                                hardCap = false;
                        }
                        handleBackspace();


                }
        else
                {
                bIsReplaced = false;


                iLastKeycode = keyCode;
                iLastPressTime = System.currentTimeMillis();
                }

 

// Convert a hardware key code to the corresponding Russian character code (in Unicode)

 

private int keyCodeToChar (int keyCode, boolean upperCase, int accentState) {
        int code;
        if (bIsReplaced) {
                if (hardCap == true)
                {
                code = sDcKeyCodeTable.get(keyCode, -1);
                }
                else
                {
                code = sDKeyCodeTable.get(keyCode, -1);
                }

                Log.d("Table","TableUsed is KeyCode");
        } else {
                code = sKeyCodeTable.get(keyCode, -1);
                Log.d("Table","TableUsed is sKeyCode");

        }
        if (accentState != ACCENT_STATE_NONE) {
                code = addAccent(code, accentState);
        }
        if (upperCase) {
                code = Character.toUpperCase(code);
        }
        return code;
    }

 

 

 

That is all.



 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值