Skip to content

fix(ui): apply in-app Appearance theme to Auth and Sync screens - #382

Open
TimeToBuildBob wants to merge 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:fix/native-settings-follow-inapp-theme
Open

TimeToBuildBob wants to merge 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:fix/native-settings-follow-inapp-theme

Conversation

@TimeToBuildBob

Copy link
Copy Markdown
Contributor

Problem

On master, Sync Settings and API Authentication follow the device night mode. The dashboard Appearance setting (Light / Dark / System) lives in WebView localStorage and never reached those native screens.

Reporter confirmation on #300: flash is gone on the 2026-10-26 master artifact, but those two screens still ignore the in-app theme.

Change

  • The theme hook reports the raw light/dark/auto setting via Android.reportThemeSetting.
  • Persist it in AWPreferences.
  • AuthSettingsActivity and SyncSettingsActivity call applyPersistedWebUiNightMode() before super.onCreate, mapping:
    • Dark → MODE_NIGHT_YES
    • Light → MODE_NIGHT_NO
    • System/auto → MODE_NIGHT_FOLLOW_SYSTEM
  • Do not change the process-wide setDefaultNightMode (that recreates MainActivity / WebView).

Onboarding stays light-only.

Testing

  • WebUiThemeTest: setting → AppCompat night-mode mapping; hook contains reportThemeSetting.
  • NativeScreenThemeTest: both screens still use AppTheme.FollowNight and apply the persisted mode before super.onCreate.
  • WebUIFragmentTest: bridge delivers the stored setting independently of exports.
  • ./gradlew :mobile:testStandardDebugUnitTest --tests net.activitywatch.android.WebUiThemeTest --tests net.activitywatch.android.NativeScreenThemeTest --tests net.activitywatch.android.fragments.WebUIFragmentTest → 44 tests, 0 failures.

This is not a physical-device or published-release check. Issue #300 stays open until the screens are verified with an explicit Light/Dark override against the opposite device mode.

Refs #300

Sync Settings and API Authentication used AppTheme.FollowNight with the
process default of MODE_NIGHT_FOLLOW_SYSTEM, so they followed the device
even when the dashboard Appearance setting was Light or Dark (ActivityWatch#300).

Persist localStorage.theme from the WebView hook and set each screen's
local night mode from that setting before super.onCreate. System/auto
still follows the device.

Git-Session-Id: 2a5ce4f1-0de9-5694-86eb-830365dae7c9
@greptile-apps

greptile-apps Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change affects the appearance of two native settings screens.

The PR appears safe to merge, with a non-blocking gap in tests for the screens' actual colors.

Findings

  1. P2 Screen colors remain untested ▶

Summary

Makes API Authentication and Sync Settings follow the dashboard's saved Appearance choice.

  • Auth and Sync screens follow the dashboard’s Appearance setting.

No blocking defect was found. The new tests should also check the screens' actual colors against an opposite device setting.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["WebView Appearance choice"] --> B["Android.reportThemeSetting"]
  B --> C["AWPreferences"]
  C --> D["applyPersistedWebUiNightMode"]
  D --> E["AuthSettingsActivity"]
  D --> F["SyncSettingsActivity"]
Loading

Reviews (1) · Last reviewed commit: "fix(ui): apply in-app Appearance theme t..." · Reviewed by Greptile

Comment on lines +21 to +24
assert(source.contains("applyPersistedWebUiNightMode()")) { activity }
assert(
source.indexOf("applyPersistedWebUiNightMode()") < source.indexOf("super.onCreate"),
) { "$activity must apply the in-app theme before super.onCreate" }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Screen colors remain untested

The new tests check mode constants, callback delivery, and source text, but never check whether a saved Appearance choice changes either screen's actual colors. A broken preference-to-screen connection could leave these tests passing.

Add an activity test that saves dark against a light device setting, then tests the reverse. Check resources.configuration and the screen background before and after recreation.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@TimeToBuildBob

TimeToBuildBob commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 AI code review

Adds persistence of the web UI Appearance setting in AWPreferences and reports that setting through Android.reportThemeSetting. AuthSettingsActivity and SyncSettingsActivity now apply a local AppCompat night mode before super.onCreate. Updates theme documentation and adds assertions for normalization, night-mode mapping, activity initialization order, and bridge callbacks.

Safe to merge — no P0/P1 findings

Confidence 5/5

✅ No findings. The diff looks correct to me on this pass.

Files changed (9) — the diff as I read it
  • mobile/src/main/java/net/activitywatch/android/AWPreferences.kt — Adds getWebUiTheme() and setWebUiTheme() using the normalized webUiTheme preference.
  • mobile/src/main/java/net/activitywatch/android/AuthSettingsActivity.kt — Calls applyPersistedWebUiNightMode() before super.onCreate.
  • mobile/src/main/java/net/activitywatch/android/SyncSettingsActivity.kt — Calls applyPersistedWebUiNightMode() before super.onCreate.
  • mobile/src/main/java/net/activitywatch/android/WebUiTheme.kt — Adds theme normalization, AppCompat night-mode mapping, and an activity extension; extends the JavaScript hook to report the stored Appearance setting.
  • mobile/src/main/java/net/activitywatch/android/WindowInsets.kt — Updates followNightMode documentation to describe activity night mode and the persisted Appearance setting.
  • mobile/src/main/java/net/activitywatch/android/fragments/WebUIFragment.kt — Adds WebAppInterface.reportThemeSetting() and wires its callback to AWPreferences.setWebUiTheme().
  • mobile/src/test/java/net/activitywatch/android/NativeScreenThemeTest.kt — Adds source assertions that both settings activities apply the persisted theme before super.onCreate.
  • mobile/src/test/java/net/activitywatch/android/WebUiThemeTest.kt — Adds assertions for reportThemeSetting, theme normalization, and AppCompat night-mode mappings.
  • mobile/src/test/java/net/activitywatch/android/fragments/WebUIFragmentTest.kt — Adds a test that reportThemeSetting forwards dark and auto to the configured callback.

Reviewed a35207312942 · panel: codex:gpt-6.1-sol · subscription engine · 24s · about this reviewer

Maintainer commands

@TimeToBuildBob review (own line) — fresh review · @TimeToBuildBob fix — a worker acts on the findings. Once per comment; 👀 = received.

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.

1 participant