Deals with multi part filters#20308
Open
Arthur-Milchior wants to merge 1 commit intoankidroid:mainfrom
Open
Conversation
e502be1 to
48b187a
Compare
Contributor
There was a problem hiding this comment.
Not sure if this is intended but maybe the copyright header is wrong
Member
Author
There was a problem hiding this comment.
Oops, probably a copy past. Nice catch
Anki deck search features allows to enter multiple part of the filter. For example "math catego" allows to find the deck "category" as a subdeck of "math", and exclude "category" in any deck that don't also contains the word "math". The same search on ankidroid would only return a deck whose name contains "math catego" literally. Also, a search for "h::cat" won't show the deck math::category as ankidroid search for the string in the name of the deck not considering the parents. This commit tries to be as close as possible to anki behaviour. However, anki deck selection uses a submenu that is very different from ankidroid filtering process. So this commit tries to keep the logic of ankidroid filtering process by ensuring that if we search for "math::alge" we still shows "math::algebra" without showing "math::algebra::group" in the deck picker. A last complexity was that, when the user tap "math:", we don't want to remove the deck "math" from the search result (as it'll reappear as soon as the user has tapped "math::a", since "math" is a parent of "math::algebra" and that we show parents of shown decks). So the search feature considers in this case that "math:" can be either a part of a name of a deck, or that "math" can be the suffix of a deck's parent name. A bunch of unit tests was added to help understand the behavior of the search feature in mulitple cases. Some CharSequence were replaced by DeckFilters so that each use of the filter against a name does not require to trim and lower case the filter again. This also allows to have all the (honestly absurdly complex given the implemented behaviour) logic of the code in a class. Fixes: ankidroid#20306
48b187a to
ffc4d55
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Anki deck search features allows to enter multiple part of the filter. For example "math catego" allows to find the deck "category" as a subdeck of "math", and exclude "category" in any deck that don't also contains the word "math".
The same search on ankidroid would only return a deck whose name contains "math catego" literally.
Also, a search for "h::cat" won't show the deck math::category as ankidroid search for the string in the name of the deck not considering the parents.
This commit tries to be as close as possible to anki behaviour. However, anki deck selection uses a submenu that is very different from ankidroid filtering process. So this commit tries to keep the logic of ankidroid filtering process by ensuring that if we search for "math::alge" we still shows "math::algebra" without showing "math::algebra::group" in the deck picker.
A last complexity was that, when the user tap "math:", we don't want to remove the deck "math" from the search result (as it'll reappear as soon as the user has tapped "math::a", since "math" is a parent of "math::algebra" and that we show parents of shown decks). So the search feature considers in this case that "math:" can be either a part of a name of a deck, or that "math" can be the suffix of a deck's parent name.
A bunch of unit tests was added to help understand the behavior of the search feature in mulitple cases.
Fixes: #20306