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

Fixed bug which was causing AnkiDroid API to not list media on cards. #17859

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

Conversation

ujjol1234
Copy link

Purpose / Description

Fixed the bug which was causing AnkiDroid API to not list media on cards. Added a unit test to confirm that media files are listed correctly in the ReviewInfo.

Fixes

Approach

Reimplemented the filesinStr function which was causing the bug.

How Has This Been Tested?

A unit test testMediaFilesAddedCorrectlyInReviewInfo() has been added in the ContentProviderTest.kt to confirm that the MEDIA_FILES attribute of ReviewInfo gets populated correctly.

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

welcome bot commented Jan 22, 2025

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.

currentCard: Card,
includeRemote: Boolean = false,
): List<String> {
val l: MutableList<String> = ArrayList()
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

@david-allison I have reimplemented the old code for the fileinStr from here:

fun filesInStr(mid: Long?, string: String, includeRemote: Boolean = false): List<String> {

This logic was able to extract the image file names but it could not extract the AV tags. My guess is that this is because the Card.renderOutput returns AVTags and it is in the form SoundOrVideoTag(filename). To address this, I added some logic in the function to extract the AVTags as well, and it is now working as expected! Could you please review the changes and let me know if you think this implementation is correct? Any feedback or suggestions for improvement would be greatly appreciated.

Copy link
Member

Choose a reason for hiding this comment

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

We should follow upstream as close as possible in libanki, unless there's a strong reason not to

Copy link
Author

Choose a reason for hiding this comment

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

ok I will try again with the upstream code you provided

@lukstbit lukstbit added the Needs Author Reply Waiting for a reply from the original author label Jan 23, 2025
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 New contributor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] AnkiDroid API no longer lists media on cards
3 participants