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

Enhancement: allow renaming flag from CardBrowser menu #16244

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

criticalAY
Copy link
Contributor

@criticalAY criticalAY commented Apr 22, 2024

Purpose / Description

  • Support renaming flags #16205, Anki allows flag to be renamed from card browser so replicating that this PR provides a menu option through which we can rename the flag and after sync the same is reflected in Anki desktop

Fixes

How Has This Been Tested?

image

AnkiDroid: (orange flag)
Screenshot 2024-04-22 144750

Anki after sync:
image

Checklist

Please, go through these checks before submitting the PR.

  • 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

Message to maintainers, this PR contains strings changes.

  1. Before merging this PR, it is best to run the "Sync Translations" GitHub action, then make and merge a PR from the i18n_sync branch to get translations cleaned out.
  2. Then merge this PR, and immediately do another translation PR so the huge change made by this PR's key changes are all by themselves.

Read more about updating strings on the wiki,

@criticalAY
Copy link
Contributor Author

criticalAY commented Apr 22, 2024

I have placed the rename option in menu for now, reason too many steps would be required in that case
Menu -> Options dialog -> Rename flag -> One more dialog consisting of the list of flag -> flag clicked -> another rename dialog

We can place the rename option just above the Options maybe?

Copy link
Contributor

@lukstbit lukstbit left a comment

Choose a reason for hiding this comment

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

I have placed the rename option in menu for now, reason too many steps would be required in that case
Menu -> Options dialog -> Rename flag -> One more dialog consisting of the list of flag -> flag clicked -> another rename dialog

Again, this is not an option that will be used by many users and even those that are going to use it are going to use it a few times. There's no justification to have this option cluttering the menu for everyone for such small/specific usage.

Menu -> Options dialog -> Rename flag -> One dialog

That dialog can both display the flags with their current name and an option to edit them inline. For example, for a flag entry, initially show a TextView + Button to rename(maybe also the flag icon so it's more clear). When the rename button is clicked replace the TextView + Button with an EditText + 2 Buttons(1 for accept and 1 for cancel the new name). This way the user both sees the current names + has the option to edit all of them in the same dialog.

@lukstbit lukstbit added the Needs Author Reply Waiting for a reply from the original author label Apr 22, 2024
@criticalAY
Copy link
Contributor Author

image

image

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.

Anki Desktop does not allow 'No Flag' to be renamed

@criticalAY
Copy link
Contributor Author

image
image
image

Copy link
Contributor

Hello 👋, this PR has had no activity for more than 2 weeks and needs a reply from the author. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically

@github-actions github-actions bot added the Stale label May 13, 2024
@criticalAY criticalAY added Keep Open avoids the stale bot Blocked by dependency Currently blocked by some other dependent / related change and removed Stale labels May 20, 2024
@david-allison david-allison removed the Blocked by dependency Currently blocked by some other dependent / related change label Jun 3, 2024
Done in the Card Browser options

Fixes 16205
@david-allison david-allison added Needs Review and removed Needs Author Reply Waiting for a reply from the original author Keep Open avoids the stale bot Has Conflicts labels Jun 3, 2024
@david-allison david-allison dismissed their stale review June 3, 2024 21:51

I've taken on this PR

override fun onResume() {
super.onResume()
(dialog as AlertDialog).positiveButton.setOnClickListener {
// TODO: Extract pending changes from the adapter and save them
Copy link
Member

Choose a reason for hiding this comment

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

Specifically: I'm being lazy here

I didn't like the fact that pressing 'OK' closed the dialog

But don't have the capacity to extract the logic from the ViewHolder, or handle the FlagItem matching the state of the adapter's edit mode (.copy() is used, changing references)

I feel this is an acceptable compromise. Needs new dev if I'm being too lazy

val pendingChanges = flagAdapter.currentList.filter { it.isInEditMode }
if (pendingChanges.any()) {
Timber.i("Attempted to close with %d pending changes", pendingChanges.size)
showThemedToast(R.string.confirm_before_saving, true)
Copy link
Member

Choose a reason for hiding this comment

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

I'm hoping this is temporary code, so not putting effort into getting the snackbar working inside the dialog

@david-allison david-allison added this to the 2.19 release milestone Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support renaming flags
3 participants