manager: Refactor WebUI to Compose & Rename enableInsets to enableEdgeToEdge#3190
Merged
Conversation
This commit refactors the WebUI implementation to use Compose, moving away from the legacy View-based approach to improve state management and UI consistency. Key changes: - Migrated `WebUIActivity` to use Compose, delegating UI rendering to `WebUIScreen`. - Implemented `WebUIScreen` to host the WebView via `AndroidView` and handle JavaScript dialogs (Alert, Confirm, Prompt) using Compose dialogs. - Extracted WebView initialization and configuration logic into `WebViewHelper`. - Updated `WebViewInterface` to interact with the new state holder. - Improved window insets handling using Compose's `WindowInsets` and `snapshotFlow` to dynamically update CSS variables. - Updated `AndroidManifest.xml` to handle configuration changes manually, preventing Activity recreation. Signed-off-by: u9521 <63995396+u9521@users.noreply.github.com>
- Rename `enableInsets` to `enableEdgeToEdge` in both JS library and Android WebViewInterface to align with modern Android terminology. - Update README documentation and type definitions. - Bump js package version to 3.0.2. Signed-off-by: u9521 <63995396+u9521@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the WebUIActivity from the legacy Android View system to Jetpack Compose, improving maintainability and modernizing the codebase. The refactor includes renaming the JavaScript API enableInsets to enableEdgeToEdge to align with standard Android terminology.
Changes:
- Migrated WebUIActivity to Jetpack Compose with a clean separation of concerns (WebUIState for state management, WebViewHelper for setup, WebUIScreen for UI composition)
- Replaced native WebView dialogs with Compose-based dialogs and improved insets handling with dynamic CSS injection via WindowInsets.safeDrawing
- Renamed the JavaScript API from
ksu.enableInsetstoksu.enableEdgeToEdgewith corresponding updates in package.json, index.js, index.d.ts, and README.md - Added configChanges handling to AndroidManifest.xml to prevent activity recreation during configuration changes
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| WebViewInterface.kt | Refactored constructor to accept WebUIState instead of individual parameters; renamed enableInsets to enableEdgeToEdge; improved code quality with var-to-val conversions |
| WebViewHelper.kt | New file containing WebView setup logic with module validation, WebChromeClient/WebViewClient configuration, and insets handling |
| WebUIState.kt | New file defining state management for WebUI with event handling and proper cleanup via dispose() |
| WebUIScreen.kt | New file implementing Compose UI with AndroidView integration, dialog handling, lifecycle management, and back navigation |
| WebUIActivity.kt | Simplified to a clean Compose implementation with MainContent composable handling state and navigation |
| Insets.kt | Added js property for dynamic CSS variable injection when insets change |
| AndroidManifest.xml | Added comprehensive configChanges attribute to handle configuration changes without activity recreation |
| js/package.json | Version bump to 3.0.2 |
| js/index.js | Renamed enableInsets to enableEdgeToEdge |
| js/index.d.ts | Updated TypeScript declarations for renamed API |
| js/README.md | Updated documentation for enableEdgeToEdge with clearer explanation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Collaborator
|
I think we need an alias for old insets api to keep combatility. |
- Move WebView URL loading logic from `update` block to `factory` block to ensure consistent initialization. - Refactor `OnLayoutChangeListener` attachment to prevent redundant triggers. - Ensure `webView` instance is assigned to `webUIState` before adding the Javascript interface. - Remove unused `Log` import. Signed-off-by: u9521 <63995396+u9521@users.noreply.github.com>
Contributor
Author
我觉得可能没有必要,一是直接调用的情况比较少,一般都是请求了css就自动 0 padding。而且是在上个release后加入的, |
KOWX712
approved these changes
Feb 2, 2026
bklynali
pushed a commit
to bklynali/BK-KSU
that referenced
this pull request
Feb 2, 2026
…eToEdge (tiann#3190) refactors the WebUIActivity to use Jetpack Compose, replacing the legacy View system. Javascript Interface API renaming enableInsets to enableEdgeToEdge. Changes: 1. Migration to Jetpack Compose * Replaced `FrameLayout` and standard WebView handling with a Composable-based architecture (`WebUIScreen`). * Replaced native WebView dialogs (`onJsAlert`, `onJsConfirm`, `onJsPrompt`) with Compose-based dialogs. * Updated Insets handling: Now uses `WindowInsets.safeDrawing` (includes system bars, display cutouts, and IME/keyboard). * Dynamic CSS Injection: Changes to insets (e.g., keyboard appearing) now dynamically update CSS variables (`--safe-area-inset-*`) via JS. * support in-app WebView history navigation via the system back gesture. 2. API Renaming * **Renamed:** `ksu.enableInsets` -> `ksu.enableEdgeToEdge` (JS). * Aligns with standard Android terminology (`androidx.activity.enableEdgeToEdge`). 3. Configuration Handling * Added `configChanges` handling to `AndroidManifest.xml`. * The Activity (and WebView) no longer recreates on screen rotation, multi-window mode toggling, or window resizing, preventing state loss. --------- Signed-off-by: u9521 <63995396+u9521@users.noreply.github.com>
selfmusing
pushed a commit
to selfmusing/USlenreK
that referenced
this pull request
Feb 2, 2026
…eToEdge (tiann#3190) refactors the WebUIActivity to use Jetpack Compose, replacing the legacy View system. Javascript Interface API renaming enableInsets to enableEdgeToEdge. Changes: 1. Migration to Jetpack Compose * Replaced `FrameLayout` and standard WebView handling with a Composable-based architecture (`WebUIScreen`). * Replaced native WebView dialogs (`onJsAlert`, `onJsConfirm`, `onJsPrompt`) with Compose-based dialogs. * Updated Insets handling: Now uses `WindowInsets.safeDrawing` (includes system bars, display cutouts, and IME/keyboard). * Dynamic CSS Injection: Changes to insets (e.g., keyboard appearing) now dynamically update CSS variables (`--safe-area-inset-*`) via JS. * support in-app WebView history navigation via the system back gesture. 2. API Renaming * **Renamed:** `ksu.enableInsets` -> `ksu.enableEdgeToEdge` (JS). * Aligns with standard Android terminology (`androidx.activity.enableEdgeToEdge`). 3. Configuration Handling * Added `configChanges` handling to `AndroidManifest.xml`. * The Activity (and WebView) no longer recreates on screen rotation, multi-window mode toggling, or window resizing, preventing state loss. --------- Signed-off-by: u9521 <63995396+u9521@users.noreply.github.com>
selfmusing
pushed a commit
to selfmusing/USlenreK
that referenced
this pull request
Feb 2, 2026
…eToEdge (tiann#3190) refactors the WebUIActivity to use Jetpack Compose, replacing the legacy View system. Javascript Interface API renaming enableInsets to enableEdgeToEdge. Changes: 1. Migration to Jetpack Compose * Replaced `FrameLayout` and standard WebView handling with a Composable-based architecture (`WebUIScreen`). * Replaced native WebView dialogs (`onJsAlert`, `onJsConfirm`, `onJsPrompt`) with Compose-based dialogs. * Updated Insets handling: Now uses `WindowInsets.safeDrawing` (includes system bars, display cutouts, and IME/keyboard). * Dynamic CSS Injection: Changes to insets (e.g., keyboard appearing) now dynamically update CSS variables (`--safe-area-inset-*`) via JS. * support in-app WebView history navigation via the system back gesture. 2. API Renaming * **Renamed:** `ksu.enableInsets` -> `ksu.enableEdgeToEdge` (JS). * Aligns with standard Android terminology (`androidx.activity.enableEdgeToEdge`). 3. Configuration Handling * Added `configChanges` handling to `AndroidManifest.xml`. * The Activity (and WebView) no longer recreates on screen rotation, multi-window mode toggling, or window resizing, preventing state loss. --------- Signed-off-by: u9521 <63995396+u9521@users.noreply.github.com>
u9521
added a commit
to u9521/KernelSU
that referenced
this pull request
Feb 3, 2026
…eToEdge (tiann#3190) refactors the WebUIActivity to use Jetpack Compose, replacing the legacy View system. Javascript Interface API renaming enableInsets to enableEdgeToEdge. Changes: 1. Migration to Jetpack Compose * Replaced `FrameLayout` and standard WebView handling with a Composable-based architecture (`WebUIScreen`). * Replaced native WebView dialogs (`onJsAlert`, `onJsConfirm`, `onJsPrompt`) with Compose-based dialogs. * Updated Insets handling: Now uses `WindowInsets.safeDrawing` (includes system bars, display cutouts, and IME/keyboard). * Dynamic CSS Injection: Changes to insets (e.g., keyboard appearing) now dynamically update CSS variables (`--safe-area-inset-*`) via JS. * support in-app WebView history navigation via the system back gesture. 2. API Renaming * **Renamed:** `ksu.enableInsets` -> `ksu.enableEdgeToEdge` (JS). * Aligns with standard Android terminology (`androidx.activity.enableEdgeToEdge`). 3. Configuration Handling * Added `configChanges` handling to `AndroidManifest.xml`. * The Activity (and WebView) no longer recreates on screen rotation, multi-window mode toggling, or window resizing, preventing state loss. --------- Signed-off-by: u9521 <63995396+u9521@users.noreply.github.com>
KOWX712
pushed a commit
to KOWX712/KernelSU
that referenced
this pull request
Feb 3, 2026
…eToEdge (tiann#3190) refactors the WebUIActivity to use Jetpack Compose, replacing the legacy View system. Javascript Interface API renaming enableInsets to enableEdgeToEdge. Changes: 1. Migration to Jetpack Compose * Replaced `FrameLayout` and standard WebView handling with a Composable-based architecture (`WebUIScreen`). * Replaced native WebView dialogs (`onJsAlert`, `onJsConfirm`, `onJsPrompt`) with Compose-based dialogs. * Updated Insets handling: Now uses `WindowInsets.safeDrawing` (includes system bars, display cutouts, and IME/keyboard). * Dynamic CSS Injection: Changes to insets (e.g., keyboard appearing) now dynamically update CSS variables (`--safe-area-inset-*`) via JS. * support in-app WebView history navigation via the system back gesture. 2. API Renaming * **Renamed:** `ksu.enableInsets` -> `ksu.enableEdgeToEdge` (JS). * Aligns with standard Android terminology (`androidx.activity.enableEdgeToEdge`). 3. Configuration Handling * Added `configChanges` handling to `AndroidManifest.xml`. * The Activity (and WebView) no longer recreates on screen rotation, multi-window mode toggling, or window resizing, preventing state loss. --------- Signed-off-by: u9521 <63995396+u9521@users.noreply.github.com>
KOWX712
added a commit
to KOWX712/ksu-webui-demo
that referenced
this pull request
Feb 4, 2026
- since KernelSU 32294 - ref: tiann/KernelSU#3190
KOWX712
added a commit
to KOWX712/kernelsu-alt
that referenced
this pull request
Feb 4, 2026
enableInsets is renamed to enableEdgeToEdge since KernelSU 32265. Old api is kept and marked as deprecated for compatibility, there is no plan to remove it currently. ref: tiann/KernelSU#3190
KOWX712
added a commit
to KOWX712/kernelsu-alt
that referenced
this pull request
Feb 4, 2026
enableInsets is renamed to enableEdgeToEdge since KernelSU 32265. Old api is kept and marked as deprecated for compatibility, there is no plan to remove it currently. ref: tiann/KernelSU#3190
KOWX712
added a commit
to KOWX712/kernelsu-alt
that referenced
this pull request
Feb 4, 2026
enableInsets is renamed to enableEdgeToEdge since KernelSU 32265. Old api is kept and marked as deprecated for compatibility, there is no plan to remove it currently. ref: tiann/KernelSU#3190
KOWX712
added a commit
to KOWX712/kernelsu-alt
that referenced
this pull request
Feb 4, 2026
enableInsets is renamed to enableEdgeToEdge since KernelSU 32265. Old api is kept and marked as deprecated for compatibility, there is no plan to remove it currently. ref: tiann/KernelSU#3190
KOWX712
added a commit
to KOWX712/kernelsu-alt
that referenced
this pull request
Feb 4, 2026
enableInsets is renamed to enableEdgeToEdge since KernelSU 32265. Old api is kept and marked as deprecated for compatibility, there is no plan to remove it currently. ref: tiann/KernelSU#3190
KOWX712
added a commit
to KOWX712/KsuWebUIStandalone
that referenced
this pull request
Feb 8, 2026
KOWX712
added a commit
to KOWX712/KsuWebUIStandalone
that referenced
this pull request
Feb 8, 2026
KOWX712
added a commit
to KOWX712/KsuWebUIStandalone
that referenced
this pull request
Mar 11, 2026
KOWX712
added a commit
to KOWX712/KsuWebUIStandalone
that referenced
this pull request
Mar 11, 2026
KOWX712
added a commit
to KOWX712/KsuWebUIStandalone
that referenced
this pull request
Apr 14, 2026
KOWX712
added a commit
to KOWX712/FolkPatch
that referenced
this pull request
May 29, 2026
The WebUI failed to load CSS/JS assets because the WebView was configured and loadUrl was called inside the AndroidView factory during Compose composition, which blocked the main thread and called loadUrl before the WebView had valid dimensions. Refactor to match the KernelSU pattern: - Create WebView and configure WebViewAssetLoader on IO dispatcher - Build WebView fully on Main thread outside AndroidView - Defer loadUrl until width > 0 && height > 0 via layout listener - related: - tiann/KernelSU#2952 - tiann/KernelSU#3083 - tiann/KernelSU#3126 - tiann/KernelSU#3190 Signed-off-by: KOWX712 <leecc0503@gmail.com>
matsuzaka-yuki
pushed a commit
to LyraVoid/FolkPatch
that referenced
this pull request
May 30, 2026
#151) The WebUI failed to load CSS/JS assets because the WebView was configured and loadUrl was called inside the AndroidView factory during Compose composition, which blocked the main thread and called loadUrl before the WebView had valid dimensions. Refactor to match the KernelSU pattern: - Create WebView and configure WebViewAssetLoader on IO dispatcher - Build WebView fully on Main thread outside AndroidView - Defer loadUrl until width > 0 && height > 0 via layout listener - related: - tiann/KernelSU#2952 - tiann/KernelSU#3083 - tiann/KernelSU#3126 - tiann/KernelSU#3190 Signed-off-by: KOWX712 <leecc0503@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
refactors the WebUIActivity to use Jetpack Compose, replacing the legacy View system. Javascript Interface API renaming enableInsets to enableEdgeToEdge.
Changes:
FrameLayoutand standard WebView handling with a Composable-based architecture (WebUIScreen).onJsAlert,onJsConfirm,onJsPrompt) with Compose-based dialogs.WindowInsets.safeDrawing(includes system bars, display cutouts, and IME/keyboard).--safe-area-inset-*) via JS.ksu.enableInsets->ksu.enableEdgeToEdge(JS).androidx.activity.enableEdgeToEdge).configChangeshandling toAndroidManifest.xml.