Android-SimpleTimeTracker icon indicating copy to clipboard operation
Android-SimpleTimeTracker copied to clipboard

feat: Add REST API and Web UI for remote time tracking

Open av1m opened this issue 3 months ago β€’ 6 comments

πŸ“± 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?

  1. Code Reuse: Leverages existing WearCommunicationAPI - no duplicate business logic
  2. Consistency: Web UI and Wear OS behave identically
  3. Maintainability: Changes to core logic automatically work for both integrations
  4. Privacy: Local network only, no cloud services required
  5. Optional: Only in play flavor, doesn't affect base (F-Droid) build

πŸ“ Usage

  1. Install the app (play flavor)
  2. Find phone's IP address (Settings β†’ About β†’ IP Address)
  3. Open web/index.html in browser on computer
  4. Enter http://[phone-ip]:8080 and click "Connect"
  5. 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 play flavor (depends on Google Play Services components)

av1m avatar Oct 21 '25 11:10 av1m

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?

AnonMiraj avatar Nov 04 '25 23:11 AnonMiraj

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:

  1. Extract WearCommunicationAPI to a shared module (e.g., core or :feature_remote_api)
  2. Move web API files from app/src/play/ to app/src/base/ or the shared module
  3. 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!

av1m avatar Nov 05 '25 00:11 av1m

I'm really looking forward to this feature.

YIRU69 avatar Nov 09 '25 14:11 YIRU69

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 avatar Dec 30 '25 21:12 B-doi

@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 avatar Dec 31 '25 06:12 Razeeman

@Razeeman Any ETA for when the feature will be avalable, looking forward to it!

B-doi avatar Dec 31 '25 23:12 B-doi

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.

Razeeman avatar Jan 04 '26 08:01 Razeeman

This is amazing. Hope it will be added soon!!!

ironhak avatar Jan 06 '26 15:01 ironhak