From 4107505fc564f3b84bf6f5d0c9a6493ea01f7cf9 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Wed, 3 Jan 2024 13:19:39 -0500 Subject: [PATCH 01/15] feat: Failed uploads while offline communicate paused state This is an exploration. The approach taken, namely using the error type string, is not fully tested. --- .../ui/posts/editor/media/EditorMedia.kt | 2 +- .../android/editor/AztecEditorFragment.java | 2 +- .../editor/EditorMediaUploadListener.java | 2 +- .../gutenberg/GutenbergContainerFragment.java | 4 ++++ .../gutenberg/GutenbergEditorFragment.java | 17 ++++++++++++++--- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/media/EditorMedia.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/media/EditorMedia.kt index 4332f516783a..c7cdff090bba 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/media/EditorMedia.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/media/EditorMedia.kt @@ -295,7 +295,7 @@ class EditorMedia @Inject constructor( } } analyticsTrackerWrapper.track(EDITOR_UPLOAD_MEDIA_FAILED, properties) - listener.onMediaUploadFailed(media.id.toString()) + listener.onMediaUploadFailed(media.id.toString(), error.type.name) } sealed class AddMediaToPostUiState( diff --git a/libs/editor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java b/libs/editor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java index 4c945a3feced..10f956090c97 100644 --- a/libs/editor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java +++ b/libs/editor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java @@ -1413,7 +1413,7 @@ public void onMediaUploadProgress(final String localMediaId, final float progres } @Override - public void onMediaUploadFailed(final String localMediaId) { + public void onMediaUploadFailed(final String localMediaId, final String errorType) { if (!isAdded() || mContent == null) { return; } diff --git a/libs/editor/src/main/java/org/wordpress/android/editor/EditorMediaUploadListener.java b/libs/editor/src/main/java/org/wordpress/android/editor/EditorMediaUploadListener.java index ce90ac13eaf7..b87efdae8269 100644 --- a/libs/editor/src/main/java/org/wordpress/android/editor/EditorMediaUploadListener.java +++ b/libs/editor/src/main/java/org/wordpress/android/editor/EditorMediaUploadListener.java @@ -7,6 +7,6 @@ public interface EditorMediaUploadListener { void onMediaUploadReattached(String localId, float currentProgress); void onMediaUploadSucceeded(String localId, MediaFile mediaFile); void onMediaUploadProgress(String localId, float progress); - void onMediaUploadFailed(String localId); + void onMediaUploadFailed(String localId, String errorType); void onGalleryMediaUploadSucceeded(long galleryId, long remoteId, int remaining); } diff --git a/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergContainerFragment.java b/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergContainerFragment.java index 8deeb3210b44..c08a1bc89304 100644 --- a/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergContainerFragment.java +++ b/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergContainerFragment.java @@ -241,6 +241,10 @@ public void mediaFileUploadFailed(final int mediaId) { mWPAndroidGlueCode.mediaFileUploadFailed(mediaId); } + public void mediaFileUploadPaused(final int mediaId) { + mWPAndroidGlueCode.mediaFileUploadPaused(mediaId); + } + public void mediaFileUploadSucceeded(final int mediaId, final String mediaUrl, final int serverMediaId) { mWPAndroidGlueCode.mediaFileUploadSucceeded(mediaId, mediaUrl, serverMediaId, new WritableNativeMap()); } diff --git a/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java b/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java index 16e2f76c9fcc..7db18045d2c8 100644 --- a/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java +++ b/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java @@ -838,7 +838,11 @@ private void updateFailedMediaState() { for (String mediaId : mFailedMediaIds) { // upload progress should work on numeric mediaIds only if (!TextUtils.isEmpty(mediaId) && TextUtils.isDigitsOnly(mediaId)) { - getGutenbergContainerFragment().mediaFileUploadFailed(Integer.valueOf(mediaId)); + if (NetworkUtils.isNetworkAvailable(getActivity())) { + getGutenbergContainerFragment().mediaFileUploadFailed(Integer.valueOf(mediaId)); + } else { + getGutenbergContainerFragment().mediaFileUploadPaused(Integer.valueOf(mediaId)); + } } else { getGutenbergContainerFragment().mediaFileSaveFailed(mediaId); } @@ -1483,8 +1487,15 @@ public void onMediaUploadProgress(final String localMediaId, final float progres } @Override - public void onMediaUploadFailed(final String localMediaId) { - getGutenbergContainerFragment().mediaFileUploadFailed(Integer.valueOf(localMediaId)); + public void onMediaUploadFailed(final String localMediaId, String errorType) { + switch (errorType) { + case "CONNECTION_ERROR": + getGutenbergContainerFragment().mediaFileUploadPaused(Integer.valueOf(localMediaId)); + break; + default: + getGutenbergContainerFragment().mediaFileUploadFailed(Integer.valueOf(localMediaId)); + break; + } mFailedMediaIds.add(localMediaId); mUploadingMediaProgressMax.remove(localMediaId); } From a929e1fa2ad87e0e88af0d5bed5ca5993181b8a2 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Wed, 3 Jan 2024 14:08:24 -0500 Subject: [PATCH 02/15] build: Update Gutenberg ref --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 4bff5380072f..4ba3dd0a8601 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ ext { automatticRestVersion = '1.0.8' automatticStoriesVersion = '2.4.0' automatticTracksVersion = '3.3.0' - gutenbergMobileVersion = 'v1.110.0-alpha2' + gutenbergMobileVersion = '291d9bdd1d9e0b29a2911a5381115e10c626f81c' wordPressAztecVersion = 'v1.9.0' wordPressFluxCVersion = 'trunk-67afc3a620b4ad56b981d21637db6b3509b07ab6' wordPressLoginVersion = '1.10.0' From 04af69f84250addc6739c1eb8576ae7a61a35e0e Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Wed, 3 Jan 2024 14:29:56 -0500 Subject: [PATCH 03/15] build: Fix incorrect Gutenberg PR reference --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 4ba3dd0a8601..3e4a96b12861 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ ext { automatticRestVersion = '1.0.8' automatticStoriesVersion = '2.4.0' automatticTracksVersion = '3.3.0' - gutenbergMobileVersion = '291d9bdd1d9e0b29a2911a5381115e10c626f81c' + gutenbergMobileVersion = '19878-291d9bdd1d9e0b29a2911a5381115e10c626f81c' wordPressAztecVersion = 'v1.9.0' wordPressFluxCVersion = 'trunk-67afc3a620b4ad56b981d21637db6b3509b07ab6' wordPressLoginVersion = '1.10.0' From 578ee6a299b2c7b89970723da906a460cf8402db Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Wed, 3 Jan 2024 14:38:28 -0500 Subject: [PATCH 04/15] build: Fix incorrect Gutenberg PR reference --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 3e4a96b12861..7b11276fec40 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ ext { automatticRestVersion = '1.0.8' automatticStoriesVersion = '2.4.0' automatticTracksVersion = '3.3.0' - gutenbergMobileVersion = '19878-291d9bdd1d9e0b29a2911a5381115e10c626f81c' + gutenbergMobileVersion = '6491-291d9bdd1d9e0b29a2911a5381115e10c626f81c' wordPressAztecVersion = 'v1.9.0' wordPressFluxCVersion = 'trunk-67afc3a620b4ad56b981d21637db6b3509b07ab6' wordPressLoginVersion = '1.10.0' From b22021a996bed9be0fae8fc35d19ac02e6456e0f Mon Sep 17 00:00:00 2001 From: Derek Blank Date: Thu, 4 Jan 2024 15:11:12 +1000 Subject: [PATCH 05/15] Add discrete onMediaUploadPaused handler to media uploads when offline --- .../android/ui/posts/EditPostActivity.java | 5 +++++ .../android/ui/posts/editor/media/EditorMedia.kt | 4 ++++ .../android/editor/AztecEditorFragment.java | 4 ++++ .../editor/EditorMediaUploadListener.java | 1 + .../gutenberg/GutenbergEditorFragment.java | 16 ++++++++-------- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java index f24b5a06d88d..dc5520661d46 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java @@ -3678,6 +3678,11 @@ public void onMediaUploaded(OnMediaUploaded event) { return; } + if (!NetworkUtils.isNetworkAvailable(this)) { + mEditorMedia.onMediaUploadPaused(mEditorMediaUploadListener, event.media); + return; + } + // event for unknown media, ignoring if (event.media == null) { AppLog.w(AppLog.T.MEDIA, "Media event carries null media object, not recognized"); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/media/EditorMedia.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/media/EditorMedia.kt index c7cdff090bba..a51decbb1320 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/media/EditorMedia.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/media/EditorMedia.kt @@ -298,6 +298,10 @@ class EditorMedia @Inject constructor( listener.onMediaUploadFailed(media.id.toString(), error.type.name) } + fun onMediaUploadPaused(listener: EditorMediaUploadListener, media: MediaModel) = launch { + listener.onMediaUploadPaused(media.id.toString()) + } + sealed class AddMediaToPostUiState( val editorOverlayVisibility: Boolean, val progressDialogUiState: ProgressDialogUiState diff --git a/libs/editor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java b/libs/editor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java index 10f956090c97..408dfa744e45 100644 --- a/libs/editor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java +++ b/libs/editor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java @@ -1431,6 +1431,10 @@ public void onMediaUploadFailed(final String localMediaId, final String errorTyp mUploadingMediaProgressMax.remove(localMediaId); } + public void onMediaUploadPaused(final String localMediaId) { + mUploadingMediaProgressMax.remove(localMediaId); + } + @Override public void onVideoInfoRequested(final AztecAttributes attrs) { // VideoPress special case here diff --git a/libs/editor/src/main/java/org/wordpress/android/editor/EditorMediaUploadListener.java b/libs/editor/src/main/java/org/wordpress/android/editor/EditorMediaUploadListener.java index b87efdae8269..e37bbdc9b7c8 100644 --- a/libs/editor/src/main/java/org/wordpress/android/editor/EditorMediaUploadListener.java +++ b/libs/editor/src/main/java/org/wordpress/android/editor/EditorMediaUploadListener.java @@ -9,4 +9,5 @@ public interface EditorMediaUploadListener { void onMediaUploadProgress(String localId, float progress); void onMediaUploadFailed(String localId, String errorType); void onGalleryMediaUploadSucceeded(long galleryId, long remoteId, int remaining); + void onMediaUploadPaused(String toString); } diff --git a/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java b/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java index 7db18045d2c8..9e97a8bc7e2d 100644 --- a/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java +++ b/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java @@ -1488,14 +1488,14 @@ public void onMediaUploadProgress(final String localMediaId, final float progres @Override public void onMediaUploadFailed(final String localMediaId, String errorType) { - switch (errorType) { - case "CONNECTION_ERROR": - getGutenbergContainerFragment().mediaFileUploadPaused(Integer.valueOf(localMediaId)); - break; - default: - getGutenbergContainerFragment().mediaFileUploadFailed(Integer.valueOf(localMediaId)); - break; - } + getGutenbergContainerFragment().mediaFileUploadFailed(Integer.valueOf(localMediaId)); + mFailedMediaIds.add(localMediaId); + mUploadingMediaProgressMax.remove(localMediaId); + } + + @Override + public void onMediaUploadPaused(final String localMediaId) { + getGutenbergContainerFragment().mediaFileUploadPaused(Integer.valueOf(localMediaId)); mFailedMediaIds.add(localMediaId); mUploadingMediaProgressMax.remove(localMediaId); } From d8a7bffc6a35c54f55540ca63da0afede4611ec0 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Thu, 4 Jan 2024 09:31:39 -0500 Subject: [PATCH 06/15] refactor: Fix parameter name typo --- .../org/wordpress/android/editor/EditorMediaUploadListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/editor/src/main/java/org/wordpress/android/editor/EditorMediaUploadListener.java b/libs/editor/src/main/java/org/wordpress/android/editor/EditorMediaUploadListener.java index e37bbdc9b7c8..cd2f68e93fb6 100644 --- a/libs/editor/src/main/java/org/wordpress/android/editor/EditorMediaUploadListener.java +++ b/libs/editor/src/main/java/org/wordpress/android/editor/EditorMediaUploadListener.java @@ -9,5 +9,5 @@ public interface EditorMediaUploadListener { void onMediaUploadProgress(String localId, float progress); void onMediaUploadFailed(String localId, String errorType); void onGalleryMediaUploadSucceeded(long galleryId, long remoteId, int remaining); - void onMediaUploadPaused(String toString); + void onMediaUploadPaused(String localId); } From 8d468027d46ba11c27eedd460d0e563b0f09a786 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Thu, 4 Jan 2024 09:32:59 -0500 Subject: [PATCH 07/15] refactor: Annotate override of `onMediaUploadPaused` method Ensure the implementation adheres to the relevant interface. --- .../java/org/wordpress/android/editor/AztecEditorFragment.java | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/editor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java b/libs/editor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java index 408dfa744e45..01fd29a8c9a7 100644 --- a/libs/editor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java +++ b/libs/editor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java @@ -1431,6 +1431,7 @@ public void onMediaUploadFailed(final String localMediaId, final String errorTyp mUploadingMediaProgressMax.remove(localMediaId); } + @Override public void onMediaUploadPaused(final String localMediaId) { mUploadingMediaProgressMax.remove(localMediaId); } From 8ed6850ffcb4c5dcaa15ed589df5883ea7526dd3 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Thu, 4 Jan 2024 09:33:50 -0500 Subject: [PATCH 08/15] refactor: Remove unused `onMediaUploadFailed` error type parameter With the addition of a discrete paused method, we no longer utilize this parameter in the failed method. --- .../org/wordpress/android/ui/posts/editor/media/EditorMedia.kt | 2 +- .../java/org/wordpress/android/editor/AztecEditorFragment.java | 2 +- .../org/wordpress/android/editor/EditorMediaUploadListener.java | 2 +- .../android/editor/gutenberg/GutenbergEditorFragment.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/media/EditorMedia.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/media/EditorMedia.kt index a51decbb1320..82e0959e8c01 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/media/EditorMedia.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/media/EditorMedia.kt @@ -295,7 +295,7 @@ class EditorMedia @Inject constructor( } } analyticsTrackerWrapper.track(EDITOR_UPLOAD_MEDIA_FAILED, properties) - listener.onMediaUploadFailed(media.id.toString(), error.type.name) + listener.onMediaUploadFailed(media.id.toString()) } fun onMediaUploadPaused(listener: EditorMediaUploadListener, media: MediaModel) = launch { diff --git a/libs/editor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java b/libs/editor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java index 01fd29a8c9a7..3470d25327fd 100644 --- a/libs/editor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java +++ b/libs/editor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java @@ -1413,7 +1413,7 @@ public void onMediaUploadProgress(final String localMediaId, final float progres } @Override - public void onMediaUploadFailed(final String localMediaId, final String errorType) { + public void onMediaUploadFailed(final String localMediaId) { if (!isAdded() || mContent == null) { return; } diff --git a/libs/editor/src/main/java/org/wordpress/android/editor/EditorMediaUploadListener.java b/libs/editor/src/main/java/org/wordpress/android/editor/EditorMediaUploadListener.java index cd2f68e93fb6..298c9f0d9160 100644 --- a/libs/editor/src/main/java/org/wordpress/android/editor/EditorMediaUploadListener.java +++ b/libs/editor/src/main/java/org/wordpress/android/editor/EditorMediaUploadListener.java @@ -7,7 +7,7 @@ public interface EditorMediaUploadListener { void onMediaUploadReattached(String localId, float currentProgress); void onMediaUploadSucceeded(String localId, MediaFile mediaFile); void onMediaUploadProgress(String localId, float progress); - void onMediaUploadFailed(String localId, String errorType); + void onMediaUploadFailed(String localId); void onGalleryMediaUploadSucceeded(long galleryId, long remoteId, int remaining); void onMediaUploadPaused(String localId); } diff --git a/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java b/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java index 9e97a8bc7e2d..96bdc41a25c8 100644 --- a/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java +++ b/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java @@ -1487,7 +1487,7 @@ public void onMediaUploadProgress(final String localMediaId, final float progres } @Override - public void onMediaUploadFailed(final String localMediaId, String errorType) { + public void onMediaUploadFailed(final String localMediaId) { getGutenbergContainerFragment().mediaFileUploadFailed(Integer.valueOf(localMediaId)); mFailedMediaIds.add(localMediaId); mUploadingMediaProgressMax.remove(localMediaId); From ad1ca04bb4f9ec275b067cb7c282372bee01faf6 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Thu, 4 Jan 2024 09:47:54 -0500 Subject: [PATCH 09/15] feat: Aztec `onMediaUploadPaused` passes onto `onMediaUploadFailed` We do not plan to add paused media support to the Aztec editor. Therefore, it likely makes more sense for the `onMediaUploadPaused` implementation to merely invoke the existing `onMediaUploadFailed` method. --- .../java/org/wordpress/android/editor/AztecEditorFragment.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/editor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java b/libs/editor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java index 3470d25327fd..836c3e67a011 100644 --- a/libs/editor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java +++ b/libs/editor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java @@ -1433,7 +1433,8 @@ public void onMediaUploadFailed(final String localMediaId) { @Override public void onMediaUploadPaused(final String localMediaId) { - mUploadingMediaProgressMax.remove(localMediaId); + // Aztec does not leverage the paused media state, only the Gutenberg editor + onMediaUploadFailed(localMediaId); } @Override From 594f989cd3c15564fc101dbfa5c0eb08bd78fb5d Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Thu, 4 Jan 2024 09:50:56 -0500 Subject: [PATCH 10/15] feat: Only consider failed media uploads to be paused Without checking for an error, there may be a possibility that successfully uploaded media is marked as "paused." --- .../java/org/wordpress/android/ui/posts/EditPostActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java index dc5520661d46..2d1d900da88b 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java @@ -3678,7 +3678,7 @@ public void onMediaUploaded(OnMediaUploaded event) { return; } - if (!NetworkUtils.isNetworkAvailable(this)) { + if (event.isError() && !NetworkUtils.isNetworkAvailable(this)) { mEditorMedia.onMediaUploadPaused(mEditorMediaUploadListener, event.media); return; } From 00df84ca8802c17efed56bd74d874a408a2e6c2a Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Thu, 4 Jan 2024 09:54:18 -0500 Subject: [PATCH 11/15] feat: Track failed media upload event when pausing media uploads Even though we communicate a nuanced paused state to the user, we likely need to continue tracking this event as a failure, or consider adding a discrete pause analytic event. --- .../wordpress/android/ui/posts/EditPostActivity.java | 2 +- .../android/ui/posts/editor/media/EditorMedia.kt | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java index 2d1d900da88b..62a07d27fea8 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java @@ -3679,7 +3679,7 @@ public void onMediaUploaded(OnMediaUploaded event) { } if (event.isError() && !NetworkUtils.isNetworkAvailable(this)) { - mEditorMedia.onMediaUploadPaused(mEditorMediaUploadListener, event.media); + mEditorMedia.onMediaUploadPaused(mEditorMediaUploadListener, event.media, event.error); return; } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/media/EditorMedia.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/media/EditorMedia.kt index 82e0959e8c01..13d81127bc5a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/media/EditorMedia.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/media/EditorMedia.kt @@ -298,7 +298,15 @@ class EditorMedia @Inject constructor( listener.onMediaUploadFailed(media.id.toString()) } - fun onMediaUploadPaused(listener: EditorMediaUploadListener, media: MediaModel) = launch { + fun onMediaUploadPaused(listener: EditorMediaUploadListener, media: MediaModel, error: MediaError) = launch { + val properties: Map = withContext(bgDispatcher) { + analyticsUtilsWrapper + .getMediaProperties(media.isVideo, null, media.filePath) + .also { + it["error_type"] = error.type.name + } + } + analyticsTrackerWrapper.track(EDITOR_UPLOAD_MEDIA_FAILED, properties) listener.onMediaUploadPaused(media.id.toString()) } From b1f7e3b6c929861afdeebb1a79c40389c06129c7 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Thu, 4 Jan 2024 09:57:47 -0500 Subject: [PATCH 12/15] feat: When lacking connectivity, pause completed upload w/o remote URLs Based upon existing code, we should consider completed uploads lacking remote URLs to be failures. Therefore, we should apply the new pause state to this context. --- .../org/wordpress/android/ui/posts/EditPostActivity.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java index 62a07d27fea8..2e9973da3b35 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java @@ -3701,7 +3701,10 @@ public void onMediaUploaded(OnMediaUploaded event) { mEditorMedia.onMediaUploadError(mEditorMediaUploadListener, event.media, event.error); } else if (event.completed) { // if the remote url on completed is null, we consider this upload wasn't successful - if (TextUtils.isEmpty(event.media.getUrl())) { + if (TextUtils.isEmpty(event.media.getUrl()) && !NetworkUtils.isNetworkAvailable(this)) { + MediaError error = new MediaError(MediaErrorType.GENERIC_ERROR); + mEditorMedia.onMediaUploadPaused(mEditorMediaUploadListener, event.media, error); + } else if (TextUtils.isEmpty(event.media.getUrl())) { MediaError error = new MediaError(MediaErrorType.GENERIC_ERROR); mEditorMedia.onMediaUploadError(mEditorMediaUploadListener, event.media, error); } else { From 51d141b758a848368925198dd171ba532d2af86b Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Thu, 4 Jan 2024 15:12:21 -0500 Subject: [PATCH 13/15] docs: Add release note --- RELEASE-NOTES.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index f489c1d15557..fa3c1623ce76 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -1,5 +1,9 @@ *** PLEASE FOLLOW THIS FORMAT: [] [] +24.1 +----- +* [**] Image block media uploads display a custom error message when there is no internet connection [https://github.com/wordpress-mobile/WordPress-Android/pull/19878] + 24.0 ----- * [*] Filter media types when sharing files to the editor [https://github.com/wordpress-mobile/WordPress-Android/pull/19754] From b97dbeccb556b565249cfe6d2ab229ba9479d33a Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Thu, 4 Jan 2024 15:44:24 -0500 Subject: [PATCH 14/15] build: Update Gutenberg ref --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 2fdb7b4dba98..723a7fe87439 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ ext { automatticRestVersion = '1.0.8' automatticStoriesVersion = '2.4.0' automatticTracksVersion = '3.3.0' - gutenbergMobileVersion = '6491-291d9bdd1d9e0b29a2911a5381115e10c626f81c' + gutenbergMobileVersion = '6491-31ff640dc82d1c7224f6791e23a4456ca034d04e' wordPressAztecVersion = 'v1.9.0' wordPressFluxCVersion = 'trunk-67afc3a620b4ad56b981d21637db6b3509b07ab6' wordPressLoginVersion = '1.10.0' From e3ad26b92139e542c31c26bcef666db57604bea5 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Wed, 10 Jan 2024 09:31:04 -0500 Subject: [PATCH 15/15] build: Update Gutenberg ref --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 491972cf882f..6748767e4606 100644 --- a/build.gradle +++ b/build.gradle @@ -23,7 +23,7 @@ ext { automatticRestVersion = '1.0.8' automatticStoriesVersion = '2.4.0' automatticTracksVersion = '3.3.0' - gutenbergMobileVersion = '6491-31ff640dc82d1c7224f6791e23a4456ca034d04e' + gutenbergMobileVersion = 'v1.111.0-alpha1' wordPressAztecVersion = 'v1.9.0' wordPressFluxCVersion = '2.61.0' wordPressLoginVersion = '1.10.0'