Skip to content

Conversation

@seadowg
Copy link
Member

@seadowg seadowg commented Feb 14, 2025

Work towards #5420

ScreenContext was making it hard to convert form entry to a Fragment as using it makes assumptions about how the views (widgets) sit within an Activity. To get rid of it, I also needed to remove the deprecated AudioHelper.

Why is this the best possible solution? Were any other approaches considered?

Comments inline.

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?

The main area affected here is forms that use audio. By this I mean in question labels, selects or the audio widget itself (although recording hasn't been changed at all).

Before submitting this PR, please make sure you have:

  • added or modified tests for any new or changed behavior
  • run ./gradlew connectedAndroidTest (or ./gradlew testLab) and confirmed all checks still pass
  • added a comment above any new strings describing it for translators
  • added any new strings with date formatting to DateFormatsTest
  • verified that any code or assets from external sources are properly credited in comments and/or in the about file.
  • verified that any new UI elements use theme colors. UI Components Style guidelines


public void setAudioHelper(AudioHelper audioHelper) {
this.audioHelper = audioHelper;
public void setAudioPlayer(AudioPlayer audioPlayer) {
Copy link
Member Author

Choose a reason for hiding this comment

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

I'd like to clean up this need to have a way of dynamically setting an AudioPlayer on the select adapter, but it would mean restructuring the select minimal dialog implementation which would be yet another rabbit hole to go down. That'll be saved for #6279.

public QuestionWidget(Context context, QuestionDetails questionDetails) {
protected AudioPlayer audioPlayer;

public QuestionWidget(Context context, Dependencies dependencies, QuestionDetails questionDetails) {
Copy link
Member Author

Choose a reason for hiding this comment

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

I think we'll hopefully move towards a world where changing this constructor isn't so awkward (#6534 is already pushing in the direction). For now, I felt like we should introduce an easier way to do it that doesn't rely on Dagger (which only works for application level dependencies) rather just adding AudioPlayer to every widget's contructor.

@seadowg seadowg changed the title Remove AudioHelper and ScreenContext Remove AudioHelper and ScreenContext Feb 18, 2025
@seadowg seadowg marked this pull request as ready for review February 18, 2025 11:48
@seadowg seadowg requested a review from grzesiek2010 February 18, 2025 11:48

private val currentlyPlaying = MutableLiveData<CurrentlyPlaying?>(null)
private val error = MutableLiveData<Exception?>()
private val error = MutableLiveData<Consumable<Exception>?>()
Copy link
Member

Choose a reason for hiding this comment

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

It doesn't need to be nullable now as it uses Consumable right? We used null to make the errors one-time occurrences.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yeah I guess we never set the error back to null now. It feels like the error should still be null once there's a successful load clip load though. I'll tweak that.

@seadowg seadowg requested a review from grzesiek2010 March 10, 2025 13:29
@grzesiek2010 grzesiek2010 merged commit 344c6ea into getodk:master Mar 10, 2025
6 checks passed
@seadowg seadowg deleted the audio-player branch March 11, 2025 08:27
@srujner
Copy link

srujner commented Mar 11, 2025

Tested with Success!

Tested on device with Android: 10,12

Verified cases:

  • Regression checks on audio;
  • Using external app for audio recording, background recording;
  • Permission dialog denied/accepted;
  • Switching between projects, multiple project;
  • Different forms with audio question type;
  • Change/stop/resume recording settings in the middle of filling the form
  • Rotate the screen, minimize the app

@WKobus
Copy link

WKobus commented Mar 11, 2025

Tested with Success!

Tested on device with Android 15

@dbemke
Copy link

dbemke commented Mar 11, 2025

Tested with Success!

Tested on device with Android: 10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants