Skip to content

Add multi-site support to Android demo app#155

Merged
oguzkocer merged 11 commits intotrunkfrom
allow-multiple-sites-in-android-demo-app
Jul 17, 2025
Merged

Add multi-site support to Android demo app#155
oguzkocer merged 11 commits intotrunkfrom
allow-multiple-sites-in-android-demo-app

Conversation

@oguzkocer
Copy link
Contributor

Similar to the iOS demo app, allows users to add and manage multiple WordPress sites alongside the bundled editor.

Changes

  • Multi-site configuration: Users can add remote WordPress sites via FAB button
  • Authentication flow: Implements WordPress Application Passwords authentication with auto-discovery
  • Site management: Tap to launch the editor, long-press to delete sites
  • Persistent storage: Added sites are saved and restored between app launches

Testing Instructions

  1. Add remote site: Tap the FAB (+) button and enter a WordPress site URL
  2. Authentication: App will auto-discover the site's API endpoints, then open a web view for login
  3. Login process: Enter WordPress credentials, authorize the app, and you'll be redirected back
  4. Site management: New site appears in the list. Tap to launch the editor, long-press to delete the site
  5. Bundled editor: Original bundled editor remains available at the top of the list

Requirements: WordPress sites must have the Application Passwords feature enabled (WordPress 5.6+ or Jetpack plugin).

…ing enabled

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@oguzkocer oguzkocer marked this pull request as ready for review July 17, 2025 00:59
@oguzkocer oguzkocer enabled auto-merge (squash) July 17, 2025 00:59
@oguzkocer oguzkocer requested a review from dcalhoun July 17, 2025 00:59
Copy link
Member

@dcalhoun dcalhoun left a comment

Choose a reason for hiding this comment

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

Thank you! The test plan succeeds for me. I successfully loaded both the bundled and remote editors.

I left a few comments for your consideration, but they are not blocking.

.setPlugins(true) // Enable plugins for remote editor
.setSiteURL(config.siteUrl)
.setSiteApiRoot(config.siteApiRoot)
.setSiteApiNamespace(arrayOf("wp/v2"))
Copy link
Member

Choose a reason for hiding this comment

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

Setting a namespace is applicable for WPCOM sites communicating through the WPCOM API. We do not need to set a namespace for the default wp/v2.

Suggested change
.setSiteApiNamespace(arrayOf("wp/v2"))
.setSiteApiNamespace(arrayOf())

defaultConfig {
applicationId = "com.example.gutenbergkit"
minSdk = 22
minSdk = 24
Copy link
Member

Choose a reason for hiding this comment

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

It seems that bumping to 24 broke loading the development server from an IP address on the development machine, that it may include tighter default security.

It seems that one now has to add an explicit entry for the IP in the network security configuration. Is there a better way to allow the development server to load?

<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">localhost</domain>
<domain includeSubdomains="true">10.0.0.2</domain>
</domain-config>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not something I am familiar with :( I've made this bump because wordpress-rs requires it, although I don't remember why.

Unless this is a major issue for you, I think it's fine to go with a temporary solution like the one you mentioned above. If it's major, I can look into it.

Copy link
Member

Choose a reason for hiding this comment

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

While annoying, it's not a blocker for my workflow; I can work around it.

The bigger concern is someone less familiar with the project encountering failed development server loads without knowledge of this workaround. Also, we don't want to commit one-off IP addresses to this configuration file. I'll try to find a solution soon.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, please let me know before spending any significant time on this. I'll double check that we need minSdk = 24 for wordpress-rs.

If you want, we can remove wordpress-rs, but I find having a proper authentication flow easier to work with than always having to figure out the authentication token, updating a config document etc. Having said that, I don't plan to work in this repo too much, so whatever works best for you is fine with me.

@oguzkocer oguzkocer merged commit 59692bb into trunk Jul 17, 2025
11 checks passed
@oguzkocer oguzkocer deleted the allow-multiple-sites-in-android-demo-app branch July 17, 2025 19:13
@dcalhoun
Copy link
Member

dcalhoun commented Jul 17, 2025

I forgot one thing: I noticed the WebViews appear to linger after closing the editor (visible in Chrome's chrome://inspect inspector). Is that expected?
lingering-web-views

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants