Finally solved.
Thanks to pskink for key clue. Important link.
The fact is that keyboard need to get someеthing called EditorInfo
from view, which is in focus. It allows EditText
with certain inputMethod
works properly.
So we just need to copy that behavior. You can use any view. I have override LinearLayout
, use it as root viewGroup in xml and mark all views as
android:focusable="false"
android:focusableInTouchMode="false"
and only root has those tags "true". Not sure if both tags important.
then you need just to override two methods in your view
public boolean onCheckIsTextEditor() {
return true;
}
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
outAttrs.inputType = InputType.TYPE_CLASS_TEXT |
InputType.TYPE_TEXT_VARIATION_PASSWORD |
InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD |
InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS |
InputType.TYPE_TEXT_FLAG_MULTI_LINE;
outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_ENTER_ACTION;
return new super.onCreateInputConnection(outAttrs)
}
This will solve most problems. There also some improperly implemented keyboards (for example Emoji Keyboard (at 03/03/14)) which ignores EditorInfo
. If you want - you can overcome even this with custom InputConnection
, which extends BaseInputConnection
- just override
public boolean setComposingText(CharSequence text, int newCursorPosition)
and you will get callback on each composing-event. Not really comfortable, but works at least. And this custom InputConnection
must be returned from view's
public InputConnection onCreateInputConnection(EditorInfo outAttrs)
UPD1. Custom InputConnection
also usefull with Samsung keyboards.