Skip to content
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

[Voice to Content] Support device rotation while recording #20995

Merged
merged 14 commits into from
Jun 19, 2024

Conversation

zwarm
Copy link
Contributor

@zwarm zwarm commented Jun 17, 2024

Fixes https://github.com/Automattic/wordpress-mobile/issues/77

This PR adds support for device rotation

  • Add fun isRecording() and fun isPaused() to IAudioRecorder` interface to allow checking if the audio recorder is currently recording or paused.
  • Update RecordingUseCase to allow access to the values mentioned above
  • Update VoiceToContentViewModel to receive the flow and add to the UI state for use in the VoiceToContentScreen
  • Update VoiceToContentScreen and MicToStopIcon to use the isRecording value to drive visual components
  • Update relevant classes to implement the new methods
  • Replace log.util with AppLog statements in AudioRecorder
  • Only endRecordingSession is one is in session

This PR is the companion app for wordpress-mobile/WordPress-FluxC-Android#3035. See merge notes.

This branch build upon issue/v2c-show-elapsed-time

Important

Merge Instructions

Note

The following have not yet been implemented:

  • Overall polishing of the UI
  • Unit tests

To Test:

  • Install and launch the app
  • Login with an account that has access to AI credits (Any a8c P2 will have this - other free sites have 20 requests)
  • Navigate to Me > Debug Settings and enable the voice_to_content flag (restart the app)
  • Navigate to My Site and tap the FAB
  • Select the Post with Audio option
  • Start the recording session by tapping on the mic icon
  • Record a blog post - a few words, maybe include a list, try it out
  • Rotate the device
  • ✅ Verify the recording view remains on the screen and you are still able to record
  • Continue recording some audio
  • Tap the done icon and wait for the Edit Post view
  • ✅ Verify content reflects the audio content from before and after the device rotation
    Note: There is a known issue that sometimes all the content shows in the title instead of the body. This is a GB transformation issue that will be addressed separately.

Regression Notes

  1. Potential unintended areas of impact
    The app crashes or doesn't pick up recording where it was left off.

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    Manual testing

  3. What automated tests I added (or what prevented me from doing so)
    N/A


PR Submission Checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Testing Checklist (strike-out the not-applying and unnecessary ones): N/A

@zwarm zwarm self-assigned this Jun 17, 2024
@zwarm zwarm changed the base branch from trunk to issue/v2c-launch-edit-post June 17, 2024 13:38
@zwarm zwarm requested a review from notandyvee June 17, 2024 13:50
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jun 17, 2024

Jetpack📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack Jetpack
FlavorJalapeno
Build TypeDebug
Versionpr20995-b3fba93
Commitb3fba93
Direct Downloadjetpack-prototype-build-pr20995-b3fba93.apk
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jun 17, 2024

WordPress📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress WordPress
FlavorJalapeno
Build TypeDebug
Versionpr20995-b3fba93
Commitb3fba93
Direct Downloadwordpress-prototype-build-pr20995-b3fba93.apk
Note: Google Login is not supported on these builds.

Copy link

codecov bot commented Jun 17, 2024

Codecov Report

Attention: Patch coverage is 6.15385% with 61 lines in your changes missing coverage. Please review.

Project coverage is 40.73%. Comparing base (5a648b3) to head (d665c58).
Report is 45 commits behind head on trunk.

Current head d665c58 differs from pull request most recent head 942b497

Please upload reports for the commit 942b497 to get more accurate results.

Files Patch % Lines
.../org/wordpress/android/util/audio/AudioRecorder.kt 0.00% 29 Missing ⚠️
.../android/ui/voicetocontent/VoiceToContentScreen.kt 0.00% 14 Missing ⚠️
...droid/ui/voicetocontent/VoiceToContentViewModel.kt 20.00% 8 Missing ⚠️
...ress/android/ui/voicetocontent/RecordingUseCase.kt 0.00% 4 Missing ⚠️
...rdpress/android/ui/voicetocontent/MicToStopIcon.kt 0.00% 3 Missing ⚠️
...android/ui/voicetocontent/VoiceToContentUseCase.kt 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #20995      +/-   ##
==========================================
- Coverage   40.73%   40.73%   -0.01%     
==========================================
  Files        1529     1529              
  Lines       70202    70220      +18     
  Branches    11613    11616       +3     
==========================================
+ Hits        28600    28604       +4     
- Misses      39012    39026      +14     
  Partials     2590     2590              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@notandyvee notandyvee left a comment

Choose a reason for hiding this comment

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

Verify content reflects the audio content from before and after the device rotation
Note: There is a known issue that sometimes all the content shows in the title instead of the body. This is a GB transformation issue that will be addressed separately.

I tested and when changing orientation it actually did not save the previous text before the orientation change. Maybe I did something wrong?

Copy link
Contributor

@notandyvee notandyvee left a comment

Choose a reason for hiding this comment

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

I just tried multiple times, and now it works 🤔 . I'll do a quick re-review and make sure I didn't miss anything.

Copy link
Contributor

@notandyvee notandyvee left a comment

Choose a reason for hiding this comment

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

Changes LGTM 👍🏻 . Testing was a bit flaky. But overall the point was to support rotation changes. Which it does. Good work. I won't merge because another PR it depends on hasn't been merged. So you can merge whenever you are ready.

Base automatically changed from issue/v2c-launch-edit-post to trunk June 19, 2024 12:04
@dangermattic
Copy link
Collaborator

1 Warning
⚠️ PR is not assigned to a milestone.

Generated by 🚫 Danger

Copy link

sonarcloud bot commented Jun 19, 2024

@wpmobilebot
Copy link
Contributor

Found 1 violations:

The PR caused some dependency changes (expand to see details)

-+--- org.wordpress:fluxc:{strictly trunk-0fe67fa241426afeaaa66bc3970ba46634efa5c8} -> trunk-0fe67fa241426afeaaa66bc3970ba46634efa5c8
-|    +--- org.wordpress:wellsql:2.0.0
-|    |    +--- androidx.annotation:annotation:1.2.0 -> 1.6.0 (*)
-|    |    \--- org.wordpress.wellsql:wellsql-annotations:2.0.0
-|    +--- org.wordpress.fluxc:fluxc-annotations:trunk-0fe67fa241426afeaaa66bc3970ba46634efa5c8
-|    +--- org.greenrobot:eventbus:3.3.1
-|    |    \--- org.greenrobot:eventbus-java:3.3.1
-|    +--- com.squareup.okhttp3:okhttp:4.9.0 -> 4.12.0 (*)
-|    +--- com.android.volley:volley:1.1.1 -> 1.2.1
-|    +--- androidx.paging:paging-runtime:2.1.2
-|    |    +--- androidx.paging:paging-common:2.1.2
-|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.6.0 (*)
-|    |    |    \--- androidx.arch.core:core-common:2.0.0 -> 2.2.0 (*)
-|    |    +--- androidx.arch.core:core-runtime:2.0.0 -> 2.2.0 (*)
-|    |    +--- androidx.lifecycle:lifecycle-runtime:2.0.0 -> 2.6.2 (*)
-|    |    +--- androidx.lifecycle:lifecycle-livedata:2.0.0 -> 2.6.2 (*)
-|    |    \--- androidx.recyclerview:recyclerview:1.0.0 -> 1.3.0 (*)
-|    +--- com.goterl:lazysodium-android:5.0.2
-|    +--- net.java.dev.jna:jna:5.5.0
-|    +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.20 -> 1.9.10 (*)
-|    +--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.6.20 -> 1.9.22 (*)
-|    +--- androidx.appcompat:appcompat:1.0.2 -> 1.6.1 (*)
-|    +--- androidx.recyclerview:recyclerview:1.0.0 -> 1.3.0 (*)
-|    +--- androidx.exifinterface:exifinterface:1.0.0 -> 1.3.6 (*)
-|    +--- androidx.security:security-crypto:1.0.0
-|    |    +--- androidx.annotation:annotation:1.1.0 -> 1.6.0 (*)
-|    |    \--- com.google.crypto.tink:tink-android:1.5.0
-|    +--- com.squareup.okhttp3:okhttp-urlconnection:4.9.0 -> 4.9.2 (*)
-|    +--- com.google.code.gson:gson:2.8.5 -> 2.10.1
-|    +--- org.apache.commons:commons-text:1.10.0
-|    |    \--- org.apache.commons:commons-lang3:3.12.0
-|    +--- androidx.room:room-runtime:2.4.2 -> 2.5.0
-|    |    +--- androidx.annotation:annotation-experimental:1.1.0 -> 1.3.1 (*)
-|    |    +--- androidx.arch.core:core-runtime:2.0.1 -> 2.2.0 (*)
-|    |    +--- androidx.room:room-common:2.5.0
-|    |    |    +--- androidx.annotation:annotation:1.3.0 -> 1.6.0 (*)
-|    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20 -> 1.9.10 (*)
-|    |    +--- androidx.sqlite:sqlite:2.3.0
-|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.6.0 (*)
-|    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.7.20 -> 1.9.22 (*)
-|    |    \--- androidx.sqlite:sqlite-framework:2.3.0
-|    |         +--- androidx.annotation:annotation:1.2.0 -> 1.6.0 (*)
-|    |         +--- androidx.sqlite:sqlite:2.3.0 (*)
-|    |         \--- org.jetbrains.kotlin:kotlin-stdlib:1.7.20 -> 1.9.22 (*)
-|    +--- androidx.room:room-ktx:2.4.2 -> 2.5.0
-|    |    +--- androidx.room:room-common:2.5.0 (*)
-|    |    +--- androidx.room:room-runtime:2.5.0 (*)
-|    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.7.20 -> 1.9.22 (*)
-|    |    \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4 -> 1.7.3 (*)
-|    +--- com.google.dagger:dagger:2.42 -> 2.50
-|    |    \--- javax.inject:javax.inject:1
-|    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9 -> 1.7.3 (*)
-|    \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9 -> 1.7.3 (*)
++--- org.wordpress:fluxc:{strictly trunk-79f2bc35285748c715e00f2a6648ed6831632178} -> trunk-79f2bc35285748c715e00f2a6648ed6831632178
+|    +--- org.wordpress:wellsql:2.0.0
+|    |    +--- androidx.annotation:annotation:1.2.0 -> 1.6.0 (*)
+|    |    \--- org.wordpress.wellsql:wellsql-annotations:2.0.0
+|    +--- org.wordpress.fluxc:fluxc-annotations:trunk-79f2bc35285748c715e00f2a6648ed6831632178
+|    +--- org.greenrobot:eventbus:3.3.1
+|    |    \--- org.greenrobot:eventbus-java:3.3.1
+|    +--- com.squareup.okhttp3:okhttp:4.9.0 -> 4.12.0 (*)
+|    +--- com.android.volley:volley:1.1.1 -> 1.2.1
+|    +--- androidx.paging:paging-runtime:2.1.2
+|    |    +--- androidx.paging:paging-common:2.1.2
+|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.6.0 (*)
+|    |    |    \--- androidx.arch.core:core-common:2.0.0 -> 2.2.0 (*)
+|    |    +--- androidx.arch.core:core-runtime:2.0.0 -> 2.2.0 (*)
+|    |    +--- androidx.lifecycle:lifecycle-runtime:2.0.0 -> 2.6.2 (*)
+|    |    +--- androidx.lifecycle:lifecycle-livedata:2.0.0 -> 2.6.2 (*)
+|    |    \--- androidx.recyclerview:recyclerview:1.0.0 -> 1.3.0 (*)
+|    +--- com.goterl:lazysodium-android:5.0.2
+|    +--- net.java.dev.jna:jna:5.5.0
+|    +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.20 -> 1.9.10 (*)
+|    +--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.6.20 -> 1.9.22 (*)
+|    +--- androidx.appcompat:appcompat:1.0.2 -> 1.6.1 (*)
+|    +--- androidx.recyclerview:recyclerview:1.0.0 -> 1.3.0 (*)
+|    +--- androidx.exifinterface:exifinterface:1.0.0 -> 1.3.6 (*)
+|    +--- androidx.security:security-crypto:1.0.0
+|    |    +--- androidx.annotation:annotation:1.1.0 -> 1.6.0 (*)
+|    |    \--- com.google.crypto.tink:tink-android:1.5.0
+|    +--- com.squareup.okhttp3:okhttp-urlconnection:4.9.0 -> 4.9.2 (*)
+|    +--- com.google.code.gson:gson:2.8.5 -> 2.10.1
+|    +--- org.apache.commons:commons-text:1.10.0
+|    |    \--- org.apache.commons:commons-lang3:3.12.0
+|    +--- androidx.room:room-runtime:2.4.2 -> 2.5.0
+|    |    +--- androidx.annotation:annotation-experimental:1.1.0 -> 1.3.1 (*)
+|    |    +--- androidx.arch.core:core-runtime:2.0.1 -> 2.2.0 (*)
+|    |    +--- androidx.room:room-common:2.5.0
+|    |    |    +--- androidx.annotation:annotation:1.3.0 -> 1.6.0 (*)
+|    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20 -> 1.9.10 (*)
+|    |    +--- androidx.sqlite:sqlite:2.3.0
+|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.6.0 (*)
+|    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.7.20 -> 1.9.22 (*)
+|    |    \--- androidx.sqlite:sqlite-framework:2.3.0
+|    |         +--- androidx.annotation:annotation:1.2.0 -> 1.6.0 (*)
+|    |         +--- androidx.sqlite:sqlite:2.3.0 (*)
+|    |         \--- org.jetbrains.kotlin:kotlin-stdlib:1.7.20 -> 1.9.22 (*)
+|    +--- androidx.room:room-ktx:2.4.2 -> 2.5.0
+|    |    +--- androidx.room:room-common:2.5.0 (*)
+|    |    +--- androidx.room:room-runtime:2.5.0 (*)
+|    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.7.20 -> 1.9.22 (*)
+|    |    \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4 -> 1.7.3 (*)
+|    +--- com.google.dagger:dagger:2.42 -> 2.50
+|    |    \--- javax.inject:javax.inject:1
+|    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9 -> 1.7.3 (*)
+|    \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9 -> 1.7.3 (*)
 \--- org.wordpress:login:1.16.0
-     \--- org.wordpress:fluxc:trunk-ed60798b4d96ec19863c74b0f525e2e20f4525db -> trunk-0fe67fa241426afeaaa66bc3970ba46634efa5c8 (*)
+     \--- org.wordpress:fluxc:trunk-ed60798b4d96ec19863c74b0f525e2e20f4525db -> trunk-79f2bc35285748c715e00f2a6648ed6831632178 (*)

Please review and act accordingly

@zwarm zwarm enabled auto-merge June 19, 2024 15:48
@zwarm zwarm merged commit f755146 into trunk Jun 19, 2024
20 checks passed
@zwarm zwarm deleted the issue/v2c-workflow-odds-ends branch June 19, 2024 16:02
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.

4 participants