Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

lukstbit
Copy link
Member

@lukstbit lukstbit commented Nov 4, 2024

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:

  • I find it confusing to have a chip checked and its text to read "No flag"
  • while for single flag selection having the name makes sense, this loses its advantage when you also have +x because you don't have any info about the other flags so you're forced to open the sheet again anyway
  • makes it easier to keep all filtering chips on screen. If we have a longer tag name + flag name it's easy to push the last filtering chip(state) outside of the screen
  • would have a more consistent UI if all chip filtering would use the same system: Tags +2 Flags +2 Card state +2

Some images:

Fixes

How Has This Been Tested?

Ran the tests and filtered by flag.

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • 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

Copy link
Contributor

github-actions bot commented Nov 4, 2024

Important

Maintainers: This PR contains Strings changes

  1. Sync Translations before merging this PR and wait for the action to complete
  2. Review and merge the auto-generated PR in order to sync all user-submitted translations
  3. Sync Translations again and merge the PR so the huge automated string changes caused by merging this PR are by themselves and easy to review

@lukstbit
Copy link
Member Author

lukstbit commented Dec 8, 2024

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.
I also thought of an addition to chip filtering area that I think it would be nice but I'll propose that change after these two are done.

@lukstbit lukstbit added this to the 2.21 release milestone Dec 8, 2024
Copy link
Member

@david-allison david-allison left a 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

Comment on lines 25 to 31
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
Copy link
Member

@david-allison david-allison Dec 8, 2024

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

Copy link
Member Author

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).

AnkiDroid/src/main/res/layout/item_browser_flag_filter.xml Outdated Show resolved Hide resolved
Comment on lines +96 to +100
<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>
Copy link
Member

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

Copy link
Member Author

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
Copy link
Member

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?

Copy link
Member Author

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.

@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label Dec 9, 2024

This comment has been minimized.

@david-allison
Copy link
Member

@lukstbit is this still awaiting comment resolution, and can I help at all? Would love to see it in

oakkitten and others added 5 commits December 24, 2024 15:07
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.
@lukstbit lukstbit force-pushed the feat_browserChipFiltering branch from e34147f to 00c8f0e Compare December 24, 2024 13:11
@lukstbit
Copy link
Member Author

Sorry, I was just busy and didn't had time to update the code.

@lukstbit lukstbit removed the Needs Author Reply Waiting for a reply from the original author label Jan 2, 2025
@david-allison david-allison added Needs Author Reply Waiting for a reply from the original author and removed Needs Author Reply Waiting for a reply from the original author labels Jan 4, 2025
Copy link
Member

@david-allison david-allison left a 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

⚠️ Filter by flag in the menu does nothing + can be removed


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

@david-allison david-allison added Needs Author Reply Waiting for a reply from the original author Review High Priority Request for high priority review labels Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Has Conflicts Needs Author Reply Waiting for a reply from the original author Needs Review Review High Priority Request for high priority review Strings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants