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

feat: Edit tags of a multiple notes / deck #8751

Merged
merged 13 commits into from
Nov 13, 2021

Conversation

TarekkMA
Copy link
Contributor

@TarekkMA TarekkMA commented May 2, 2021

Based on #8766

Pull Request template

Purpose / Description

The final PR of the TagsDialog refactoring series :D,

Fixes

Fixes #4911

Approach

Tags that are checked in all selected notes will appear as checked, if some notes have a tag but others don't then the tags are classified as indeterminate.

CheckBoxTriStates

A tristate checkbox (Like this one in flutter) was needed to display the 3 states the tag can be (checked, unchecked, indeterminate).

I added a cycleBackToIndeterminate property on the tristate checkbox, so if the user clicked on the checkbox it doesn't cycle back to an indeterminate state.

Used icons are the provided material ones in android studio

TagsUtil#getUpdatedTags

The code used to extract the updated tags from (prev, selected, indeterminate) lists.

TagsList

is now aware of the concept of indeterminate tags (updated all tested)

UpdateMultipleNotes

new task for updating multiple notes

How Has This Been Tested?

Unit tests

Checklist

  • You have not changed whitespace unnecessarily (it makes diffs hard to read)
  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • Your code follows the style of the project (e.g. never omit braces in if statements)
  • 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

@TarekkMA TarekkMA force-pushed the multi-tag-edit branch 5 times, most recently from 0ee0b30 to 8f09a28 Compare May 2, 2021 21:15
@TarekkMA TarekkMA marked this pull request as ready for review May 2, 2021 21:26
@TarekkMA TarekkMA marked this pull request as draft May 2, 2021 21:36
@TarekkMA TarekkMA marked this pull request as ready for review May 2, 2021 22:51
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 really like this, thanks!

@TarekkMA TarekkMA force-pushed the multi-tag-edit branch 3 times, most recently from 93bce3d to 2969f52 Compare May 3, 2021 13:18
boolean lhsChecked = isChecked(lhs);
boolean rhsChecked = isChecked(rhs);
boolean lhsChecked = isChecked(lhs) || isIndeterminate(lhs);
boolean rhsChecked = isChecked(rhs) || isIndeterminate(rhs);

if (lhsChecked != rhsChecked) {
// checked tags must appear first
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now indeterminate tags have the same priority as checked when sorting, should we make checked then indeterminate then unchecked?

@TarekkMA TarekkMA force-pushed the multi-tag-edit branch 5 times, most recently from dfeabe6 to 9e116bf Compare May 4, 2021 20:33
@TarekkMA
Copy link
Contributor Author

TarekkMA commented May 4, 2021

Added a test to test all tag variations are showing as expected.

@mikehardy
Copy link
Member

@TarekkMA looks like this needs re-basing as we're unwinding your stack of chained PRs - if you have a moment (and I understand it might be exam times for you! no pressure, it's not urgent) could you re-push this ?

@mikehardy mikehardy added the Needs Author Reply Waiting for a reply from the original author label Jun 27, 2021
@TarekkMA
Copy link
Contributor Author

I have just finished my exams, I will give this PR a look and repush.

@TarekkMA TarekkMA force-pushed the multi-tag-edit branch 2 times, most recently from f6ef727 to edcad4f Compare June 28, 2021 14:26
@mikehardy mikehardy added Needs Review and removed Needs Author Reply Waiting for a reply from the original author labels Jun 28, 2021
@mikehardy
Copy link
Member

@david-allison-1 what do you think on this one? The test cover is really good, and it's a feature that is highly requested. I'd like to merge this to rescue it from entropy and deliver a great feature

@david-allison
Copy link
Member

@david-allison-1 what do you think on this one? The test cover is really good, and it's a feature that is highly requested. I'd like to merge this to rescue it from entropy and deliver a great feature

Can this wait until Sunday? I don't have the free time to give this an appropriate amount of review or testing. Ping me if I don't look at this by Monday

@david-allison david-allison self-assigned this Nov 5, 2021
@mikehardy
Copy link
Member

@david-allison-1 what do you think on this one? The test cover is really good, and it's a feature that is highly requested. I'd like to merge this to rescue it from entropy and deliver a great feature

Can this wait until Sunday? I don't have the free time to give this an appropriate amount of review or testing. Ping me if I don't look at this by Monday

Oh sure! Not a rush per se, just a statement of intention that I'd like it to not rot

this will be used to get updated tags in case there are indeterminate tags
onSelectedTags now returns list of `indeterminateTags`, the indeterminateTags should be ignored if not needed.
this should have no effect on normal call with only checked tags
based on TagsDialogListenerAction the listener callback will do different things

for now the only action doable is FILTER action
now the name and comment reflects the meaning of the tags

since we can add/remove tags from multiple notes using this dialog type
Select multiple cards and change the tags of their notes
@mikehardy
Copy link
Member

I just rescued it from conflict again and re-pushed

Can this wait until Sunday? I don't have the free time to give this an appropriate amount of review or testing. Ping me if I don't look at this by Monday

Gentle nudge :-)

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.

Tested and this looks good

Arrays.asList("aA", "bb", "cc", "dd", "ff"), list.copyOfAllTagList());
assertEquals("Checked tags list should not contain any duplicates (case insensitive)",
Arrays.asList("ff"), list.copyOfCheckedTagList());
assertEquals("Checked tags list should not contain any duplicates (case insensitive)\n" +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems logically correct, but it's handled by the above assert

@mikehardy
Copy link
Member

Okay, deep breath, here we go

@mikehardy mikehardy merged commit f6525c2 into ankidroid:master Nov 13, 2021
@mikehardy mikehardy removed Review High Priority Request for high priority review Needs Second Approval Has one approval, one more approval to merge labels Nov 13, 2021
@mikehardy mikehardy added this to the 2.16 release milestone Nov 13, 2021
@mikehardy
Copy link
Member

Hi there! November OpenCollective Notice

Apologies for the delay, and if you're already submitted something to OpenCollective for PRs merged in November 2021, you may feel free to ignore this and it will be processed shortly

Just a friendly notice that we try to process OpenCollective payments monthly - it's time for November 2021 submissions

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

(I only post one comment per person to avoid spamming you, regardless of the number of PRs merged, but this note applies to all PRs merged for in the month of August)

Thanks!

@mikehardy
Copy link
Member

@TarekkMA !!! We finally landed this one ❤️

@TarekkMA
Copy link
Contributor Author

This is awesome, thank you guys for your reviews and guidance.
Very proud to be a contributor to AnkiDroid ❤️.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding tags to deck/multiple notes
3 participants