WorkCount
An Android time-tracking app built with Kotlin and Jetpack Compose that deducts breaks automatically, produces weekly and monthly reports, and later grew an AI assistant that calls tools on its own.
Log when work starts, when it ends and how long the breaks were, then find out how much was actually done. I needed it, so I wrote it.
What I built
- Records: clock-in and clock-out times with any number of breaks in between, each carrying a reason, a pause time and a resume time.
- Effective-hours calculation: the core logic. Breaks are clipped to the work interval, overlapping breaks are merged before being deducted, and shifts crossing midnight still add up — producing effective minutes and break minutes for the day.
- Reports: weekly and monthly summaries, with Monday as the start of the week, showing effective time and break count per day, plus a heatmap of long-term logging density.
- Calendar integration: reads upcoming events from the device calendar and raises a reminder dialog.
- Notifications: a nudge on days with no record, and weekly / monthly report pushes.
- The assistant (an AI agent): backed by DeepSeek, but not plain chat — it carries a set of tools and can look up data, backfill records and read the calendar itself.
- Settings: the API key is stored encrypted with
security-crypto, alongside a password-encrypted export that produces a.wcbdata file and a PDF report.
The assistant: from chat to tool use
This is where the biggest change happened. It started as a chat box that needed its data stuffed into the prompt. Now it runs a tool-calling loop with six senses:
| Tool | What it does |
|---|---|
now | Current time, to anchor “today” and “this week” |
query_work_records | Day-by-day work records |
query_stats | Aggregates: totals, period-over-period, break rankings |
save_work_record | Backfill a day |
query_calendar | Read upcoming device calendar events |
get_device_status | Device state |
Some deliberate trade-offs:
- Only the always-relevant context goes in the prompt (current time, whether today has a record); anything deep is fetched by tool on demand. Stuffing everything in costs tokens and buries the point.
- Aggregate questions are forced through the stats tool rather than letting the model add up daily records itself, which it gets wrong.
- Backfilling only works for days with no record yet. When a day already has one the tool returns an error, and the model is told to explain why and send the user to the records screen rather than retry.
- If the calendar cannot be read, say so — inventing a schedule or a meeting is never allowed.
- The persona is constrained too: talk like a person, no “how may I help you today”; when someone has been working late, acknowledge it before giving the conclusion, without getting sentimental or lecturing.
The pet: Xiaolemi
At the bottom of the assistant screen there is a pixel character who wanders around on her own. The art comes from a desktop-pet sprite pack, with 9 actions (idle, run left and right, wave, smug, jump, fail, wait, draw continuously, think). She walks somewhere random while idle, and she also shows up in the missed-log reminder dialog.
She is deliberately simple: she has no state machine of her own — the ViewModel pushes her what to do. That way the pet’s animation and the conversation state never disagree.
Stack
Kotlin + Jetpack Compose (Material 3) + WorkManager + kotlinx.serialization, with a paper-like off-white palette.
Tests
The hour calculation and the AI logic both have unit tests, with separate coverage for the edge cases: crossing midnight, breaks outside the work interval, and overlapping breaks.