Skip to content

Comments

fix: missing media error on new study screen#20359

Open
HS0204 wants to merge 1 commit intoankidroid:mainfrom
HS0204:fix/new-screen-media
Open

fix: missing media error on new study screen#20359
HS0204 wants to merge 1 commit intoankidroid:mainfrom
HS0204:fix/new-screen-media

Conversation

@HS0204
Copy link
Contributor

@HS0204 HS0204 commented Feb 24, 2026

Purpose / Description

In the new study screen, media errors were not being counted correctly. This caused the error snackbar to appear repeatedly, which could be annoying for users.
This was caused by hasExecuted not being reset on card side changes. This PR restores the previous behaviour by aligning the logic with the old screen implementation. Snackbar will no longer be displayed in after being missing media error counted twice.

Fixes

Approach

To minimise unexpected side effects, the logic of the new study screen was aligned with the old screen.
When media errors occur, the previous logic follows these steps:

  1. If a media file cannot be found, processMissingMedia() in MediaErrorHandler.kt is called.
  2. Inside that function, the exposure count is checked and missingMediaCount may be incremented.
  3. hasExecuted flag plays an role in above process and must be reset whenever the card side changes.
  4. In the old screen, hasExecuted was reset via onCardSideChange() inside displayCardAnswer() in AbstractFlashcardViewer.kt when the card side changed.
  5. In the new study screen, the call to onCardSideChange() was missing, so it has been added.

How Has This Been Tested?

  1. passed the existing unit test MediaErrorHandlerTest. (honestly the logic isn't changed)
  2. compared with the old screen and checked the same actions. please check the below videos.
    Old Screen Recording
    Previous New Screen Recording
    Fixed New Screen Recording

Learning (optional, can help others)

  • I considered moving the hasExecuted management into MediaErrorHandler.kt to avoid relying on external updates. However, this would be a larger change than required for this issue, so I limited the fix to the current logic.
  • I also reflected on the purpose of hasExecuted. It seems that it was intended to manage media error counting per card rather than globally. While this could be improved, refactoring it would be exceed the scope of this issue. It may be better addressed in a separate task.

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

- Updated the new study screen logic to match the old screen.
- The execution flags(hasExecueted) is reset to `false` when showing the answer so that missing media can be counted properly.
@welcome
Copy link

welcome bot commented Feb 24, 2026

First PR! 🚀 We sincerely appreciate that you have taken the time to propose a change to AnkiDroid! Please have patience with us as we are all volunteers - we will get to this as soon as possible.

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.

[New study screen] Missing media message appears repeatedly

1 participant