feat: Add REST API and Web UI for remote time tracking
π± What does this PR do?
Adds a local REST API server and web interface that allows users to track time from their computer browser while keeping data synced with the Android app in real-time.
This addresses the sync and web UI feature request from issue #103.
π₯ A screen recording that show the feature
β¨ Features Added
REST API Server
- Lightweight HTTP server using NanoHTTPD
-
Reuses existing Wear OS API (
WearCommunicationAPI) - zero duplicate code - Local network only - no cloud dependency, privacy-focused
- Auto-starts on app launch (can be disabled)
Web Interface
- π View all activities with colors and icons
- βΆοΈ Start/Stop tracking with one click
- β±οΈ Live timers with real-time countdown
- π Statistics dashboard showing today's activity
- π Activity history with recent records
- π Dark mode support
- π± Responsive design for mobile and desktop
- π Auto-refresh every 2 seconds
π§ Technical Implementation
API Endpoints
- GET /api/activities # List all activities
- GET /api/running # Currently running timers
- POST /api/start/:id # Start activity
- POST /api/stop/:id # Stop activity
Files Added/Modified
New files:
-
app/src/play/java/.../api/WebApiAdapter.kt- REST API implementation -
app/src/play/java/.../api/WebApiModule.kt- Dependency injection -
web/index.html- Sample of WebApp (we just use API)
Modified files:
-
app/src/main/java/.../TimeTrackerApp.kt- Start API server on app launch -
app/src/main/AndroidManifest.xml- Add INTERNET permission
π― Why This Approach?
-
Code Reuse: Leverages existing
WearCommunicationAPI- no duplicate business logic - Consistency: Web UI and Wear OS behave identically
- Maintainability: Changes to core logic automatically work for both integrations
- Privacy: Local network only, no cloud services required
-
Optional: Only in
playflavor, doesn't affectbase(F-Droid) build
π Usage
- Install the app (play flavor)
- Find phone's IP address (Settings β About β IP Address)
- Open
web/index.htmlin browser on computer - Enter
http://[phone-ip]:8080and click "Connect" - Start tracking from your computer! π
π Security Considerations
- Local network only - not exposed to internet
- No authentication (for now) - assumes trusted network
- Same WiFi required - phone and computer must be on same network
- Future enhancement: Add optional API key authentication
π Known Limitations
- Web UI is read-only for tags (cannot create/edit tags from web)
- Statistics calculated from running activities (not full history)
- If the app is closed, the server not work
- No WebSocket support (uses polling instead)
- Only available in
playflavor (depends on Google Play Services components)
Looks really cool! Iβve wanted to try implementing something similar for a long time. Reusing the core logic from WearOS is very smart. Would it be possible to enable this in the base FβDroid build by refactoring so both Wear OS and the web UI depend on a shared base implementation? Or is it heavily dependent on Google services?
Yes @AnonMiraj, this can definitely work in the F-Droid build!
The web UI doesn't actually depend on Google services; it uses NanoHTTPD (standalone library) and local networking only. The note about Google Play Services dependency might be misleading.
To enable F-Droid support:
-
Extract
WearCommunicationAPIto a shared module (e.g.,coreor:feature_remote_api) -
Move web API files from
app/src/play/toapp/src/base/or the shared module -
Keep WearOS-specific code (actual Google Play Services deps) in
app/src/play/
Result:
- Base (F-Droid): Core API + Web UI
- Play: Base + WearOS
I'm happy to refactor this PR to support both flavors if desired, or we can merge as-is (play-only) and handle it later. Let me know your preference @Razeeman!
I'm really looking forward to this feature.
Explain what I am meant to do to get the sync going like I am a grandma who got this app from the appstore and runs win 10 on their computer.
I looked at the recording and I do not understand a single thing that you did. I want to sync the app to the PC and hopefully to my Samsung Tab 10 FE.
Typing "web/index.html" into my browser did nothing, tried https:// and http:// , neither of those did anything. Looking more into it seems to be a file I am meant to get from somewhere.
@B-doi Hello! This feature is not ready at the moment. There will be some sort of instructions available, when it will be ready.
@Razeeman Any ETA for when the feature will be avalable, looking forward to it!
No ETA unfortunately. This is mainly a mobile app without internet permissions for data privacy, so sync features or web versions are somewhat out of scope at the moment.
This is amazing. Hope it will be added soon!!!