Skip to content

feat(android): add configurable network access setting#144

Open
lucletoffe wants to merge 3 commits intoActivityWatch:masterfrom
lucletoffe:feature/configurable-host
Open

feat(android): add configurable network access setting#144
lucletoffe wants to merge 3 commits intoActivityWatch:masterfrom
lucletoffe:feature/configurable-host

Conversation

@lucletoffe
Copy link
Copy Markdown

@lucletoffe lucletoffe commented Feb 24, 2026

Summary

Adds a user-facing "Allow network access" toggle so the embedded server can optionally bind to 0.0.0.0 instead of 127.0.0.1, letting other devices on the local network connect to the ActivityWatch API.

Off by default. Enabling shows a security warning dialog.

Changes

Settings UI:

  • New SettingsActivity with a Material switch, accessible from the action bar Settings button (which previously showed a "not yet implemented" snackbar)
  • Security warning dialog on enable, explaining the API has no authentication
  • Toast prompting the user to restart the app for the change to take effect

Plumbing:

  • AWPreferences: new isNetworkAccessEnabled / setNetworkAccessEnabled methods
  • RustInterface: startServer() and startServerTask() now accept a host parameter
  • MainActivity: reads the preference on startup, passes "0.0.0.0" or "127.0.0.1" to the server
  • strings.xml: setting labels and warning text
  • AndroidManifest.xml: registered SettingsActivity

aw-server-rust submodule:

Security

The toggle is opt-in with a clear warning dialog. The warning mentions:

  • The ActivityWatch API has no authentication
  • Anyone on the same network can read and modify activity data
  • Only recommended on trusted networks (e.g., a VPN like Tailscale)

Notes

  • The setting requires an app restart to take effect (the server starts once in onCreate). I kept it simple rather than adding server restart logic.
  • CI will fail until the aw-server-rust PR is merged and the submodule pointer is updated to a commit that exists upstream. Happy to rebase once that's in.
  • Screenshots pending — I don't have an Android build environment set up yet, will add them once I can build the APK.

Closes #121, relates to #107


This is my first PR on the project. If there's anything I should do differently (commit structure, code style, approach), let me know — happy to adjust.


Important

Adds a user-configurable network access setting to allow the embedded server to bind to all network interfaces, with a security warning and requiring app restart.

  • Behavior:
    • Adds a toggle in SettingsActivity to allow network access, binding the server to 0.0.0.0 instead of 127.0.0.1.
    • Displays a security warning dialog when enabling network access.
    • Requires app restart for changes to take effect.
  • Settings and Preferences:
    • AWPreferences: Adds isNetworkAccessEnabled and setNetworkAccessEnabled methods.
    • MainActivity: Reads network access preference and starts server with appropriate host.
  • Server Interface:
    • RustInterface: Updates startServer() and startServerTask() to accept a host parameter.
  • UI and Resources:
    • Adds SettingsActivity to AndroidManifest.xml.
    • Updates strings.xml with new labels and warning messages.
    • Creates activity_settings.xml layout for settings UI.
  • Submodule Update:
    • Updates aw-server-rust submodule to include JNI changes for host parameter.

This description was created by Ellipsis for c68cd3d. You can customize this summary. It will automatically update as commits are pushed.

Add a Settings screen with a toggle to allow network access to the
embedded ActivityWatch server. When enabled, the server binds to
0.0.0.0 instead of 127.0.0.1, allowing other devices on the local
network to connect.

The setting is off by default. Enabling it shows a security warning
dialog explaining the risks (no authentication on the API, data
exposed to the network). The change takes effect on app restart.

This also wires up the previously-unimplemented Settings action bar
button to open the new Settings screen.

The aw-server-rust submodule is updated to accept a host parameter
in the JNI startServer() call instead of using a hardcoded address.

Closes ActivityWatch#121, closes ActivityWatch#107
Copy link
Copy Markdown

@ellipsis-dev ellipsis-dev Bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed everything up to c68cd3d in 10 seconds. Click for details.
  • Reviewed 222 lines of code in 8 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.

Workflow ID: wflow_KwTYz1tLqtlRe2VO

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Feb 24, 2026

Greptile Summary

This PR adds a user-configurable "Allow network access" setting that enables the embedded ActivityWatch server to bind to 0.0.0.0 instead of 127.0.0.1, allowing devices on the local network to connect to the API.

Key changes:

  • Added new SettingsActivity with Material switch for network access toggle
  • Security warning dialog shown when enabling, clearly explaining lack of authentication
  • Preference stored in AWPreferences with secure default (disabled)
  • Server host parameter passed through RustInterface.startServerTask() to native code
  • Settings button in action bar now opens the new settings screen
  • Requires app restart for changes to take effect (documented in toast message)

