Skip to content

Migrate Remaining EditPostActivity Direct Launches to EditorLauncher #22120

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

Merged
merged 7 commits into from
Aug 13, 2025

Conversation

oguzkocer
Copy link
Contributor

@oguzkocer oguzkocer commented Aug 12, 2025

Follow up to #22111 to migrate the remaining EditPostActivity launches to use the EditorLauncher.

ShareIntentReceiverActivity Migration

Commit: 934ed82

Migrated share intents to use EditorLauncher and removed the reflection-like targetClass pattern from ShareAction enum.

Changes:

  • Replace shareAction.targetClass with explicit switch statement
  • Use EditorLauncher.getInstance().createEditorIntent() for SHARE_TO_POST
  • Add null checking for selectedSite

Testing:

  • Share text/media to WordPress → verify editor opens with content
  • Share media to Media Library → verify MediaBrowserActivity opens
  • Test single-site auto-share shortcut

AddQuickPressShortcutActivity Migration

Commit: dfb51a0

Extended EditorLauncherParams to support QuickPress shortcuts while preserving the original site resolution behavior where shortcuts store site IDs and resolve them at launch time.

Changes:

  • Add EditorLauncherSiteSource sealed class for compile-time type safety
  • Add Builder.forSite() and Builder.forQuickPressBlogId() factory methods
  • Update EditorLauncher to handle both site source types
  • Migrate AddQuickPressShortcutActivity to use Builder.forQuickPressBlogId()

Testing:

  • Create QuickPress home screen shortcuts → verify they launch editor correctly
  • Test shortcuts with different sites → verify site resolution works at launch time

UploadUtils Migration

Commit: ed06a15

Migrated the "Write Post" action that appears in snackbars after successful media uploads to use EditorLauncher.

Changes:

  • Use EditorLauncher.getInstance().createEditorIntent() for write post action
  • Pass insertMedia parameter with uploaded media files
  • Preserve isPage(false) for new post creation

Testing:

  • Upload media files (images/videos) → verify success snackbar shows "Write Post" action
  • Tap "Write Post" → verify editor opens with uploaded media inserted
  • Test with multiple media files → verify all media is included

PostUploadNotifier Migration

Commit: 8e2fdd3

Migrated the "Write Post" action in upload completion notifications to use EditorLauncher.

Changes:

  • Use EditorLauncher.getInstance().createEditorIntent() for notification write post action
  • Pass insertMedia parameter with uploaded media files
  • Preserve isPage(false) for new post creation

Testing:

  • Upload media files → verify upload completion notification appears
  • Tap "Write Post" action in notification → verify editor opens with uploaded media inserted
  • Test notification PendingIntent behavior → verify proper activity launch

@oguzkocer oguzkocer added this to the 26.2 milestone Aug 12, 2025
@oguzkocer oguzkocer requested a review from Copilot August 12, 2025 19:34
Copilot

This comment was marked as outdated.

… targetClass

Replace direct EditPostActivity Intent creation with EditorLauncher for share intents
and eliminate the reflection-like targetClass pattern in ShareAction enum.

Changes:
- Migrate SHARE_TO_POST to use EditorLauncher.getInstance().createEditorIntent()
- Remove ShareAction.targetClass property and use explicit switch statement
- Add null checking for selectedSite with appropriate error handling
- Preserve original media sharing behavior via Intent.EXTRA_STREAM

This addresses the review comment about remaining direct EditPostActivity launches
and improves the ShareAction design by removing the awkward targetClass property.
…serving site resolution behavior

Migrate AddQuickPressShortcutActivity to use EditorLauncher while maintaining the original
behavior where shortcuts store site IDs and resolve them to SiteModels at launch time.

Changes:
- Add EditorLauncherSiteParameter sealed class supporting EditorLauncherSite(SiteModel) or QuickPressBlogId(Int)
- Replace EditorLauncherParams.site with siteParameter field for compile-time type safety
- Add Builder.forSite() and Builder.forQuickPressBlogId() factory methods
- Update EditorLauncher.addBasicExtras() to handle both site parameter types
- Migrate AddQuickPressShortcutActivity to use Builder.forQuickPressBlogId()
- Update all existing Builder usages in ActivityLauncher and ShareIntentReceiverActivity

This preserves original QuickPress behavior where EditPostActivity resolves site IDs
at launch time, while routing through EditorLauncher for analytics and consistency.
…ia upload

Replace direct EditPostActivity Intent creation with EditorLauncher for the "Write Post"
action that appears in snackbars after successful media uploads.

Changes:
- Use EditorLauncher.getInstance().createEditorIntent() for write post action
- Pass insertMedia parameter with uploaded media files
- Preserve isPage(false) for new post creation
- Maintain existing Intent flags for proper activity handling

This ensures consistent editor routing and analytics tracking for posts created
after media upload while preserving the original media insertion behavior.
…t creation

Replace direct EditPostActivity Intent creation with EditorLauncher for the "Write Post"
action that appears in upload completion notifications.

Changes:
- Use EditorLauncher.getInstance().createEditorIntent() for notification write post action
- Pass insertMedia parameter with uploaded media files
- Preserve isPage(false) for new post creation
- Maintain existing Intent flags and notification action setup

