Repository navigation
fix(ui): initialize WebView background from system night mode to prevent first-paint flash - #363
TimeToBuildBob wants to merge 1 commit into
Conversation
…ent first-paint flash Before this change, WebUIFragment created its WebView with the default white background. The JS theme hook (ANDROID_THEME_HOOK_JS) only set the correct colour after onPageFinished, leaving a white flash visible during startup and each fresh drawer navigation in dark mode. Set the background immediately at WebView creation using the system night mode as the pre-load approximation. The JS hook still corrects it after onPageFinished reads localStorage.theme, so explicit Light/Dark overrides are unaffected. Introduces initialWebViewBackgroundRes() in WebUiTheme — a pure function that picks chrome_dark or chrome_light based on Configuration.uiMode, tested in WebUiThemeTest. Closes ActivityWatch#300 (pending device verification — see issue) Git-Session-Id: 67c1dcbe-e031-4889-8f5c-3f7071249702
|
|
Greptile found no actionable issues on This only initializes the blank WebView surface. It does not verify the document's first painted frame or eliminate a saved-theme/system-theme mismatch during loading. #300 stays open until startup and drawer navigation are verified in an Android build with System dark/light and explicit Light/Dark controls; this PR still needs maintainer review/merge. |
|
CI-green and mergeable (Greptile 5/5) — waiting only on a maintainer click. This PR is ready to merge, but the bot has pull-only access to this repo and can't self-merge — surfacing it here so it isn't lost. The monitoring loop will stop re-flagging it now that this note is posted. |
🤖 AI code reviewAdds initialWebViewBackgroundRes() in WebUiTheme.kt to map system night mode to chrome_dark/chrome_light, and calls setBackgroundColor() in WebUIFragment.onCreateView() before the page loads to avoid a white flash. Adds a unit test for the new function. Safe to merge — no P0/P1 findingsConfidence 5/5 ✅ No findings. The diff looks correct to me on this pass. Files changed (3) — the diff as I read it
Reviewed Maintainer commands
|
Problem
Startup and fresh drawer navigation (Activity, Raw Data, Dashboard Settings) show a white flash in dark mode. The reporter on #300 confirmed this after #301 fixed theme selection.
Root cause:
WebUIFragment.onCreateView()creates the WebView with its default white background. The JS theme hook (ANDROID_THEME_HOOK_JS) only sets the correct colour afteronPageFinished, leaving the white surface visible for the entire page-load window.Fix
Set
myWebView.setBackgroundColor()immediately at WebView creation using the system night mode as the pre-load approximation. The existing JS hook still corrects the colour afteronPageFinishedreadslocalStorage.theme, so explicit Light and Dark overrides are unaffected.Introduces
initialWebViewBackgroundRes()inWebUiTheme.kt— a pure function that mapsConfiguration.UI_MODE_NIGHT_YES/NO→R.color.chrome_dark/chrome_light, tested inWebUiThemeTest.Testing
WebUiThemeTest.initialWebViewBackgroundResFollowsSystemNightModecovers the new function.Closes #300 (pending device verification)