Skip to content

Improve the review forgotten cards dialog#20620

Closed
nourhanbakry wants to merge 2 commits intoankidroid:mainfrom
nourhanbakry:Improve-the-Review-forgotten-cards-dialog
Closed

Improve the review forgotten cards dialog#20620
nourhanbakry wants to merge 2 commits intoankidroid:mainfrom
nourhanbakry:Improve-the-Review-forgotten-cards-dialog

Conversation

@nourhanbakry
Copy link
Copy Markdown
Contributor

Purpose / Description

Improve the "Review forgotten cards" dialog.

The current dialog has multiple UX issues:

  • unclear title
  • unnecessary text like "x days" in description
  • no unit shown in input field
  • generic "OK" button label
  • no inline validation feedback
  • shows error dialog instead of inline warning when no cards match

This creates confusion and breaks consistency with other dialogs.

Fixes

Approach

The dialog UI and behavior were updated to match the expected UX:

  • added a clear title "Review forgotten cards"
  • removed redundant "x days" text from description
  • added dynamic unit suffix "day/days" to the input field using getQuantityString
  • changed positive button text from "OK" to "Create"

Validation improvements:

  • prevented leading zeros using InputFilter
  • limited input length
  • disabled button when input is invalid or zero
  • added inline error messages instead of showing a dialog

Dynamic validation:

  • on each input change, a background check runs using hasMatchingCards
  • if no cards match the criteria:
    • show error message "No cards matched the criteria"
    • disable the button
  • if valid:
    • clear error
    • enable button

This ensures immediate feedback without interrupting the user flow.

How Has This Been Tested?

Tested manually with the following setup:

  • Device: Pixel 8 emulator
  • API Level: 36
  • Build Variant: playDebug
Screen.Recording.2026-03-29.at.2.30.25.AM.mov

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

@github-actions
Copy link
Copy Markdown
Contributor

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

@david-allison
Copy link
Copy Markdown
Member

Failing lint

https://github.com/ankidroid/Anki-Android/tree/main/.github/workflows#quality-checks

@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label Mar 29, 2026
@Galal-20
Copy link
Copy Markdown
Contributor

Hello @nourhanbakry
If the resource ("Invalid number") is really not needed, remove it.

@nourhanbakry
Copy link
Copy Markdown
Contributor Author

Hello @nourhanbakry If the resource ("Invalid number") is really not needed, remove it.

Thanks for your comment, I fixed it

Comment thread AnkiDroid/src/main/java/com/ichi2/anki/dialogs/customstudy/CustomStudyDialog.kt Outdated
@david-allison david-allison removed the Needs Author Reply Waiting for a reply from the original author label Mar 30, 2026
Copy link
Copy Markdown
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.

This is taking on too much, please fix the commit structure via rebase + force push so individual changes are reviewable as separate commits or split out maybe 2 smaller PRs so they're reviewable

This feels AI-genned, could I confirm it's not? The use of bare strings, where your previews PRs contained R.string seemed unusual

https://github.com/ankidroid/Anki-Android/blob/main/AI_POLICY.md

@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label Mar 30, 2026
- Fixed translation issues
- Updated multiple string resources
- Applied lint fixes
@nourhanbakry
Copy link
Copy Markdown
Contributor Author

This is taking on too much, please fix the commit structure via rebase + force push so individual changes are reviewable as separate commits or split out maybe 2 smaller PRs so they're reviewable

This feels AI-genned, could I confirm it's not? The use of bare strings, where your previews PRs contained R.string seemed unusual

https://github.com/ankidroid/Anki-Android/blob/main/AI_POLICY.md

Thank you for the feedback.

Regarding the commit structure, I apologize for the clutter. I will work on rebasing the branch to clean up the history and ensure each commit represents a logical, reviewable change.

As for the strings, I assure you this is not AI-generated. I used bare strings temporarily during development and intended to move them to R.string before finalizing, but I clearly missed that step. I will fix them to use string resources as per the project standards.

I’ll ping you again once the rebase and the fixes are pushed. Thanks for your patience!

@david-allison david-allison marked this pull request as draft April 5, 2026 13:21
@david-allison
Copy link
Copy Markdown
Member

Cheers! Please un-draft when it's ready for review

@nourhanbakry nourhanbakry force-pushed the Improve-the-Review-forgotten-cards-dialog branch from 67127a8 to ec8eca1 Compare April 5, 2026 21:22
@nourhanbakry nourhanbakry marked this pull request as ready for review April 5, 2026 23:18
@nourhanbakry
Copy link
Copy Markdown
Contributor Author

Cheers! Please un-draft when it's ready for review

Thank you, it's open now could you please take a look?

withCol {
val currentDeckName = decks.name(viewModel.deckId)

val hasForgottenCards =
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What's the source of this code?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Galal-20 This looks very similar to your code:

https://github.com/ankidroid/Anki-Android/pull/20618/changes#diff-db6bbcabbd676cdc4c30bd6ff19fe6371503423f866743aeb5ec4cdab543a243R517

What's going on?

Thanks for pointing this out.

Yes, after reviewing the code, the implementations look very similar.

But I would like to clarify something important:
this was written independently from my perspective in my PR, based on Anki’s search (e.g., deck filtering, prop:due queries, filtering, numeric input validation, handling leading zeros, and basic UI state updates), which naturally leads to very similar results.
I just wanted to highlight that the logic here is fairly standard, so some overlap in approach is expected.
I hope this clarifies the situation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What's the source of this code?

I appreciate you bringing this up.

The logic here is mainly based on Anki’s search system, which I used as the primary reference while implementing this part.
While working on it, I also noticed that @Galal-20 had a similar issue and solution in his PR, which helped me better understand the expected behavior. So his approach influenced my thinking, but I reimplemented the logic myself to fit my current changes.
Since the problem and constraints are the same, it’s natural that the implementations look very similar.

Let me know if you’d like me to adjust anything here.

}
}

private suspend fun hasMatchingCards(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The name doesn't provide context for what it does

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The name doesn't provide context for what it does

You’re right, the current name doesn’t clearly describe what the function is actually checking.

This function is specifically used for the STUDY_FORGOT case.
It validates the user input, then checks whether there are any cards in the current deck that match the search query rated:$value:1 (forgotten cards within the given range).
The result is used to decide whether to enable the positive button or show an error if no cards match the criteria.

I’m thinking of renaming it to (hasForgottenCardsMatchingInput) as its more descriptive name from my point of view since it reflects both the condition and the dependency on the user input.

Do you think this makes the intent clearer? if this name suitable and clear, ping me to rename it.

@david-allison
Copy link
Copy Markdown
Member

cbbaec1#r3037507014 makes me feel uneasy. Closing this PR after a discussion with the maintainers.

Two PRs sharing code this closely without attribution is not normal.

If code is being borrowed, mention it in the commit message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Author Reply Waiting for a reply from the original author Needs Review Strings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve the Review forgotten cards dialog

4 participants