Search in sources :

Example 1 with KeyListener

use of android.text.method.KeyListener in project platform_frameworks_base by android.

the class DialerFilter method swapPrimaryAndHint.

private void swapPrimaryAndHint(boolean makeLettersPrimary) {
    Editable lettersText = mLetters.getText();
    Editable digitsText = mDigits.getText();
    KeyListener lettersInput = mLetters.getKeyListener();
    KeyListener digitsInput = mDigits.getKeyListener();
    if (makeLettersPrimary) {
        mLetters = mPrimary;
        mDigits = mHint;
    } else {
        mLetters = mHint;
        mDigits = mPrimary;
    }
    mLetters.setKeyListener(lettersInput);
    mLetters.setText(lettersText);
    lettersText = mLetters.getText();
    Selection.setSelection(lettersText, lettersText.length());
    mDigits.setKeyListener(digitsInput);
    mDigits.setText(digitsText);
    digitsText = mDigits.getText();
    Selection.setSelection(digitsText, digitsText.length());
    // Reset the filters
    mPrimary.setFilters(mInputFilters);
    mHint.setFilters(mInputFilters);
}
Also used : Editable(android.text.Editable) KeyListener(android.text.method.KeyListener) TextKeyListener(android.text.method.TextKeyListener) DialerKeyListener(android.text.method.DialerKeyListener)

Example 2 with KeyListener

use of android.text.method.KeyListener in project XobotOS by xamarin.

the class EditableInputConnection method clearMetaKeyStates.

@Override
public boolean clearMetaKeyStates(int states) {
    final Editable content = getEditable();
    if (content == null)
        return false;
    KeyListener kl = mTextView.getKeyListener();
    if (kl != null) {
        try {
            kl.clearMetaKeyState(mTextView, content, states);
        } catch (AbstractMethodError e) {
        // This is an old listener that doesn't implement the
        // new method.
        }
    }
    return true;
}
Also used : Editable(android.text.Editable) KeyListener(android.text.method.KeyListener)

Example 3 with KeyListener

use of android.text.method.KeyListener in project XobotOS by xamarin.

the class DialerFilter method swapPrimaryAndHint.

private void swapPrimaryAndHint(boolean makeLettersPrimary) {
    Editable lettersText = mLetters.getText();
    Editable digitsText = mDigits.getText();
    KeyListener lettersInput = mLetters.getKeyListener();
    KeyListener digitsInput = mDigits.getKeyListener();
    if (makeLettersPrimary) {
        mLetters = mPrimary;
        mDigits = mHint;
    } else {
        mLetters = mHint;
        mDigits = mPrimary;
    }
    mLetters.setKeyListener(lettersInput);
    mLetters.setText(lettersText);
    lettersText = mLetters.getText();
    Selection.setSelection(lettersText, lettersText.length());
    mDigits.setKeyListener(digitsInput);
    mDigits.setText(digitsText);
    digitsText = mDigits.getText();
    Selection.setSelection(digitsText, digitsText.length());
    // Reset the filters
    mPrimary.setFilters(mInputFilters);
    mHint.setFilters(mInputFilters);
}
Also used : Editable(android.text.Editable) KeyListener(android.text.method.KeyListener) TextKeyListener(android.text.method.TextKeyListener) DialerKeyListener(android.text.method.DialerKeyListener)

Example 4 with KeyListener

use of android.text.method.KeyListener in project Jota-Text-Editor-old by jiro-aqua.

the class TextView method setInputType.

