android.text.method.MetaKeyKeyListener Java Examples

The following examples show how to use android.text.method.MetaKeyKeyListener. 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 Project: android_9.0.0_r45   Author: lulululbj   File: BaseInputConnection.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * The default implementation changes the selection position in the
 * current editable text.
 */
public boolean setSelection(int start, int end) {
    if (DEBUG) Log.v(TAG, "setSelection " + start + ", " + end);
    final Editable content = getEditable();
    if (content == null) return false;
    int len = content.length();
    if (start > len || end > len || start < 0 || end < 0) {
        // If the given selection is out of bounds, just ignore it.
        // Most likely the text was changed out from under the IME,
        // and the IME is going to have to update all of its state
        // anyway.
        return true;
    }
    if (start == end && MetaKeyKeyListener.getMetaState(content,
            MetaKeyKeyListener.META_SELECTING) != 0) {
        // If we are in selection mode, then we want to extend the
        // selection instead of replacing it.
        Selection.extendSelection(content, start);
    } else {
        Selection.setSelection(content, start, end);
    }
    return true;
}
 
Example #2
Source Project: android_9.0.0_r45   Author: lulululbj   File: KeyEvent.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Normalizes the specified meta state.
 * <p>
 * The meta state is normalized such that if either the left or right modifier meta state
 * bits are set then the result will also include the universal bit for that modifier.
 * </p><p>
 * If the specified meta state contains {@link #META_ALT_LEFT_ON} then
 * the result will also contain {@link #META_ALT_ON} in addition to {@link #META_ALT_LEFT_ON}
 * and the other bits that were specified in the input.  The same is process is
 * performed for shift, control and meta.
 * </p><p>
 * If the specified meta state contains synthetic meta states defined by
 * {@link MetaKeyKeyListener}, then those states are translated here and the original
 * synthetic meta states are removed from the result.
 * {@link MetaKeyKeyListener#META_CAP_LOCKED} is translated to {@link #META_CAPS_LOCK_ON}.
 * {@link MetaKeyKeyListener#META_ALT_LOCKED} is translated to {@link #META_ALT_ON}.
 * {@link MetaKeyKeyListener#META_SYM_LOCKED} is translated to {@link #META_SYM_ON}.
 * </p><p>
 * Undefined meta state bits are removed.
 * </p>
 *
 * @param metaState The meta state.
 * @return The normalized meta state.
 */
public static int normalizeMetaState(int metaState) {
    if ((metaState & (META_SHIFT_LEFT_ON | META_SHIFT_RIGHT_ON)) != 0) {
        metaState |= META_SHIFT_ON;
    }
    if ((metaState & (META_ALT_LEFT_ON | META_ALT_RIGHT_ON)) != 0) {
        metaState |= META_ALT_ON;
    }
    if ((metaState & (META_CTRL_LEFT_ON | META_CTRL_RIGHT_ON)) != 0) {
        metaState |= META_CTRL_ON;
    }
    if ((metaState & (META_META_LEFT_ON | META_META_RIGHT_ON)) != 0) {
        metaState |= META_META_ON;
    }
    if ((metaState & MetaKeyKeyListener.META_CAP_LOCKED) != 0) {
        metaState |= META_CAPS_LOCK_ON;
    }
    if ((metaState & MetaKeyKeyListener.META_ALT_LOCKED) != 0) {
        metaState |= META_ALT_ON;
    }
    if ((metaState & MetaKeyKeyListener.META_SYM_LOCKED) != 0) {
        metaState |= META_SYM_ON;
    }
    return metaState & META_ALL_MASK;
}
 
Example #3
Source Project: java-n-IDE-for-Android   Author: shenghuntianlang   File: TerminalKeyboard.java    License: Apache License 2.0 6 votes vote down vote up
/**
     * 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);
    }
 
Example #4
Source Project: PowerFileExplorer   Author: PowerExplorer   File: ArrowKeyMovementMethod.java    License: GNU General Public License v3.0 6 votes vote down vote up
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);
            }
        }
    }
 
Example #5
Source Project: PowerFileExplorer   Author: PowerExplorer   File: ArrowKeyMovementMethod.java    License: GNU General Public License v3.0 6 votes vote down vote up
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);
            }
        }
    }
 
Example #6
Source Project: PowerFileExplorer   Author: PowerExplorer   File: ArrowKeyMovementMethod.java    License: GNU General Public License v3.0 6 votes vote down vote up
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);
        }
    }
}
 
Example #7
Source Project: PowerFileExplorer   Author: PowerExplorer   File: ArrowKeyMovementMethod.java    License: GNU General Public License v3.0 6 votes vote down vote up
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);
        }
    }
}
 
Example #8
Source Project: PowerFileExplorer   Author: PowerExplorer   File: ArrowKeyMovementMethod.java    License: GNU General Public License v3.0 6 votes vote down vote up
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);
        }
    }
}
 
Example #9
Source Project: PowerFileExplorer   Author: PowerExplorer   File: ArrowKeyMovementMethod.java    License: GNU General Public License v3.0 6 votes vote down vote up
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);
        }
    }
}
 
Example #10
Source Project: JotaTextEditor   Author: jiro-aqua   File: ArrowKeyMovementMethod.java    License: Apache License 2.0 6 votes vote down vote up
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);
            }
        }
    }
 
Example #11
Source Project: JotaTextEditor   Author: jiro-aqua   File: ArrowKeyMovementMethod.java    License: Apache License 2.0 6 votes vote down vote up
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);
            }
        }
    }
 
Example #12
Source Project: JotaTextEditor   Author: jiro-aqua   File: ArrowKeyMovementMethod.java    License: Apache License 2.0 6 votes vote down vote up
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);
        }
    }
}
 
Example #13
Source Project: JotaTextEditor   Author: jiro-aqua   File: ArrowKeyMovementMethod.java    License: Apache License 2.0 6 votes vote down vote up
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);
        }
    }
}
 
Example #14
Source Project: JotaTextEditor   Author: jiro-aqua   File: ArrowKeyMovementMethod.java    License: Apache License 2.0 6 votes vote down vote up
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);
        }
    }
}
 
Example #15
Source Project: JotaTextEditor   Author: jiro-aqua   File: ArrowKeyMovementMethod.java    License: Apache License 2.0 6 votes vote down vote up
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);
        }
    }
}
 
Example #16
Source Project: android_9.0.0_r45   Author: lulululbj   File: BaseInputConnection.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Default implementation uses
 * {@link MetaKeyKeyListener#clearMetaKeyState(long, int)
 * MetaKeyKeyListener.clearMetaKeyState(long, int)} to clear the state.
 */
public boolean clearMetaKeyStates(int states) {
    final Editable content = getEditable();
    if (content == null) return false;
    MetaKeyKeyListener.clearMetaKeyState(content, states);
    return true;
}
 
Example #17
Source Project: java-n-IDE-for-Android   Author: shenghuntianlang   File: TerminalKeyboard.java    License: 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 #18
Source Project: PowerFileExplorer   Author: PowerExplorer   File: ArrowKeyMovementMethod.java    License: GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example #19
Source Project: PowerFileExplorer   Author: PowerExplorer   File: ArrowKeyMovementMethod.java    License: GNU General Public License v3.0 5 votes vote down vote up
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;
    }
}
 
Example #20
Source Project: PowerFileExplorer   Author: PowerExplorer   File: ArrowKeyMovementMethod.java    License: GNU General Public License v3.0 5 votes vote down vote up
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;
    }
}
 
Example #21
Source Project: PowerFileExplorer   Author: PowerExplorer   File: ArrowKeyMovementMethod.java    License: 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 #22
Source Project: PowerFileExplorer   Author: PowerExplorer   File: ArrowKeyMovementMethod.java    License: GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example #23
Source Project: AndroidKeyboard   Author: maihannijat   File: SoftKeyboard.java    License: 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 #24
Source Project: AndroidKeyboard   Author: maihannijat   File: SoftKeyboard.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #25
Source Project: JotaTextEditor   Author: jiro-aqua   File: ArrowKeyMovementMethod.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #26
Source Project: JotaTextEditor   Author: jiro-aqua   File: ArrowKeyMovementMethod.java    License: Apache License 2.0 5 votes vote down vote up
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;
    }
}
 
Example #27
Source Project: JotaTextEditor   Author: jiro-aqua   File: ArrowKeyMovementMethod.java    License: Apache License 2.0 5 votes vote down vote up
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;
    }
}
 
Example #28
Source Project: JotaTextEditor   Author: jiro-aqua   File: ArrowKeyMovementMethod.java    License: 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 #29
Source Project: JotaTextEditor   Author: jiro-aqua   File: ArrowKeyMovementMethod.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #30
Source Project: io.appium.settings   Author: appium   File: UnicodeIME.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    Log.i(TAG, String.format("onKeyUp (keyCode='%s', event.keyCode='%s', metaState='%s')",
            keyCode, event.getKeyCode(), event.getMetaState()));
    metaState = MetaKeyKeyListener.handleKeyUp(metaState, keyCode, event);
    return super.onKeyUp(keyCode, event);
}