美文网首页
Amlogic Android N LatinIME 数字键盘移

Amlogic Android N LatinIME 数字键盘移

作者: 小磊长江大 | 来源:发表于2020-03-25 10:36 被阅读0次
    ---
     .../keyboard/MainKeyboardView.java            | 30 +++++++++++++++++++
     1 file changed, 30 insertions(+)
    
    diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
    index 209a50d..815b25d 100644
    --- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
    +++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
    @@ -823,6 +823,8 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
                     Key tmp = sortedKeys.get(i);
                     if (k.getY() >= tmp.getY())
                            continue;
    +                if (tmp.getCode() == Constants.CODE_UNSPECIFIED)
    +                       continue;
                     if (checkFacing(k, tmp)) {
                         ret =  tmp;
                         lastFocusIndex = i;
    @@ -859,6 +861,8 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
                     Key tmp = sortedKeys.get(i);
                     if (k.getY() <= tmp.getY())
                         continue;
    +                if (tmp.getCode() == Constants.CODE_UNSPECIFIED)
    +                    continue;
                     if (checkFacing(k, tmp)) {
                         ret =  tmp;
                         lastFocusIndex = i;
    @@ -905,6 +909,18 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
             if (lastFocusIndex > 0 && lastFocusIndex < sz) {
                 lastFocusIndex--;
                 ret = sortedKeys.get(lastFocusIndex);
    +            while (ret.getCode() == Constants.CODE_UNSPECIFIED) {
    +                    lastFocusIndex--;
    +                    if (lastFocusIndex < 0) {
    +                            while (ret.getCode() == Constants.CODE_UNSPECIFIED) {
    +                                    lastFocusIndex++;
    +                                    ret = sortedKeys.get(lastFocusIndex);
    +                            }
    +
    +                    } else {
    +                            ret = sortedKeys.get(lastFocusIndex);
    +                    }
    +            }
                 changeFocusState(lastFocusKey, ret);
                 KeyEventProcessedFlag = true;
                 LatinIME.mIsFocusInKeyboard = true;
    @@ -924,6 +940,20 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
             if (lastFocusIndex >= 0 &&  lastFocusIndex < sz -1) {
                 lastFocusIndex++;
                 ret = sortedKeys.get(lastFocusIndex);
    +       //we do not move to undefined keys
    +            while (ret.getCode() == Constants.CODE_UNSPECIFIED) {
    +                    lastFocusIndex++;
    +                    // 最后一位或连续多位为无效按键
    +                    if (lastFocusIndex >= sz) {
    +                            while (ret.getCode() == Constants.CODE_UNSPECIFIED) {
    +                                    lastFocusIndex--;
    +                                    ret = sortedKeys.get(lastFocusIndex);
    +                            }
    +
    +                    } else {
    +                            ret = sortedKeys.get(lastFocusIndex);
    +                    }
    +            }
                 changeFocusState(lastFocusKey, ret);
             }
             if (ret != null && DEBUG) {
    -- 
    2.17.1
    
    

    相关文章

      网友评论

          本文标题:Amlogic Android N LatinIME 数字键盘移

          本文链接:https://www.haomeiwen.com/subject/ctltuhtx.html