private void setInputType(int type, boolean direct) {
    final int cls = type & EditorInfo.TYPE_MASK_CLASS;
    KeyListener input;
    if (cls == EditorInfo.TYPE_CLASS_TEXT) {
        boolean autotext = (type & EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT) != 0;
        TextKeyListener.Capitalize cap;
        if ((type & EditorInfo.TYPE_TEXT_FLAG_CAP_CHARACTERS) != 0) {
            cap = TextKeyListener.Capitalize.CHARACTERS;
        } else if ((type & EditorInfo.TYPE_TEXT_FLAG_CAP_WORDS) != 0) {
            cap = TextKeyListener.Capitalize.WORDS;
        } else if ((type & EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES) != 0) {
            cap = TextKeyListener.Capitalize.SENTENCES;
        } else {
            cap = TextKeyListener.Capitalize.NONE;
        }
        input = JotaTextKeyListener.getInstance(autotext, cap);
    } else if (cls == EditorInfo.TYPE_CLASS_NUMBER) {
        input = DigitsKeyListener.getInstance((type & EditorInfo.TYPE_NUMBER_FLAG_SIGNED) != 0, (type & EditorInfo.TYPE_NUMBER_FLAG_DECIMAL) != 0);
    } else if (cls == EditorInfo.TYPE_CLASS_DATETIME) {
        switch(type & EditorInfo.TYPE_MASK_VARIATION) {
            case EditorInfo.TYPE_DATETIME_VARIATION_DATE:
                input = DateKeyListener.getInstance();
                break;
            case EditorInfo.TYPE_DATETIME_VARIATION_TIME:
                input = TimeKeyListener.getInstance();
                break;
            default:
                input = DateTimeKeyListener.getInstance();
                break;
        }
    } else if (cls == EditorInfo.TYPE_CLASS_PHONE) {
        input = DialerKeyListener.getInstance();
    } else {
        input = JotaTextKeyListener.getInstance();
    }
    setRawInputType(type);
    if (direct)
        mInput = input;
    else {
        setKeyListenerOnly(input);
    }
}
Also used : TextKeyListener(android.text.method.TextKeyListener) MetaKeyKeyListener(android.text.method.MetaKeyKeyListener) DateTimeKeyListener(android.text.method.DateTimeKeyListener) DigitsKeyListener(android.text.method.DigitsKeyListener) TextKeyListener(android.text.method.TextKeyListener) DialerKeyListener(android.text.method.DialerKeyListener) KeyListener(android.text.method.KeyListener) TimeKeyListener(android.text.method.TimeKeyListener) DateKeyListener(android.text.method.DateKeyListener) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint)

Example 5 with KeyListener

use of android.text.method.KeyListener in project XobotOS by xamarin.

the class TextView method setInputType.

private void setInputType(int type, boolean direct) {
    final int cls = type & EditorInfo.TYPE_MASK_CLASS;
    KeyListener input;
    if (cls == EditorInfo.TYPE_CLASS_TEXT) {
        boolean autotext = (type & EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT) != 0;
        TextKeyListener.Capitalize cap;
        if ((type & EditorInfo.TYPE_TEXT_FLAG_CAP_CHARACTERS) != 0) {
            cap = TextKeyListener.Capitalize.CHARACTERS;
        } else if ((type & EditorInfo.TYPE_TEXT_FLAG_CAP_WORDS) != 0) {
            cap = TextKeyListener.Capitalize.WORDS;
        } else if ((type & EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES) != 0) {
            cap = TextKeyListener.Capitalize.SENTENCES;
        } else {
            cap = TextKeyListener.Capitalize.NONE;
        }
        input = TextKeyListener.getInstance(autotext, cap);
    } else if (cls == EditorInfo.TYPE_CLASS_NUMBER) {
        input = DigitsKeyListener.getInstance((type & EditorInfo.TYPE_NUMBER_FLAG_SIGNED) != 0, (type & EditorInfo.TYPE_NUMBER_FLAG_DECIMAL) != 0);
    } else if (cls == EditorInfo.TYPE_CLASS_DATETIME) {
        switch(type & EditorInfo.TYPE_MASK_VARIATION) {
            case EditorInfo.TYPE_DATETIME_VARIATION_DATE:
                input = DateKeyListener.getInstance();
                break;
            case EditorInfo.TYPE_DATETIME_VARIATION_TIME:
                input = TimeKeyListener.getInstance();
                break;
            default:
                input = DateTimeKeyListener.getInstance();
                break;
        }
    } else if (cls == EditorInfo.TYPE_CLASS_PHONE) {
        input = DialerKeyListener.getInstance();
    } else {
        input = TextKeyListener.getInstance();
    }
    setRawInputType(type);
    if (direct)
        mInput = input;
    else {
        setKeyListenerOnly(input);
    }
}
Also used : TextKeyListener(android.text.method.TextKeyListener) TextKeyListener(android.text.method.TextKeyListener) DialerKeyListener(android.text.method.DialerKeyListener) KeyListener(android.text.method.KeyListener) TimeKeyListener(android.text.method.TimeKeyListener) MetaKeyKeyListener(android.text.method.MetaKeyKeyListener) DateTimeKeyListener(android.text.method.DateTimeKeyListener) DigitsKeyListener(android.text.method.DigitsKeyListener) DateKeyListener(android.text.method.DateKeyListener) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint)

Aggregations

KeyListener (android.text.method.KeyListener)23 Editable (android.text.Editable)15 DialerKeyListener (android.text.method.DialerKeyListener)15 TextKeyListener (android.text.method.TextKeyListener)15 Paint (android.graphics.Paint)8 TextPaint (android.text.TextPaint)8 DateKeyListener (android.text.method.DateKeyListener)8 DateTimeKeyListener (android.text.method.DateTimeKeyListener)8 DigitsKeyListener (android.text.method.DigitsKeyListener)8 MetaKeyKeyListener (android.text.method.MetaKeyKeyListener)8 TimeKeyListener (android.text.method.TimeKeyListener)8