Search in sources :

Example 16 with MovementMethod

use of android.text.method.MovementMethod in project android_frameworks_base by crdroidandroid.

the class InputMethodService method doMovementKey.

boolean doMovementKey(int keyCode, KeyEvent event, int count) {
    final ExtractEditText eet = getExtractEditTextIfVisible();
    if (eet != null) {
        // If we are in fullscreen mode, the cursor will move around
        // the extract edit text, but should NOT cause focus to move
        // to other fields.
        MovementMethod movement = eet.getMovementMethod();
        Layout layout = eet.getLayout();
        if (movement != null && layout != null) {
            // cursor will properly move in our own word wrapping.
            if (count == MOVEMENT_DOWN) {
                if (movement.onKeyDown(eet, eet.getText(), keyCode, event)) {
                    reportExtractedMovement(keyCode, 1);
                    return true;
                }
            } else if (count == MOVEMENT_UP) {
                if (movement.onKeyUp(eet, eet.getText(), keyCode, event)) {
                    return true;
                }
            } else {
                if (movement.onKeyOther(eet, eet.getText(), event)) {
                    reportExtractedMovement(keyCode, count);
                } else {
                    KeyEvent down = KeyEvent.changeAction(event, KeyEvent.ACTION_DOWN);
                    if (movement.onKeyDown(eet, eet.getText(), keyCode, down)) {
                        KeyEvent up = KeyEvent.changeAction(event, KeyEvent.ACTION_UP);
                        movement.onKeyUp(eet, eet.getText(), keyCode, up);
                        while (--count > 0) {
                            movement.onKeyDown(eet, eet.getText(), keyCode, down);
                            movement.onKeyUp(eet, eet.getText(), keyCode, up);
                        }
                        reportExtractedMovement(keyCode, count);
                    }
                }
            }
        }
        // we never allow DPAD navigation to the application.
        switch(keyCode) {
            case KeyEvent.KEYCODE_DPAD_LEFT:
            case KeyEvent.KEYCODE_DPAD_RIGHT:
            case KeyEvent.KEYCODE_DPAD_UP:
            case KeyEvent.KEYCODE_DPAD_DOWN:
                return true;
        }
    }
    return false;
}
Also used : KeyEvent(android.view.KeyEvent) LinearLayout(android.widget.LinearLayout) FrameLayout(android.widget.FrameLayout) Layout(android.text.Layout) MovementMethod(android.text.method.MovementMethod)

Aggregations

MovementMethod (android.text.method.MovementMethod)16 Layout (android.text.Layout)7 KeyEvent (android.view.KeyEvent)7 FrameLayout (android.widget.FrameLayout)7 LinearLayout (android.widget.LinearLayout)7 Paint (android.graphics.Paint)6 Spannable (android.text.Spannable)3 ActivityNotFoundException (android.content.ActivityNotFoundException)1 Context (android.content.Context)1 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)1 Resources (android.content.res.Resources)1 ExtractEditText (android.inputmethodservice.ExtractEditText)1 SpannableStringBuilder (android.text.SpannableStringBuilder)1 Time (android.text.format.Time)1 ArrowKeyMovementMethod (android.text.method.ArrowKeyMovementMethod)1 LinkMovementMethod (android.text.method.LinkMovementMethod)1 ForegroundColorSpan (android.text.style.ForegroundColorSpan)1 MotionEvent (android.view.MotionEvent)1 View (android.view.View)1 OnTouchListener (android.view.View.OnTouchListener)1