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) { createEditorIfNeeded(); mEditor.mKeyListener = input; } else { setKeyListenerOnly(input); } }
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); } }