-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Fix Auto Advance waiting for audio when autoplay is disabled #17974
base: main
Are you sure you want to change the base?
Conversation
AnkiDroid/src/main/java/com/ichi2/anki/ui/windows/reviewer/ReviewerViewModel.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/ui/windows/reviewer/autoadvance/AutoAdvance.kt
Outdated
Show resolved
Hide resolved
b8e596c
to
b0c6e3a
Compare
Hi, |
AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.kt
Outdated
Show resolved
Hide resolved
Co-authored-by: Brayan Oliveira <[email protected]>
private suspend fun automaticAnswerShouldWaitForAudio(): Boolean = | ||
withCol { | ||
decks.configDictForDeckId(currentCard!!.did).waitForAudio | ||
val card = currentCard ?: return@withCol false | ||
val waitForAudio = decks.configDictForDeckId(card.did).waitForAudio | ||
val soundConfig = CardSoundConfig.create(this, card) | ||
return@withCol waitForAudio && soundConfig.autoplay | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the method does more than what its name say it does. The issue probably isn't here, but in the calls for auto advance to run
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.