From f242c990a16a54e927765d0f71d24cc26b17c4c4 Mon Sep 17 00:00:00 2001 From: kevingitonga Date: Wed, 28 Sep 2022 11:32:39 +0300 Subject: [PATCH 1/7] Check for pause audio pending requests from PlayerStatus observer and complete pending requests. --- .../android/app/player/audio/AudioFragmentPresenter.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt index 2de7bc529ad..f32902c7d3c 100755 --- a/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt @@ -59,6 +59,7 @@ class AudioFragmentPresenter @Inject constructor( private val viewModel by lazy { getAudioViewModel() } + private var isPauseAudioRequestPending = false /** Sets up SeekBar listener, ViewModel, and gets VoiceoverMappings or restores saved state */ fun handleCreateView( @@ -101,6 +102,9 @@ class AudioFragmentPresenter @Inject constructor( Observer { prepared = it != UiAudioPlayStatus.LOADING && it != UiAudioPlayStatus.FAILED binding.audioProgressSeekBar.isEnabled = prepared + if (prepared && isPauseAudioRequestPending) { + pauseAudio() + } } ) @@ -197,8 +201,10 @@ class AudioFragmentPresenter @Inject constructor( viewModel.loadFeedbackAudio(contentId, allowAutoPlay) fun pauseAudio() { - if (prepared) + if (prepared && isPauseAudioRequestPending) { viewModel.pauseAudio() + isPauseAudioRequestPending = false + } } fun handleEnableAudio(saveUserChoice: Boolean) { @@ -265,6 +271,7 @@ class AudioFragmentPresenter @Inject constructor( } private fun hideAudioFragment() { + isPauseAudioRequestPending = true (activity as AudioButtonListener).showAudioStreamingOff() (fragment as AudioUiManager).pauseAudio() val animation = AnimationUtils.loadAnimation(context, R.anim.slide_up_audio) From 6a1b1787f222ab89eeed0132d2971c897e82e57b Mon Sep 17 00:00:00 2001 From: kevingitonga Date: Fri, 30 Sep 2022 11:16:54 +0300 Subject: [PATCH 2/7] Check pendingAudioPause request directly from "pauseAudio" since it interfaces with viewModel to perform pause. --- .../oppia/android/app/player/audio/AudioFragmentPresenter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt index 38742ad5a6e..72096f949d9 100755 --- a/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt @@ -202,6 +202,7 @@ class AudioFragmentPresenter @Inject constructor( viewModel.loadFeedbackAudio(contentId, allowAutoPlay) fun pauseAudio() { + isPauseAudioRequestPending = true if (prepared && isPauseAudioRequestPending) { viewModel.pauseAudio() isPauseAudioRequestPending = false @@ -272,7 +273,6 @@ class AudioFragmentPresenter @Inject constructor( } private fun hideAudioFragment() { - isPauseAudioRequestPending = true (activity as AudioButtonListener).showAudioStreamingOff() (fragment as AudioUiManager).pauseAudio() val animation = AnimationUtils.loadAnimation(context, R.anim.slide_up_audio) From d67eca9215e7af37c54d6345ce18252c9a2e0cae Mon Sep 17 00:00:00 2001 From: kevingitonga Date: Tue, 17 Jan 2023 14:03:35 +0300 Subject: [PATCH 3/7] Fix lint check CI failure issue. --- .../oppia/android/app/player/audio/AudioFragmentPresenter.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt index 80551107f08..bc760727dc6 100644 --- a/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt @@ -66,11 +66,10 @@ class AudioFragmentPresenter @Inject constructor( private val viewModel by lazy { getAudioViewModel() } - + private var isPauseAudioRequestPending = false private lateinit var binding: AudioFragmentBinding - /** Sets up SeekBar listener, ViewModel, and gets VoiceoverMappings or restores saved state */ fun handleCreateView( inflater: LayoutInflater, From c6773514efe5950893af93cdcb7bc2ddfd28fbec Mon Sep 17 00:00:00 2001 From: kevingitonga Date: Tue, 31 Jan 2023 12:14:11 +0300 Subject: [PATCH 4/7] Add comments on the changes as to why this fix works and link notes. --- .../android/app/player/audio/AudioFragmentPresenter.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt index bc760727dc6..b88d6a51933 100644 --- a/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt @@ -111,6 +111,13 @@ class AudioFragmentPresenter @Inject constructor( Observer { prepared = it != UiAudioPlayStatus.LOADING && it != UiAudioPlayStatus.FAILED binding.audioProgressSeekBar.isEnabled = prepared + + // This check will execute any pending pause request that causes + // issue with audio not being paused as user navigates through + // lessons in a topic check below issue for more details + // https://github.com/oppia/oppia-android/issues/1801 + // Link to notes on why this fix works can be found on link below + // https://github.com/oppia/oppia-android/pull/4629#issuecomment-1410005186 if (prepared && isPauseAudioRequestPending) { pauseAudio() } From 800a21e07c05edf175b10345360e555442d2c3e7 Mon Sep 17 00:00:00 2001 From: kevingitonga Date: Wed, 1 Feb 2023 15:10:03 +0300 Subject: [PATCH 5/7] Update comments to line wrap at atleast 100 chars. --- .../android/app/player/audio/AudioFragmentPresenter.kt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt index b88d6a51933..88e9d2141ad 100644 --- a/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt @@ -111,13 +111,10 @@ class AudioFragmentPresenter @Inject constructor( Observer { prepared = it != UiAudioPlayStatus.LOADING && it != UiAudioPlayStatus.FAILED binding.audioProgressSeekBar.isEnabled = prepared - - // This check will execute any pending pause request that causes - // issue with audio not being paused as user navigates through - // lessons in a topic check below issue for more details - // https://github.com/oppia/oppia-android/issues/1801 - // Link to notes on why this fix works can be found on link below + // This check will execute any pending pause request that causes issues with audio not being paused + // as the user navigates through lessons in a topic. Check #1801 for more details, and specifically // https://github.com/oppia/oppia-android/pull/4629#issuecomment-1410005186 + // for notes on why this fix works. if (prepared && isPauseAudioRequestPending) { pauseAudio() } From a2d40c143cf75b61cb7a9d169700a825e6de54ca Mon Sep 17 00:00:00 2001 From: kevingitonga Date: Wed, 1 Feb 2023 15:50:02 +0300 Subject: [PATCH 6/7] Update comments to line wrap at atleast 100 chars. --- .../android/app/player/audio/AudioFragmentPresenter.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt index 88e9d2141ad..b6d5a7387b0 100644 --- a/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt @@ -111,10 +111,13 @@ class AudioFragmentPresenter @Inject constructor( Observer { prepared = it != UiAudioPlayStatus.LOADING && it != UiAudioPlayStatus.FAILED binding.audioProgressSeekBar.isEnabled = prepared - // This check will execute any pending pause request that causes issues with audio not being paused - // as the user navigates through lessons in a topic. Check #1801 for more details, and specifically + + // This check will execute any pending pause request that causes issues with + // audio not being paused as the user navigates through lessons in a topic. + // Check #1801 for more details, and specifically // https://github.com/oppia/oppia-android/pull/4629#issuecomment-1410005186 // for notes on why this fix works. + if (prepared && isPauseAudioRequestPending) { pauseAudio() } From 362e4ebe280fec514f622feea3c091cd3093e029 Mon Sep 17 00:00:00 2001 From: kevingitonga Date: Wed, 1 Feb 2023 15:51:36 +0300 Subject: [PATCH 7/7] Update comments to line wrap at atleast 100 chars. --- .../org/oppia/android/app/player/audio/AudioFragmentPresenter.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt index b6d5a7387b0..5e5f4cd29c6 100644 --- a/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt @@ -117,7 +117,6 @@ class AudioFragmentPresenter @Inject constructor( // Check #1801 for more details, and specifically // https://github.com/oppia/oppia-android/pull/4629#issuecomment-1410005186 // for notes on why this fix works. - if (prepared && isPauseAudioRequestPending) { pauseAudio() }