Implementation quality:

  • Follows existing code patterns and Android conventions
  • Security-conscious design with opt-in behavior and prominent warnings
  • Clean separation of concerns between UI, preferences, and server initialization
  • WebView correctly continues using 127.0.0.1 for local connections while server binds to 0.0.0.0 when enabled

Confidence Score: 5/5

  • Safe to merge - well-implemented security feature with proper warnings and secure defaults
  • Clean implementation following Android best practices, secure by default with opt-in behavior, thorough security warnings, and proper separation of concerns. No logical errors or security vulnerabilities found.
  • No files require special attention

Important Files Changed

Filename Overview
mobile/src/main/java/net/activitywatch/android/AWPreferences.kt Added network access preference methods with secure defaults
mobile/src/main/java/net/activitywatch/android/MainActivity.kt Reads preference and passes host to server, opens SettingsActivity from action bar
mobile/src/main/java/net/activitywatch/android/RustInterface.kt Added host parameter to startServer methods with localhost default
mobile/src/main/java/net/activitywatch/android/SettingsActivity.kt New settings screen with network access toggle and security warning dialog

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User clicks Settings button] --> B[SettingsActivity opens]
    B --> C{Network access<br/>switch toggled?}
    C -->|Enable| D[Show security warning dialog]
    C -->|Disable| E[Save preference: false]
    D -->|User clicks Enable| F[Save preference: true]
    D -->|User cancels| G[Revert switch to off]
    F --> H[Show restart notice toast]
    E --> H
    H --> I[User restarts app]
    I --> J[MainActivity.onCreate]
    J --> K{Check preference:<br/>isNetworkAccessEnabled?}
    K -->|true| L[host = 0.0.0.0]
    K -->|false| M[host = 127.0.0.1]
    L --> N[RustInterface.startServerTask]
    M --> N
    N --> O[Native startServer called<br/>with host parameter]
    O --> P{Binding address}
    P -->|0.0.0.0| Q[Server accepts<br/>external connections]
    P -->|127.0.0.1| R[Server localhost only]
Loading

Last reviewed commit: c68cd3d

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

8 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

j-standfast added a commit to j-standfast/aw-android that referenced this pull request May 7, 2026
…led upstream

PR ActivityWatch#144 wired R.id.action_settings (action-bar overflow) to launch
SettingsActivity. But the action bar's Toolbar is commented out in
app_bar_main.xml (the AppBarLayout block at lines 10-22 is wrapped in
an XML comment), so R.menu.main never displays. The Settings entry
point we cherry-picked is unreachable in the running app — confirmed
by sideload test on the Pixel 10 Pro.

The original PR author admitted to never building the APK, which
explains why this slipped past review.

Fix: surface SettingsActivity through the existing navigation drawer
instead. Repoint "Misc → Settings" at SettingsActivity (the natural
spot for Android-native app settings), and add a separate
"Server settings" item to preserve the old web-UI route to
http://127.0.0.1:5600/#/settings/.

Leaves R.menu.main wired to SettingsActivity too — if someone ever
re-enables the toolbar, the action-bar entry point lights up for
free. No reason to remove it.

Refs QLI-555.
j-standfast added a commit to j-standfast/aw-android that referenced this pull request May 7, 2026
… nav

Upstream commented out the Toolbar in app_bar_main.xml (lines 10-22 of
the file were wrapped in <!-- -->). With no toolbar there's no system
action bar, no hamburger button, and no R.menu.main display surface.
On modern Android (11+, especially GrapheneOS) the gesture-nav
left-edge swipe is intercepted as the system back gesture, so the
DrawerLayout's edge-pull is unreachable too — the navigation drawer
becomes effectively invisible.

Confirmed on Pixel 10 Pro / GrapheneOS: even with our SettingsActivity
correctly registered and routed from R.id.nav_settings, the user had
no way to reach the drawer at all.

Fix: uncomment the AppBarLayout/Toolbar block, switch the toolbar
background from hardcoded #FFFFFF to ?attr/colorPrimary so it picks up
the theme, and wire it up in MainActivity.onCreate via
setSupportActionBar + ActionBarDrawerToggle. Reuses the existing
navigation_drawer_open/close strings already in strings.xml.

Now: hamburger top-left opens the drawer, drawer shows
Home/Activity/Raw Data + Misc → Settings/Server settings/Share/
Report bugs. Action bar overflow also lights up R.menu.main, so the
PR-ActivityWatch#144 action_settings entry point becomes reachable as a bonus.

Refs QLI-555.
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.

Option to change host address

1 participant