splitwise/TokenAutoComplete

Planning next version

mgod opened this issue ยท 16 comments

mgod commented

Hi everyone!

It's been a while since I've done significant work on this project and there are a number of bugs that have cropped up (#253, #242, #241, #238, #237, #228, #226, #220, #193, #184, #183, #172, #132, #95) that will require a lot of reworking. There are also some use cases I hadn't considered during my initial design that don't work well with the current structure. I'd also like to simplify and automate the testing process.

Part of this is that I'll be removing a lot of features and reducing the public interface of the class as much as possible. To help me figure out what I should keep and do better planning out improvements, please comment and let me know how you're using it. Here's the template I'd like to see. Please copy and paste this into a comment and complete it. See my example below.

### My use case (a few sentences describing it)

### Settings (choose the correct one in each [], first option is the default)

 - setDeletionStyle([Clear, PartialCompletion, ToString])
 - setTokenClickStyle([None, Delete, Select, SelectDeselect])
 - allowDuplicates([true, false])
 - performBestGuess([true, false])
 - allowCollapse([true, false])

### API (delete all functions you do not use directly)

 - setPrefix()
 - setSplitChar()
 - setTokenLimit()
 - setTokenizer()
 - setTokenListener()
 - getObjects()
 - addListeners()
 - removeListeners()
 - clearCompletionText()
 - currentCompletionText()
 - performCompletion()
 - performCollapse()
 - addObject()
 - removeObject()
 - clear()

### Behavior overrides (delete all functions you do not override)

 - performFiltering()
 - isTokenRemovable()
 - maxTextWidth()
 - enoughToFilter()
 - buildSpanForObject()
 - replaceText()
 - getSerializableObjects()
 - convertSerializableArrayToObjectArray()
 - canDeleteSelection()

### Workarounds (any customization that is likely to break if I stop subclassing MultiAutoCompleteTextView)


### Feature requests (anything you currently do that the library could do for you)
mgod commented

My use case (a few sentences describing it)

We use the library to allow the user to select a list of people when creating an expense. We load data from the the Android contacts provider and a local database of existing Splitwise friends.

Settings (choose the correct one in each [], first option is the default)

  • setDeletionStyle(Clear)
  • setTokenClickStyle(Select)
  • allowDuplicates(true)
  • performBestGuess(true)
  • allowCollapse(true)

API (delete all functions you do not use directly)

  • setPrefix()
  • setTokenListener()
  • getObjects()
  • currentCompletionText()
  • addObject()
  • removeObject()

Behavior overrides (delete all functions you do not override)

  • getSerializableObjects()
  • convertSerializableArrayToObjectArray()

Workarounds (any customization that is likely to break if I stop subclassing MultiAutoCompleteTextView)

  1. We make the drop down appear the first time the view is visible even if there's no completion text.
  2. We add a text watcher the updates a separate view with the currentCompletionText() when the user types.

Feature requests (anything you currently do that the library could do for you)

  1. I'd like it if the library let me style more of the view in the XML layout instead of in code
  2. Update the styles in the view to more closely match MD guidelines and use AppCompat views.

My use case

We use the library to allow the user to add hashtags to show their interests, and also select a list of people when sending them SMS messages. We load data from the API to pull suggested hashtags, and for SMS , from the Android contacts provider

Settings

setDeletionStyle(Clear)
setTokenClickStyle(None)
allowDuplicates(false)
performBestGuess(false)
allowCollapse(false)

API

setTokenListener()
getObjects()
addObject()
removeObject()

mgod commented

@raylee4204 Thanks for the feedback! When you're getting the hashtags, is it just a list of hashtags or do you let the user enter other text as well like a Tweet editor?

@mgod I do accept regular texts along with hashtags.

My use case :

I use TokenAutoComplete to autocomplete a list of areas in my app using my own adapter that fetches the data from the server
Thank you for your contribution

Settings (choose the correct one in each [], first option is the default)

  • setDeletionStyle([Clear])
  • setTokenClickStyle([ Select])
  • allowDuplicates([false])
  • performBestGuess([true])
  • allowCollapse([false])

API (delete all functions you do not use directly)

  • setAdapter
  • setSplitChar()
  • setTokenListener()
  • getObjects()
  • addListeners()
  • removeListeners()
  • clearCompletionText()
  • addObject()
  • removeObject()
  • clear()

Behavior overrides (delete all functions you do not override)

Workarounds (any customization that is likely to break if I stop subclassing MultiAutoCompleteTextView)

I am using our own class to create the tokens and swop the images to make it clear that they need to click to select and then delete

Feature requests (anything you currently do that the library could do for you

I would like to add a remove image to the token and add an onclick to the image so that they can remove the token with 1 click
setTokenClickStyle() - > remove image

mgod commented

@biovolt Just to clarify for me, by "add a remove image" to the token, do you mean adding a separate area of the token that you can style that responds to selections differently than the main token body? I've been pretty hesitant to allow sub-token clicking both because it's hard and it feels like most tokens should be small enough that having separate click areas would be confusing for the user. I had intended TokenClickStyle.Delete for cases where you want to 1-click delete tokens as that felt like the more usable choice to me.

mgod commented

I've just deleted some comments because this isn't a help thread. If you're not commenting about what features you currently use in the library, please look for a different thread to post in or create a new one. I usually respond fairly quickly to new issues unless they 1) are the same as an existing open issue (though I try to point to the current issue in this case) or 2) do not provide enough context for me to understand what's being asekd.

When will be released the new version?

mgod commented

I don't have a timeline for the next version. There is a 3.0.0-alpha version you can get with implementation 'com.splitwise:tokenautocomplete:3.0.0-alpha@aar' in your gradle dependencies, but I'm not quite done changing the interfaces I'm updating and there's no migration guide yet.

Thanks,

This is a must have library

mgod commented

There's a version 3.0.0-alpha2 available now. I don't expect the public interface to change at this point, but I'm still ironing out some edge case bugs.

Where's the .allowDuplicates(false) function?

mgod commented

I'll hopefully get a migration guide together soon, but

setAllowDuplicates(false)

is now (in your TokenCompleteTextView subclass):

@Override
public boolean shouldIgnoreToken(T token) {
    return getObjects().contains(token);
}

with the correct substitution for T.

Existing Bug
If i add more than 100 email id's and performCollapse, the control gets stuck, it take a long time (more than 10 secs) to collapse.

My use case :
I use TokenAutoComplete to autocomplete a list of email id's copied from another source.

Feature requests:
I would like to have a paste option for bulk insertion at once. There should be addObjects() method to list of tokens.

mgod commented

3.0.0 is available now and the docs should be up to date. I believe I've addressed most of the requests here (please let me know how the free form text support works for you if you need it!).

I've not added paste or bulk insert support. There's some ground work in place to make paste more reasonable to implement and addObjectSync should be much less resource intensive in a loop than the current addObject code.

I'm also not planning to support handling clicks on different pieces of the tokens. It's clear from looking at the underpinnings of the text layout that this problem is beyond the scope of what I can support in the library.