Skip to content

Comments

Move editor loading into the library#326

Open
jkmassel wants to merge 6 commits intotrunkfrom
refactor/android-loading-ui
Open

Move editor loading into the library#326
jkmassel wants to merge 6 commits intotrunkfrom
refactor/android-loading-ui

Conversation

@jkmassel
Copy link
Contributor

What?

Moves the editor loading UI from #316 into its own PR

Why?

The smaller change is easier to validate.

How?

Adds loading UI – if you test with the sample app, you'll see that it was removed from the activity and added to the view.

jkmassel and others added 6 commits February 18, 2026 10:37
GutenbergView previously extended WebView directly and delegated all
loading UI (progress bar, spinner, error states) to consumers via the
EditorLoadingListener interface. This forced every app embedding the
editor to implement its own loading UI boilerplate.

This change makes GutenbergView extend FrameLayout instead, containing
an internal WebView plus overlay views for loading states:

- EditorProgressView (progress bar + label) during dependency fetching
- ProgressBar (circular/indeterminate) during WebView initialization
- EditorErrorView (new) for error states

The view manages its own state transitions with 200ms fade animations,
matching the iOS EditorViewController pattern. The EditorLoadingListener
interface is removed entirely — consumers no longer need loading UI code.

Changes:
- GutenbergView: WebView -> FrameLayout with internal WebView child
- New EditorErrorView for displaying load failures
- Delete EditorLoadingListener (no longer needed)
- Simplify demo EditorActivity by removing ~90 lines of loading UI
- Update tests to use editorWebView accessor for WebView properties
- Delete unused activity_editor.xml layout

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Cancel in-flight view animations in onDetachedFromWindow

Prevents withEndAction callbacks from firing on detached views
if the editor is closed mid-animation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Remove unused LoadingState enum from GutenbergView

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Remove unused ASSET_LOADING_TIMEOUT_MS constant from GutenbergView

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…edFromWindow

These two listeners were not being nulled out during teardown,
inconsistent with all other listener cleanup in the same method.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jkmassel jkmassel requested a review from dcalhoun February 18, 2026 19:26
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.

Tested well for me. I left a few suggestions, but non are blocking. Rebasing this atop the latest trunk branch should resolve the CI failures.

Comment on lines +211 to +214
// Initialize the asset loader now that context is available
assetLoader = WebViewAssetLoader.Builder()
.addPathHandler("/assets/", AssetsPathHandler(context))
.build()
Copy link
Member

Choose a reason for hiding this comment

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

This seems duplicative of assetLoader initialization on lines 91-93. Should we remove one?

this.dependencies = dependencies

// FAST PATH: Dependencies were provided - load immediately
showSpinnerPhase()
Copy link
Member

Choose a reason for hiding this comment

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

This may be duplicative since showSpinnerPhase() is invoked within loadEditor(). Remove it?

}
gravity = Gravity.CENTER
TextViewCompat.setTextAppearance(this, android.R.style.TextAppearance_Material_Subhead)
text = "Failed to load editor"
Copy link
Member

Choose a reason for hiding this comment

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

For a future PR, we should likely localize strings like this in a manner similar to iOS.

public final class EditorLocalization {
/// This is designed to be overridden by the host app to provide translations.
public static var localize: (EditorLocalizableString) -> String = { key in
switch key {
case .showMore: "Show More"
case .showLess: "Show Less"
case .search: "Search"
case .insertBlock: "Insert Block"
case .failedToInsertMedia: "Failed to insert media"
case .patterns: "Patterns"
case .noPatternsFound: "No Patterns Found"
case .insertPattern: "Insert Pattern"
case .patternsCategoryUncategorized: "Uncategorized"
case .patternsCategoryAll: "All"
case .loadingEditor: "Loading Editor"
case .editorError: "Editor Error"
}
}
/// Convenience subscript for accessing localized strings.
public static subscript(key: EditorLocalizableString) -> String {
localize(key)
}
}

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