Anki-Android icon indicating copy to clipboard operation
Anki-Android copied to clipboard

Delete tags

Open javiercl2020 opened this issue 3 years ago β€’ 37 comments

It would be useful if you can delete tags having an option or button I know that the only way to do that is selecting the cards or notes and change the tag for a different one and after that check the database. But it would be quicker with an option

javiercl2020 avatar Feb 25 '22 00:02 javiercl2020

This is one of the least intuitive parts of the app, in my opinion. I agree with you. May I ask, @javiercl2020 - how does AnkiDesktop (and/or AnkiMobile - the iOS app) handle it now?

mikehardy avatar Feb 25 '22 13:02 mikehardy

I don't have the ios app I didn't find the way to delete tags using Anki desktop tomorrow I will try again

javiercl2020 avatar Feb 27 '22 05:02 javiercl2020

The way I deleted tags in Anki desktop is:

  1. Go to browse
  2. In the sidebar filter you will see Tags
  3. Right click on the tag you want to delete and you will get an option to do so

image

viciousAegis avatar Feb 27 '22 07:02 viciousAegis

Neat - thanks @viciousAegis - so I assume (untested, please correct if I'm wrong) that it will first find all cards that have the tag, remove the tag from them cards, then check database? Or perhaps newer versions of anki desktop have this as a real method in the library (which we reuse via Anki-Android-Backend...) such that it is clean+easy. Those are further question where the answers would inform future work - checking the Desktop code to see how exactly it's implemented, as a next step

mikehardy avatar Feb 27 '22 21:02 mikehardy

It will be when we update our backend to the latest version, best to focus on schema 16 before introducing more breaking changes.

https://github.com/ankitects/anki/blob/main/proto/anki/tags.proto

david-allison avatar Feb 27 '22 21:02 david-allison

got it - thanks!

mikehardy avatar Feb 27 '22 21:02 mikehardy

Hello πŸ‘‹, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically

github-actions[bot] avatar Apr 28 '22 22:04 github-actions[bot]

Hello πŸ‘‹, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically

github-actions[bot] avatar Jun 27 '22 23:06 github-actions[bot]

We are really really close to having the backend updated with #11644 at which point this does become much easier.

mikehardy avatar Jun 27 '22 23:06 mikehardy

Just requires exposing col.newBackend.backend.removeTags()

dae avatar Jul 18 '22 06:07 dae

Hello πŸ‘‹, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically

github-actions[bot] avatar Nov 11 '22 19:11 github-actions[bot]

Too easy not to keep open as a feature request

mikehardy avatar Dec 20 '22 16:12 mikehardy

I wanna work on this issue, where should I start with?

Sagar0-0 avatar Dec 21 '22 05:12 Sagar0-0

@Sagar0-0 find any code (via search) that is conditional on legacy backend, use git blame to find the commits that added or changed the legacy backend conditional, and examine the related PRs to see how code for the new backend works. Second, find any menu items that are added dynamically in the deck list and do the same

mikehardy avatar Dec 21 '22 14:12 mikehardy

Ok getting started now

Sagar0-0 avatar Dec 21 '22 14:12 Sagar0-0

Found 3 usage in Storage. While using git blame in this file I found that particular commit "Use Rust backend for database queries". How to find the corresponding PR? and is this even the right thing I am doing?

Sagar0-0 avatar Dec 22 '22 16:12 Sagar0-0

I think that's the method in Anki Desktop which removes the tags(from the list awa notes)

Sagar0-0 avatar Dec 27 '22 11:12 Sagar0-0

There are some brief instructions on https://github.com/ankidroid/Anki-Android/issues/11882 if you haven't already read them.

dae avatar Dec 27 '22 11:12 dae

Well, I found that same method in proto also , and now do I have to add some new function in CollectionV16 and TagsV16 classes that call the associated backend function to remove the tag?

Sagar0-0 avatar Dec 27 '22 12:12 Sagar0-0

Any update here?

Sagar0-0 avatar Jan 16 '23 18:01 Sagar0-0

Yes, that is correct.

dae avatar Jan 18 '23 04:01 dae

I think first I have to try anki desktop also and see how it behaves with new tags and older tags.

Sagar0-0 avatar Jan 18 '23 05:01 Sagar0-0

@Sagar0-0 there is already a comment above showing how it works on Anki Desktop.

The task here is maybe going to be difficult because there is no spot really where the tags are editable and I'm not sure where that would even fit in the UI πŸ€” .

There is a tag browser component which may be reusable - it is visible in the card browser if you filter by tag, but there is no long-press ability there. Perhaps the easiest thing just to get this hooked up is to respond to a long-press on a tag in that existing tag filter popup to make yet another popup that gives you options for the tag. Just one option right now for delete, and make it all connect to the backend function and work.

Once it is actually working at all - even if the UX is not great - a follow-on step could be to add a "tag browser" option in the menu for card browser, and in there show the tag widget (which now allows for delete on long-press...) and start adding more features like rename etc.

But just start - maybe if you investigate and it looks doable - by listening for long-press on the existing tag component and make delete work ?

mikehardy avatar Jan 18 '23 17:01 mikehardy

aye aye captain

Sagar0-0 avatar Jan 18 '23 17:01 Sagar0-0

I did it! Trying to add a workable UI now! I also know the backend proto method that is required but I am not aware about abstraction layers that have to be added on different levels. After searching I got that first I have to add the methods in CollectionsV16 and TagsV16 but gotta stress more to understand the abstraction level for working with these classes. Any helpful tips here?

Sagar0-0 avatar Jan 19 '23 04:01 Sagar0-0

On long press I am showing a dialog(similar to Help and Support Android dialog) with currently a single option of Delete tag(later we can also add rename).

Sagar0-0 avatar Jan 19 '23 08:01 Sagar0-0

image LGTM, clean and simple😌. P.s. It also persist config changes. If I have to also set a title here, then what it should be?

Sagar0-0 avatar Jan 19 '23 09:01 Sagar0-0

If I have to also set a title here, then what it should be?

The tag name

BrayanDSO avatar Jan 19 '23 15:01 BrayanDSO

done

Sagar0-0 avatar Jan 19 '23 17:01 Sagar0-0

Progress report

  1. Added Dialog to onLongPressListener on Tag (also persist config change).
  2. Dialog contains the Title(as tag name) and option to delete.
  3. Added a delete method in TagsList class that returns boolean (One liner function bcz we are calling UniqueArrayList remove method [this is working and not working, I think that is because it restores the tags everytime as we are not removing them properly]).
  4. On choosing delete option of dialog we call the corresponding delete method of TagsList
  5. We create a MaterialDialog snackbar withe the appropriate feedback message, whether tag is deleted or not.
  6. Call notifyDataSetChanged and sortData methods of TagsArrayAdapter
  7. Added a function inTagsV16 that calls the removetags function of backend.

Need help in

  1. I think(not sure) I have to add delete fxn in UniqueArrayList and call that from tagslist class.
  2. Don't know(abstraction layers)how to reach TagsV16 and call the delete function from UniqueArrayList class.
  3. What is this OpChangesWithCount and do this thing have any uses?
  4. It is good to also add delete abstract method in TagsManager as it is the parent of TagsV16.
  5. Do I also have to make changes in the docstrings side by side?

Sagar0-0 avatar Jan 20 '23 16:01 Sagar0-0