Skip to content

feat(android): add native block inserter#461

Draft
jkmassel wants to merge 2 commits intojkmassel/block-picker-flagfrom
jkmassel/android-block-picker
Draft

feat(android): add native block inserter#461
jkmassel wants to merge 2 commits intojkmassel/block-picker-flagfrom
jkmassel/android-block-picker

Conversation

@jkmassel
Copy link
Copy Markdown
Contributor

@jkmassel jkmassel commented Apr 22, 2026

Summary

Third of three stacked PRs for the native block inserter. Adds the Android-side handler for the showBlockInserter JavaScript bridge call set up in #463, gated by the enableNativeBlockInserter flag added in #464. GutenbergView renders a programmatic BottomSheetDialog internally — headless-into-library, so no Compose leaks into the Gutenberg library.

The dialog is a stub — flat list of section headers and tappable block rows. Icons, patterns, search, and richer layout will replace it in a follow-up PR.

Flow

bridge.js showBlockInserter → Android @JavascriptInterfaceBlockInserterPayload.fromJsonBlockInserterDialog (sections + blocks). Tapping a block fires window.blockInserter.insertBlock(id). Any dismiss — selection or swipe — fires window.blockInserter.onClose() so the JS picker state always resets. Bad payloads surface a Toast (from R.string.gbk_block_inserter_failure) so a broken tap isn't silent.

Test plan

  • make test-js — 135/135
  • ./gradlew :Gutenberg:test detekt :Gutenberg:lintDebug :app:compileDebugKotlin — BUILD SUCCESSFUL
  • Manually verified on a Pixel 9 Pro XL: toggle Enable Native Inserter → open editor → tap + → library sheet opens, tapping a block inserts + dismisses, reopening works on subsequent taps.
  • Reviewer: verify iOS behavior is unchanged. The structured body for iOS is preserved, but I haven't run this branch on iOS myself.

Related

Third of three stacked PRs:

Mirrors the iOS implementation under ios/Sources/GutenbergKit/Sources/Views/BlockInserter/.

@github-actions github-actions Bot added the [Type] Enhancement A suggestion for improvement. label Apr 22, 2026
@jkmassel jkmassel force-pushed the jkmassel/android-block-picker branch from 0c4794d to eece41e Compare April 22, 2026 21:04
@jkmassel jkmassel changed the title feat(android): native block inserter via listener API feat(android): add native block inserter Apr 22, 2026
@jkmassel jkmassel force-pushed the jkmassel/android-block-picker branch from 6b881ff to 05b3fd4 Compare April 22, 2026 23:11
@jkmassel jkmassel changed the base branch from trunk to jkmassel/block-picker-flag April 22, 2026 23:12
@jkmassel jkmassel marked this pull request as draft April 22, 2026 23:13
Adds a native bottom-sheet block inserter to Android, bringing it to
parity with the iOS SwiftUI sheet. Android takes the headless-into-
library route — `GutenbergView` renders a programmatic
`BottomSheetDialog` internally, so no Compose leaks into the Gutenberg
library.

Wires up a new `@JavascriptInterface showBlockInserter(String)` method
that decodes the payload added in the payload-model PR, shows the
dialog, and reflects selection + dismiss back to JS via
`window.blockInserter.insertBlock` / `onClose`. Bad payloads surface a
Toast so a broken tap isn't silent.

The dialog is a stub — flat list of section headers and tappable block
rows. Icons, patterns, search, and richer layout will replace it in a
follow-up PR.

Enabled via `EditorConfiguration.setEnableNativeBlockInserter(true)`
(added in the feature-flag PR).
Moves the two synthetic section fallbacks ("Most used", "Suggested")
and the parse-failure Toast out of the Kotlin source and into
`Gutenberg/src/main/res/values/strings.xml`. Adds `resourcePrefix =
"gbk_"` so AGP flags any future unprefixed library resource at lint
time, preventing collision with host-app resource ids.
@jkmassel jkmassel force-pushed the jkmassel/block-picker-flag branch from a11c583 to 32e096e Compare April 22, 2026 23:38
@jkmassel jkmassel force-pushed the jkmassel/android-block-picker branch from 05b3fd4 to 6d17fbe Compare April 22, 2026 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant