ankidroid/Anki-Android — pull request #279 by chajadan (2014-04-12 09:43:03+00:00)
Title: Grab all answer audio, even above answer horizonal rule

This change is a replacement for #278, both of which address issue 2068 -- merge only one of the two, and close the other. The trade offs are: this one holds libanki in the utmost of regard, working around that constraint by calling some code more than once, whereas #278 would be computationally much less intense, but it maintains a discrepancy from anki desktop libanki code.

We had issues in the past, where a call here involved regex calls that significantly slowed down users, so I address that topic of code speed here. When it comes to rendering questions, the code is slightly simplified, so there we are good. When it comes to rendering answers (where we had the issue before), this change certainly introduces a decent amount of code. The meat of that new code comes down to one call each to Reviewer.getAnswerFormat() and Reviewer.IncludeAnyFrontSideAudio(). That second call is highly repetitive in nature (necessarily so), in that in calls _renderQA a second time, and it also recalls a replaceAll regex operation a second time as well. I do not see any lag on my system, but I didn't see it before with the other issue either. I will be running some timing tests for 3 scenarios: 1) how it was after the last lag fix but before addressing issue 2068, 2) how it is after #278, and 3) how it is with this change. I will post those results in this conversation. However again, I did not encounter any lag with this last recent lag issue where other users did, so my system alone is likely not representative of the problem they encountered, for whatever reason (it's a somewhat dinky phone, but).

Both requests address the behavior, but this one not only makes no changes to libanki, but at the request of @timrae and suggestion of @dae goes out of its way to return a part of libanki that has differed for awhile back to a state that is closer to the core libanki we inherit.

A decent amount of effort is spent reproducing the expected ankidroid behavior of having all audio linked to media that a user can play by pressing the play buttons -- such that the user can independently play any one of the audio files present, including those expanded from inclusion of {{FrontSide}}

To that aim, the FrontSide audio which is now stripped in Collection._renderQA (from libanki) is then immediately reinserted. And then, that re-inserted audio from FrontSide is not added to the list of audio that is to be auto-played as part of the answer. If the question is to be repeated automatically, that question audio is already in the list designated as part of the question.

This request maintains the proper separation of question and answer audio that already existed, but the list of answer audio added for playing now strips the {{FrontSide}} expansion, rather than relying on the

as delineating the answer, which for some users I was told it did not.