-
Notifications
You must be signed in to change notification settings - Fork 1.3k
WP Stories integration: UploadService trigger #12031
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
WP Stories integration: UploadService trigger #12031
Conversation
…ress class so we can trigger the UploadService from there
… payload to the FrameSaveService and get it back when a SaveResult is ready
You can trigger optional UI/connected tests for these changes by visiting CircleCI here. |
You can test the changes on this Pull Request by downloading the APK here. |
…ch of the StoryFrameItem composed frame files
…t will hold the contents of the Story
…files and add them as Media and insert them into a Post, then upload
…ploadBridge registers itself
…y unneeded Post from the database when the user exits without creating anything
…n existing backing Post
…y is complete and successfully saved - avoid processing individual frame retries
… with PostUploadNotifier
…nted loader interface for loading notification dismiss PendingIntent
WordPress/src/main/java/org/wordpress/android/ui/stories/StoryMediaSaveUploadBridge.kt
Show resolved
Hide resolved
WordPress/src/main/java/org/wordpress/android/ui/stories/StoryMediaSaveUploadBridge.kt
Outdated
Show resolved
Hide resolved
editPostRepository.getPost(), | ||
site | ||
) | ||
uploadService.uploadPost(WordPress.getContext(), editPostRepository.id, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we inject this context somehow so that we avoid using the static method call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Been checking this, I think we need to make a context factory so it's injectable. I've seen sometimes we use init()
to pass some variables to ViewModels and other injectable classes in WPAndroid, so went that way for now in 85bda8b
WordPress/src/main/java/org/wordpress/android/ui/stories/StoryMediaSaveUploadBridge.kt
Show resolved
Hide resolved
WordPress/src/main/java/org/wordpress/android/ui/stories/StoryMediaSaveUploadBridge.kt
Outdated
Show resolved
Hide resolved
WordPress/src/main/java/org/wordpress/android/ui/stories/StoryMediaSaveUploadBridge.kt
Outdated
Show resolved
Hide resolved
WordPress/src/main/java/org/wordpress/android/ui/stories/StoryMediaSaveUploadBridge.kt
Outdated
Show resolved
Hide resolved
WordPress/src/main/java/org/wordpress/android/ui/stories/StoryMediaSaveUploadBridge.kt
Outdated
Show resolved
Hide resolved
WordPress/src/main/java/org/wordpress/android/ui/stories/StoryMediaSaveUploadBridge.kt
Show resolved
Hide resolved
WordPress/src/main/java/org/wordpress/android/ui/stories/StoryMediaSaveUploadBridge.kt
Outdated
Show resolved
Hide resolved
WordPress/src/main/java/org/wordpress/android/ui/stories/StoryComposerActivity.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mzorz great work on this 😄 I left some comments but overall the solution works really nicely. It was great seeing the story converted to a post!
…rt9-emoji-compat WP Stories integration: add EmojiCompat library for stories emoji support
Co-authored-by: Joel Dean <[email protected]>
…rt92-notif-delete-intent WP Stories integration - setting the base error notification ID and setDelete PendingIntent for error notification
…rt10-tracks-notifications WP Stories integration - implement StoryNotificationTrackerProvider interface
Generated by 🚫 dangerJS |
Co-authored-by: Joel Dean <[email protected]>
…hub.com/wordpress-mobile/WordPress-Android into feature/wp-stories-part8-upload-service
Thanks a lot for your review! Should be ready for a second round @jd-alexander 🙇 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes @mzorz Ran another test and all works well! LGTM 🚢
Builds on top of #11987
This PR implements the needed changes to listen to a StorySaveResult and then triggering the UploadService to upload the composed images.
For this, a new class is introduced, called
StoryMediaSaveUploadBridge
that is both aLifecycleObserver
and aEditorMediaListener
, which carries with this responsibility.How it works
First, the StoryComposerActivity is now creating a backing Post, which will contain the story content in the format of a Gallery.
The post is instantiated and kept empty, given we won't populate its content until later when we know the media Ids for each of the saved story frames.
The StoryMediaSaveUploadBridge is registered as a LifeycleObserver of the Application class, and subscribes to EventBus
StorySaveResult
events in itsonCreate()
observer override.When all of a Story's frames are successfully saved to disk (which is the responsibility of FrameSaveManager and FrameSaveService in the stories library), this class will then:
mediaId
for each (this is simply theid
in the MediaStore).mediaId
field in FluxC's MediaStore) and the post content is updated by replacing the placeholders with each remoteId correspondingly, for example:once media is finished uploading, the UploadService also takes care of uploading the corresponding Post.
in the case the user decides to abandon the Story creation screen without pubslishing, the backing Post will be discarded. Any frames saved to that point will remain as media in their device (not media in the WP libraries, just on their device as raw image / video files)
Error handling
Videos
Videos are not supported yet, given the Gallery only supports images. There's no code in this PR or in the stories library in general to prevent this, given it'd be just adding unnecessary work. If you add a video to a Story, and it gets saved correctly, etc. it will be uploaded to the site and added to the Gallery, but it won't show in the resulting Post.
To test:
PR submission checklist:
RELEASE-NOTES.txt
if necessary.