-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add card browser chip filtering for flags #17355
base: main
Are you sure you want to change the base?
Conversation
Important Maintainers: This PR contains Strings changes
|
fa1f5c9
to
e34147f
Compare
I fixed the conflicts for this. Note: I also did the filtering for card states but I didn't add the PR yet because it sits on top of this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clicking on the flag icons has no effect other than a ripple
Also for the X in the 'clear filter'
Clear filter should allow a user to click anywhere in the row, as with the flag icons, rather than just the text
Other than that, THANK YOU SO MUCH! Looks great
val userInput: String, | ||
val deckIds: Set<DeckId>, | ||
val tags: Set<String>, | ||
val flags: Set<Flag> | ||
) : Parcelable { | ||
val isEmpty get() = userInput.isEmpty() && deckIds.isEmpty() && tags.isEmpty() && flags.isEmpty() | ||
val isNotEmpty get() = !isEmpty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like too many parameters, is tags
necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we plan to add a chip for filtering by tags(or so it was done in your original PR).
<string name="chip_filter_multiple_selections" comment="Arg 1: Selected filter ('Red Flag') | ||
Arg 2: Number of additional selected filters (2: Green and Blue Flags) | ||
Example shown to use: 'Red +2' | ||
When displaying a chip control for a filter, if one element is selected, we display it | ||
If more than one element is selected, we also show the count of extra filters">%1$s +%2$d</string> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this needs to be a plural, but I'm not certain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand. This string can't be a plural because the quantity is represented by numeric values.
@@ -41,7 +41,6 @@ import com.ichi2.anki.model.SortType.EASE | |||
import com.ichi2.anki.model.SortType.NO_SORTING | |||
import com.ichi2.anki.model.SortType.SORT_FIELD | |||
import com.ichi2.anki.servicelayer.NoteService | |||
import com.ichi2.anki.setFlagFilterSync | |||
import com.ichi2.anki.utils.ext.ifNotZero |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want additional test coverage here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you have in mind? Extra tests for the flag filtering itself or for the code that was introduced to support filtering(SearchParameters)?
Note: this is the original code from the first attempt, I didn't modified it in any way.
This comment has been minimized.
This comment has been minimized.
@lukstbit is this still awaiting comment resolution, and can I help at all? Would love to see it in |
TODO: Thank Oakkitten for the code Cherry-picked from ankidroid#16859, commit 2b89111 There was a conflict related to imports in card browser that was fixed.
This fixes the bug ankidroid@2b89111#r1731116500 where using a top level deck id in the search query will result in an empty result set although its child decks do have cards. The fix consists in properly creating the search query by switching from "did" to "deck" for deck selection(ex did:435435 -> deck:"Deck name"). Looking though the docs, it seems "did" isn't a valid selector for a deck and the selector "deck" must be used instead. Note that the deck name is put in "" to accommodate decks with spaces in name. Note: I choose to make toQuery() suspended to access the collection for the decks names to avoid SearchParameters referencing the decks names and then having to synchronize with outside name changes.
Cherry-picked from ankidroid#16859, commit 6565924 + other changes Other changes: - renamed bottom_sheet_item -> item_browser_flag_filter - refactor item_browser_flag_filter to simplify and remove unused views - removed the BottomSheetFragment, TreeAdapter and TemplatedTreeAdapter classes as they will not be used for flags filtering - removed bg_input.xml and bottom_sheet_list_without_filter.xml as they are unused - removed the chip for flags filtering, it will be added in a separate commit - moved BottomSheetDialogFragmentFix to the anki.workarounds package, I assumed we might want this in other places as well - renamed the id of the ChipGroup from chips_group to filtering_chips_group
Code partially cherry-picked from ankidroid#16859, commit 4254250 References to flags filtering were removed and will(partially) be added in the next commit. The code works now as before related to flags filtering.
The flags filtering was moved from a menu option to an embedded chip view triggering a separate bottom sheet dialog. Contains some code from commit 4254250 that was about flags filtering. Note: see the changes in CardBrowserTest.checkIfLongSelectChecksAllCardsInBetween(). For some reason after adding the tests related to flag filtering, this test started to throw NullPointerExceptions which also triggered another test to crash as well due to unhandled exception from another test. Using a position that should be displayed seems to fix this.
e34147f
to
00c8f0e
Compare
Sorry, I was just busy and didn't had time to update the code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm so sorry, didn't realize this was open for review! This is great, one blocker
design nitpicks, non-blocking
- If 'clear' is not visible, the top of the sheet could do with a few more dp blank space
- Could do with a few dp padding to the end of the flag icon
- I /think/ the font may be a little larger/bolder than gmail and could be reduced by a few dp
Purpose / Description
Adds a part of the CardBrowser new chip filtering, targeting flags. The PR uses code from the original attempt at #16859 where possible. See more info in the messages of commits.
UI note: I think it would be better if we just show Flags +x instead of FlagName +1:
Some images:
Fixes
How Has This Been Tested?
Ran the tests and filtered by flag.
Checklist