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.
Closes #5977
Why is this the best possible solution? Were any other approaches considered?
The implementation of passing new answers to the audio widget was incorrect. The issue stemmed from immediately saving the answer after recording audio, as seen here: https://github.com/getodk/collect/pull/5979/files#diff-06b81c70d38f41b152a55fd3c656029170b518aa952058c54e7b8d68041150b7L62
This approach diverges from the standard procedure followed by other widgets. Typically, answers are passed to the widget, with saving occurring later when answers for the current screen are saved.
Adopting the same process as with other widgets ensures consistency. When the answer is saved prematurely, as with the audio widget, it complicates the handling of question updates, especially on screens with multiple questions. This early saving prevents proper comparison of questions before and after saving answers for the current screen see: https://github.com/getodk/collect/blob/master/collect_app/src/main/java/org/odk/collect/android/activities/FormFillingActivity.java#L2301
Consequently, if a question depended on the audio widget and was displayed conditionally, it might not have been added to the list upon audio recording. Subsequently, attempting to remove such a question, which wasn't displayed, led to a crash when the audio was deleted.
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
Apart from testing the issue itself, it would be good to verify that the audio widget works well with no regressions. I would take a look at the similar issues we have had recently:
Do we need any specific form for testing your changes? If so, please attach one.
Does this change require updates to documentation? If so, please file an issue here and include the link below.
No.
Before submitting this PR, please make sure you have:
./gradlew connectedAndroidTest
(or./gradlew testLab
) and confirmed all checks still pass