splitwise / TokenAutoComplete

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

Bug: Text not being reset after item selection #51

Closed AndroidDeveloperLB closed 8 years ago

AndroidDeveloperLB commented 10 years ago

On Galaxy S3 with Android 4.3, there is a weird bug:

  1. open the sample project.
  2. start typing "ma" .
  3. choose the last item ("Max Jordan") .
  4. you see just the new item being added, no text next to it (which is what it should be).
  5. continue typing - write "t"

Expected result: seeing the new item, and only the new text next to it. Actual result: seeing the new item, and the text "mat" next to it.

note that for some reason, I can't confirm this on other devices, like the Nexus 4 (has the same Android version).

The bug might be related to another bug I've noticed: when choosing an item and then pressing backspace, it doesn't remove the item AND its text. only the item. So if you typed "ma", chose "Max Jordan", and pressed backspace, the old text of "ma" is shown.


EDIT: Another 2 bugs I've found is on Galaxy S2 with Android v4.0.4 : The first bug is: 1.enter "ma".

  1. choose "Max Jordan". 3.press backspace.

Expected result: it should delete the item that was added. Actual result: the suggestions list popup appears, as if you've typed "ma" (showing 3 items on the list to choose from). However, only the new item is shown .

the second bug is a rare crashing bug, which I cannot reproduce but I think is related to focus. Here's the log: 04-03 09:46:31.985: E/AndroidRuntime(21519): FATAL EXCEPTION: main 04-03 09:46:31.985: E/AndroidRuntime(21519): java.lang.IndexOutOfBoundsException: setSpan (3 ... 3) ends beyond length 2 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:945) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:527) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:520) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.text.Selection.setSelection(Selection.java:76) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.text.Selection.setSelection(Selection.java:87) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.widget.EditText.setSelection(EditText.java:108) 04-03 09:46:31.985: E/AndroidRuntime(21519): at com.tokenautocomplete.library.TokenCompleteTextView.onSelectionChanged(TokenCompleteTextView.java:456) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.widget.TextView.spanChange(TextView.java:8409) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.widget.TextView$ChangeWatcher.onSpanChanged(TextView.java:8740) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.text.SpannableStringBuilder.sendSpanChanged(SpannableStringBuilder.java:927) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:583) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:520) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.text.Selection.setSelection(Selection.java:78) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.text.Selection.setSelection(Selection.java:87) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.widget.EditText.setSelection(EditText.java:108) 04-03 09:46:31.985: E/AndroidRuntime(21519): at com.tokenautocomplete.library.TokenCompleteTextView.handleFocus(TokenCompleteTextView.java:524) 04-03 09:46:31.985: E/AndroidRuntime(21519): at com.tokenautocomplete.library.TokenCompleteTextView.onFocusChanged(TokenCompleteTextView.java:540) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.view.View.handleFocusGainInternal(View.java:3796) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.view.View.requestFocus(View.java:5489) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.view.View.requestFocus(View.java:5439) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.view.View.requestFocus(View.java:5417) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.view.View.onTouchEvent(View.java:6643) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.widget.TextView.onTouchEvent(TextView.java:9010) 04-03 09:46:31.985: E/AndroidRuntime(21519): at com.tokenautocomplete.library.TokenCompleteTextView.onTouchEvent(TokenCompleteTextView.java:422) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.view.View.dispatchTouchEvent(View.java:5717) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1962) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1731) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1962) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1731) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1962) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1731) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1962) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1731) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1962) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1731) 04-03 09:46:31.985: E/AndroidRuntime(21519): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2064) 04-03 09:46:31.985: E/AndroidRuntime(21519): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1400) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.app.Activity.dispatchTouchEvent(Activity.java:2369) 04-03 09:46:31.985: E/AndroidRuntime(21519): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2012) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.view.View.dispatchPointerEvent(View.java:5897) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3115) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2657) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.view.ViewRootImpl.processInputEvents(ViewRootImpl.java:1021) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2666) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.os.Handler.dispatchMessage(Handler.java:99) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.os.Looper.loop(Looper.java:137) 04-03 09:46:31.985: E/AndroidRuntime(21519): at android.app.ActivityThread.main(ActivityThread.java:4511) 04-03 09:46:31.985: E/AndroidRuntime(21519): at java.lang.reflect.Method.invokeNative(Native Method) 04-03 09:46:31.985: E/AndroidRuntime(21519): at java.lang.reflect.Method.invoke(Method.java:511) 04-03 09:46:31.985: E/AndroidRuntime(21519): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980) 04-03 09:46:31.985: E/AndroidRuntime(21519): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747) 04-03 09:46:31.985: E/AndroidRuntime(21519): at dalvik.system.NativeStart.main(Native Method)

suwany commented 10 years ago

your problem Resolution... turnoff suggestions ...

completionView = (ContactsCompletionView)findViewById(R.id.searchView); completionView.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);

AndroidDeveloperLB commented 10 years ago

do it before everything? but wouldn't it also disable the suggestions being shown? anyway, i've made my own library, which is heavily based on Google's code: https://github.com/AndroidDeveloperLB/ChipsLibrary

mgod commented 10 years ago

I believe I fixed the crash issue in master, though I haven't updated the release jar yet.

jimfulton commented 10 years ago

FWIW, I experienced the "Text not being reset after item selection" problem with the Samsung keyboard. Switching to a different keyboard made the problem go away. I expect lots of people use the Samsung keyboard.

Fortunately, suwany's workaround worked great.

mgod commented 10 years ago

The Samsung keyboard is really annoying. I've had a number of issues with it. If you're still seeing the crash, grab release 1.2 and see if it fixes it.

AndroidDeveloperLB commented 10 years ago

@mgod I actually quite liked Samsung's keyboard. Currently, since I moved to AOSP (and maybe will return to stock or some other AOSP rom), I use a different keyboard named "ai.type keyboard".

mgod commented 10 years ago

@AndroidDeveloperLB the keyboard is really nice from a user perspective, but this is the 3rd time I've run into an inscrutable bug that only appears on a subset of Samsung phones using the Samsung keyboard.

AndroidDeveloperLB commented 10 years ago

@mgod yes I understand.

mgod commented 8 years ago

As I think I did fix this in 1.2, I'm going to go ahead and close unless anyone can confirm they're still seeing the issue.

kaushal2406 commented 7 years ago

I am having same problem in Galaxy S6 with Android 7.1 with samsung keyboard, with other keyboard like swift it working perfect. I open issue https://github.com/splitwise/TokenAutoComplete/issues/308

Any One having solution for this weired problem. Please help me. My Email - kaushal2406@gmail.com