This ensures consistent editor routing and analytics tracking for posts created
from upload notifications while preserving the original media insertion behavior.
@oguzkocer oguzkocer force-pushed the migrate-remaining-edit-post-activity-launches branch from 8e2fdd3 to cf7c1f6 Compare August 12, 2025 19:43
@oguzkocer oguzkocer requested a review from Copilot August 12, 2025 19:45
Copilot

This comment was marked as outdated.

@oguzkocer oguzkocer force-pushed the migrate-remaining-edit-post-activity-launches branch from 84c0290 to 8c473d7 Compare August 12, 2025 19:47
@oguzkocer oguzkocer requested a review from Copilot August 12, 2025 19:48
Copilot

This comment was marked as outdated.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Aug 12, 2025

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
Versionpr22120-f9ba6e5
Commitf9ba6e5
Direct Downloadwordpress-prototype-build-pr22120-f9ba6e5.apk
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Aug 12, 2025

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
Versionpr22120-f9ba6e5
Commitf9ba6e5
Direct Downloadjetpack-prototype-build-pr22120-f9ba6e5.apk
Note: Google Login is not supported on these builds.

Update test to expect 'siteParameter' field instead of 'site' field
after the EditorLauncherParams refactor to use sealed class.

The test reflection was failing because the field name changed from
'site' to 'siteParameter' in the data class.
Improve naming throughout EditorLauncher ecosystem to better convey intent:

Changes:
- EditorLauncherSiteParameter → EditorLauncherSiteSource
- EditorLauncherSite → DirectSite (clearer than generic Site)
- QuickPressBlogId → QuickPressSiteId (consistent naming)
- siteParameter field → siteSource field
- quickPressBlogId property → siteId property

The "siteSource" name better conveys that this parameter represents the source
of site information (either direct SiteModel or site ID to be resolved later),
rather than being just another generic parameter.

Addresses Copilot suggestion for more meaningful naming.
@oguzkocer oguzkocer requested a review from Copilot August 12, 2025 20:29
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR completes the migration from direct EditPostActivity launches to using the EditorLauncher pattern across the WordPress Android codebase. The primary goal is to centralize editor launching logic and improve type safety through the use of EditorLauncherParams.

  • Migrates remaining EditPostActivity direct launches in share intents, QuickPress shortcuts, upload notifications, and upload snackbars
  • Extends EditorLauncherParams to support QuickPress shortcuts with runtime site resolution
  • Removes reflection-like patterns in favor of explicit switch statements

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
EditorLauncherParams.kt Adds sealed class for site sources and factory methods for different launch scenarios
EditorLauncher.kt Updates intent creation to handle both direct site models and QuickPress blog IDs
ShareIntentReceiverActivity.java Migrates share intents to use EditorLauncher with explicit switch statement
ShareIntentReceiverFragment.java Removes reflection-like targetClass pattern from ShareAction enum
AddQuickPressShortcutActivity.java Migrates QuickPress shortcuts to use EditorLauncher with blog ID resolution
UploadUtils.java Migrates "Write Post" snackbar action to use EditorLauncher
PostUploadNotifier.java Migrates upload notification "Write Post" action to use EditorLauncher
ActivityLauncher.java Updates all existing EditorLauncher usages to use new factory methods
EditorLauncherTest.kt Updates test to reflect site source parameter changes

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

@oguzkocer oguzkocer marked this pull request as ready for review August 12, 2025 20:33
@oguzkocer oguzkocer enabled auto-merge (squash) August 12, 2025 20:33
Copy link

codecov bot commented Aug 12, 2025

Codecov Report

❌ Patch coverage is 0% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.43%. Comparing base (37a5943) to head (f9ba6e5).
⚠️ Report is 3 commits behind head on trunk.

Files with missing lines Patch % Lines
...ava/org/wordpress/android/ui/ActivityLauncher.java 0.00% 9 Missing ⚠️
...rdpress/android/ui/uploads/PostUploadNotifier.java 0.00% 7 Missing ⚠️
.../org/wordpress/android/ui/uploads/UploadUtils.java 0.00% 7 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            trunk   #22120   +/-   ##
=======================================
  Coverage   39.43%   39.43%           
=======================================
  Files        2149     2149           
  Lines      101872   101872           
  Branches    15604    15604           
=======================================
  Hits        40177    40177           
  Misses      58126    58126           
  Partials     3569     3569           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nbradbury nbradbury self-assigned this Aug 13, 2025
Copy link
Contributor

@nbradbury nbradbury left a comment

Choose a reason for hiding this comment

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

Changes look good and all testing steps passed :shipit:

@oguzkocer oguzkocer merged commit 5ed9439 into trunk Aug 13, 2025
28 checks passed
@oguzkocer oguzkocer deleted the migrate-remaining-edit-post-activity-launches branch August 13, 2025 13:29
@dcalhoun
Copy link
Member

@oguzkocer it appears this introduced a regression where the GutenbergKit editor content is unexpectedly discarded when toggling the OS appearance. This problem does not occur for Gutenberg Mobile.

Screen_Recording_20250813_150159_Jetpack.Pre-Alpha.mp4

@oguzkocer
Copy link
Contributor Author

@oguzkocer it appears this introduced a regression where the GutenbergKit editor content is unexpectedly discarded when toggling the OS appearance. This problem does not occur for Gutenberg Mobile.

@dcalhoun Thank you for reporting the issue! This is not a regression in this PR, because I can reproduce the issue in 26.1-rc-1. I think it's likely related to the recently introduced GutenbergKitViewModel change. I am looking into it.

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