InputFilter not working properly with Samsung

1k Views Asked by At

I've got an EditText and I would like to set the text to uppercase. I used setFilters(new InputFilter[]{new InputFilter.AllCaps()}) which is working most of the time but not on Samsung with autocorrect and autocompletion.

On that kind of device each time I type a letter it replace the former one, leaving me with a 1 character text long. The only way to be able to type multiple characters is to lock caps on keyboard.

I would like to have a solution working on every device, does anyone know how to achieve that ?

1

There are 1 best solutions below

0
On

This is Samsung's keyboard bug and you can't do anything with it. (except android.os.Build.MANUFACTURER check)

Look at InputFilter#filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) method

this method is called when the buffer is going to replace the range dstart … dend of dest with the new text from the range start … end of source.

And the output for:

Normal device:

"s" 0 1 "" 0 0 -> "S"
"e" 0 1 "S" 1 1 -> "E"

Samsung:

"s" 0 1 "" 0 0 -> "S"
"e" 0 1 "S" 0 1 -> "E"

The Samsung's result doesn't differ from a such result in case you are going to replace one character with other one, for example with using Insert option of clipboard.