splitwise / TokenAutoComplete

Gmail style MultiAutoCompleteTextView for Android
Apache License 2.0
1.3k stars 383 forks source link

Huawei problem with split words #191

Closed rusmichal closed 8 years ago

rusmichal commented 8 years ago

Hello,

I found small issue on Huawei Y560(5.1.1) and Huawei PL-L-10 (4.x.x). I guess it is small.

For antoher device method filter() work fine thaht mean after tap on split char source return just split char. But for Huawei it is strange. That mean source is single word with spilit char. If I will remove split char and I will add again all (in input field) works fine (renderer tags).

I have char split characters {' ', '#', ','}

If I will write hello# -> hello# I remove '#' in input and add it again then:

  1. hello# -> hello#
  2. hello - remove '#'
  3. hello# ->|#hello|

(The same for other split char) It work only for second time on Huawei devices.

setFilters(new InputFilter[]{new InputFilter() {
            @Override
            public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
                // Token limit check
                if (tokenLimit != -1 && objects.size() == tokenLimit) {
                    if(onTagsOverflowListener != null)
                        onTagsOverflowListener.onOverflow();
                    return "";
                } else if (source.length() == 1) {//Detect split characters, remove them and complete the current token instead
                    if (isSplitChar(source.charAt(0))) {
                        performCompletion();
                        return "";
                    }
                }

                //We need to not do anything when we would delete the prefix
                if (dstart < prefix.length() && dend == prefix.length()) {
                    return prefix.substring(dstart, dend);
                }
                return null;
            }
        }});

I tried to add new if

else if (source.length() > 1) {//Detect split characters, remove them and complete the current token instead
                    if (isSplitChar(source.charAt(source.length() - 1))) {
                        performCompletion();
                        return "";
                    }
                }

But it dosen't work because it is in loop. Any ideas why it dosne't work on great huawei devies?

mgod commented 8 years ago

I think this may have been related to a bug with handling ' ' as a split character and may be fixed in 2.0.3. Can you update and let me know if it's still broken for you there?