splitwise / TokenAutoComplete

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

Add `prefixEnabled` property to allow the prefix to be disabled #415

Open scottyab opened 3 years ago

scottyab commented 3 years ago

I ran in a weird bug with TokenCompleteTextView.onRestoreInstanceState() and so ended up not wanting to use the restored objects in onRestoreInstanceState (we have the state in our viewmodel. However the even though I'm not using the prefix the setPrefix() in onRestoreInstanceState() the would clear the tokens I had already set in the TokenCompleteTextView in my activities onCreate(). Specifically when it called setText().

To resolve I've added the prefixEnabled property. This allows callers to disable the prefix behaviour and solve the issue I was seeing. However, there maybe an alternate way to solve this that doesn't involve and extra property. Open to suggestions.

Also, apologies for the additional formatting changes it seems my code formatter got carried away. I can correct this if there's approval for this PR to the merged.