[GSoC] Add a search bar to the settings screen
Pull Request template
Purpose / Description
Describe the problem or feature and motivation
Fixes
Fixes #8342
Approach
- refactored some things to ease the search bar code
- Add SearchPreference library
- MIT licensed
- I've contacted the author to question about the lack of updates for ~1 year:
Hi, Nice to hear that you want to integrate my library. There is not much development going on because it just works. It is integrated into AntennaPod and K-9 Mail and I have not heard of crashes or bugs there, so there is no need to commit anything :) If I get critical bug reports, I do plan to fix the problems. ByteHamster
- edit: I had to send some PRs and they were accepted fairly quickly, so we can conclude that the mantainer is stil active
- Implement the search bar
- Add SearchPreferenceResultListener to the activty with the search bar
- Add the search bar to the fragment which will hold it (HeaderFragment)
- Configure the search index
- Index the preferences XMLs
- Ignore some preferences based on some conditions
- Index the preferences that are created programatically (i.e. are not on a XML)
- Set the resultClicked action
- Add a test
How Has This Been Tested?

https://user-images.githubusercontent.com/69634269/177347590-957c4c2b-3dd0-4821-b9b1-f04cb2c60444.mp4
Learning (optional, can help others)
Checklist
Please, go through these checks before submitting the PR.
- [X] You have not changed whitespace unnecessarily (it makes diffs hard to read)
- [X] You have a descriptive commit message with a short title (first line, max 50 chars).
- [X] Your code follows the style of the project (e.g. never omit braces in
ifstatements) - [X] You have commented your code, particularly in hard-to-understand areas
- [X] You have performed a self-review of your own code
- [X] UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
- [ ] UI Changes: You have tested your change using the Google Accessibility Scanner
ping @ankidroid/gsoc-mentor
I'm removing my approval: I don't feel the search is correct when I test it on my phone.
For example: the word "Hello" returns completely irrelevant results.
I'm removing my approval: I don't feel the search is correct when I test it on my phone.
For example: the word "Hello" returns completely irrelevant results.
FuzzySearch (an algorithm of the library to score results) is enabled by default. Disabled it.

FuzzySearch (an algorithm of the library to score results) is enabled by default. Disabled it.
Now it seems that with FuzzySearch disbaled, the library doesn't handle searches independently of uppercase/lowercase.
~~I should send a PR to fix it on their side later after I discover how I can test changes on a Android library.~~
https://github.com/ByteHamster/SearchPreference/pull/19
@BrayanDSO I saw you added "waiting for feedback". Can you clarify whose feedback you are waiting for? Usually we use it for feedback from the PR author, which I assume is not the case here. If it's from ByteHamster, I guess ew can remove the tag now that your PR is merged.
Can you clarify whose feedback you are waiting for?
As the label implies, from the author, which means myself.
I still have to do another PR on the library and then update the code here to conform with it.
~~Blocked by https://github.com/ByteHamster/SearchPreference/pull/21 and #11874. I'll do the necessary changes after those are in.~~
~~On top of/Blocked by #11934~~
@ankidroid/gsoc-mentor, ready for review again.
Looking at this again after some time gave me a fresher look of it.
I'll add a TODO for future myself to move the searchBar to the toolbar if I have time. As it will be in another PR, this is still ready for review.
Looking at this again after some time gave me a fresher look of it. I'll add a TODO for future myself to move the searchBar to the toolbar if I have time. As it will be in another PR, this is still ready for review.
Sorry for asking a re-review @david-allison. But I got excited from my above comment and had the time, so went full on it. I really love the new result. Only the last commit is new, so shouldn't be hard to review.
https://user-images.githubusercontent.com/69634269/183777943-455ead5c-6579-40e4-8bf4-3c9954d40b7d.mp4
I find way more useful having the search option everywhere, so I'll keep that
About the history, I'm removing because it currently only saves the last thing typed, so a lot of saved results are poor/incomplete
- e.g. I type "de", then open "Deck for new cards" and what is saved to the history is just "de"
And as far as I can tell, the history problem can only be fixed on upstream. I could do it, but currently it's a low priority for me and it can be done on any time in the future
I'm aware of the conflicts (as I've caused them, lol), but would like to solve them only after a second approval, since I'll continue to send another PRs that may conflict with this again and again and again
@BrayanDSO You have a ktlint issue with imports in HeaderFragment.
Thank you for the ping. Fixed it.
Hi there @BrayanDSO! This is the OpenCollective Notice for PRs merged from 2022-08-01 through 2022-08-31
If you are interested in compensation for this work, the process with details is here:
https://github.com/ankidroid/Anki-Android/wiki/OpenCollective-Payment-Process#how-to-get-paid
We only post one comment per person per month to avoid spamming you, regardless of the number of PRs merged, but this note applies to all PRs merged for this month
Please note that GSoC contributions are okay for this process. Our philosophy is that our users have donated to AnkiDroid for all contributions. The only PRs that will not go through the OpenCollective process are ones directly related to am accepted GSoC project from a selected participant, since those receive a stipend from GSoC itself.
Please understand that our monthly budget is never guaranteed to cover all claims - the cap on payments-per-person may be lower, but we try to make our process as fair and transparent as possible, we just need your understanding.
Thanks!