RS Post Settings: Device gallery as featured image source#22690
RS Post Settings: Device gallery as featured image source#22690
Conversation
Replace Toast with Compose Snackbar for inline error messages with retry actions, add pull-to-refresh support, show "Saving..." label alongside the spinner, display "Not Set" placeholder for empty status, and improve accessibility with content descriptions for password toggle and featured image placeholder. Extract shared error utilities from PostRsListViewModel into PostRsErrorUtils for reuse across both list and settings screens. Add unit tests for PostRsSettingsViewModel. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Preserve unsaved edits when refreshing post from server - Remove unreachable snackbar when site is null (activity finishes immediately) - Fix PullToRefreshBox content indentation - Remove redundant offline mocks in refresh tests - Rename misleading test name for status selection - Add test for save-online sets isSaving Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract preserveEdits() helper to shorten refreshPost() below the 60-line detekt limit, and remove empty line after opening brace in test class. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add navigationBarsPadding to SnackbarHost so snackbars aren't obscured by the system navigation bar. Wrap ErrorContent in a centered Box so the error message displays in the center of the screen instead of at the top. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add fillMaxWidth and TextAlign.Center to the ErrorContent on the term selection screen so the network error message is properly centered horizontally. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The network error snackbar shown when saving in airplane mode was missing an actionLabel and onAction callback, so no Retry button appeared. Add both so the user can retry saving after reconnecting. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Set the snackbar action color to MaterialTheme.colorScheme.primary so the Retry text on snackbars matches the primary color used by the Retry button on the error empty state. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…race condition When disabling airplane mode and immediately tapping Retry, Android may not have re-established connectivity yet, causing a spurious network error. Now the save always proceeds to the API call, which handles network errors naturally via its catch block using PostRsErrorUtils.friendlyErrorMessage(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use BackHandler(onBack=) instead of wrapping lambda
- Use ?.let { } ?: Modifier for conditional click modifiers
- Replace PostApiException with RuntimeException
- Inline isAuthError wrapper in PostRsListViewModel
- Remove status bar hiding to fix PTR triggering on system bar pull
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace RuntimeException with PostApiRequestException to fix TooGenericExceptionThrown detekt violations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
On self-hosted sites, a new WpApiClient was created for every API call (5 instantiations just to open post settings). Cache self-hosted clients in WpApiClientProvider (mirroring the existing WP.com pattern), add a per-site client cache in PostRsRestClient, and use a lazy property in PostRsSettingsViewModel to reuse the same client across fetch and save. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Now that WpApiClientProvider caches self-hosted clients, the per-site client cache in PostRsRestClient is redundant — remove it. Also remove the now-unused site parameters from fetchPost() and savePost() in the ViewModel, and replace shadowed locals with simple null guards. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…eption, remove unused methods Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Show hero image shimmer and placeholder rows while loading instead of a titled app bar with a centered spinner. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Extract shared HeroOverlay composable to deduplicate gradient and back button between loading skeleton and hero layout - Inline statusResId variable - Remove unreachable site null guards in ViewModel - Remove extra blank line in WpApiClientProvider Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Allow choosing a featured image from the device gallery in addition to the WP Media Library. Device picks are copied to a temp file and uploaded via the wordpress-rs media API before being set as the featured image. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…e options Replace the single "Change" menu item with "Choose from WP Media" and "Choose from device" options in the featured image dropdown. The placeholder (no image set) now shows the same dropdown menu instead of jumping straight to the picker. Each option launches its own dedicated picker without confusing source-switching toolbars. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Generated by 🚫 Danger |
WordPress/src/main/java/org/wordpress/android/ui/postsrs/PostRsSettingsActivity.kt
Fixed
Show fixed
Hide fixed
WordPress/src/main/java/org/wordpress/android/ui/postsrs/PostRsSettingsViewModel.kt
Fixed
Show fixed
Hide fixed
|
|
|
|
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## trunk #22690 +/- ##
==========================================
- Coverage 37.61% 37.58% -0.04%
==========================================
Files 2272 2273 +1
Lines 118379 118477 +98
Branches 16370 16382 +12
==========================================
+ Hits 44531 44532 +1
- Misses 70196 70293 +97
Partials 3652 3652 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ce-featured-image # Conflicts: # WordPress/src/main/java/org/wordpress/android/ui/postsrs/PostRsSettingsViewModel.kt # WordPress/src/main/java/org/wordpress/android/ui/postsrs/screens/PostRsSettingsScreen.kt
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ce-featured-image
|
Overall, it looks and works well. What do you think about the following points?
|
The temp file created by copyUriToTempFile() was never cleaned up, causing orphan files to accumulate in the cache directory. Add a finally block to delete the temp file after upload completes or fails. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The temp file for device-picked featured images was always created with a .jpg extension regardless of actual image type. Use ContentResolver and MimeTypeMap to determine the correct extension, falling back to .jpg when the MIME type is unavailable. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move copyUriToTempFile and its Context dependency out of the ViewModel into a dedicated injectable helper. This improves testability and removes the @ApplicationContext from the ViewModel. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update PostRsSettingsViewModelTest to match the ViewModel constructor change from the UriToFileMapper extraction commit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…lename for upload title Delete the temp file if the stream copy fails so partial files don't linger. Query the ContentResolver for the original display name and use it as the media upload title instead of the temp file name. Also fix import ordering in PostRsSettingsActivity. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Narrow catch from Exception to IOException to satisfy detekt's TooGenericExceptionCaught rule. Add @Suppress("Recycle") to getDisplayName since the cursor is already closed by .use {}. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@adalpari Those are all good points and I've fixed them. |
Handle the Boolean return value of File.delete() by logging a warning when deletion fails. Extract the duplicated "No site selected" string into a companion object constant. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
adalpari
left a comment
There was a problem hiding this comment.
Thank you for the fixes! LGTM!





Description
Adds the ability to pick a featured image from the device gallery (in addition to the existing WP Media Library option). When a device image is selected, it is uploaded to the site's media library and then set as the featured image.
Key changes:
MediaCreateParams, and sets the returned media ID as the featured imageTesting instructions
Featured image from WP Media:
Featured image from device:
Remove featured image:
featured.mp4