Fix Auto Advance waiting for audio when autoplay is disabled #17974
+5
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose / Description
Auto Advance does not work when both "Don't play audio automatically" and "Wait for audio" are enabled
Fixes
Approach
TheFile Abstractflashcardviewer.k contain automaticAnswerShouldWaitForAudio() function
https://github.com/ankidroid/Anki-Android/blob/main/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.kt#L1309-L1312
this function only checks "Wait for audio" but ignores autoplay, which means Auto Advance might still wait even if autoplay is disabled.Since this function doesn’t check autoplay, we need to fix it so Auto Advance behaves correctly.
Since ReviewerViewModel.kt does not inherit from AbstractFlashcardViewer.kt, we need a reference to an instance of AbstractFlashcardViewer.then call the function through flashcardViewer
then Modify AutoAdvance.kt so it correctly calls shouldWaitForAudio() from ReviewerViewModel.kt
How Has This Been Tested?
Instructions to reprodruce
1-(Optional) Confirm that "Auto Advance" feature is working in the selected deck in Reviewer
2-Long-press the deck in the main screen > "Deck options" >
"Audio" > set "Don't play audio automatically" enabled
(It is set to disabled by default)
3-"Auto Advance" > set "Wait for audio" enabled
(It is already set to enabled by default)
4-Tap "Save"
5-Tap the deck to open Reviewer
verfication:AutoAdvance behaves correctly
ankidroid.mp4
tested on android device samsung
Learning (optional, can help others)
Describe the research stage
Links to blog posts, patterns, libraries or addons used to solve this problem
Checklist
Please, go through these checks before submitting the PR.