This is a log of stuff I did w/ one of my random pet projects, it’s not terribly interesting and is mostly just so I can get into the habit of writing more. You have been warned.

Continuing work on my new/old project GetDisciplined, I added routine playing which, in addition to the ability to define routines, makes the app usable:

A screenshot of GetDisciplined playing a routine with a task named Exercise near the beginning of the task's time limit

A screenshot of GetDisciplined playing a routine with a task named Exercise near the middle of the task's time limit

(Ok, I know I’m mixing flat design principles w/ material design principles in ^^, but I’m not a UX designer so don’t yell at me pls!!!)

It’s a pretty simple feature, running a clock per task, letting users pause/play tasks as well as navigate the routine. In a browser this would just be a matter of using setInterval() and updating elapsed times every time a user interacts with the player. On mobile, however, it’s a bit more complex.

Mobile apps differ from desktop/web apps in a lot of ways (of course), but one of the more interesting differences is how power usage becomes a concern. We use lots of apps on our phone simultaneously and having those apps run constantly in the background consumes power. To make phone batteries last longer mobile OSes will stop apps at will, say if the user switches to another one, or the phone goes to sleep.

GetDisciplined is intended to be run on mobile as having to run back and forth to a stationary desktop while in the middle of a routine makes the app far less useful, so it needs to take this into account. If we set a timer to continuously update the elapsed time of a task, and the phone it’s running on goes to sleep, the timer will just stop running until the phone wakes up again. So if you start on a task and finish 10 minutes later and your phone isn’t constantly on, the app wouldn’t report it taking 10 minutes.

To make sure the timer could resume even if the app had been turned off, I stored the state of the timer in the SQLite database the app uses. Specifically, in addition to the total elapsed time for a task, the time the timer was last activated (as in the time the user pressed play for a task or moved to the next task) is stored in the database. So when the app starts and we see there was a routine playing, we can just resume it and calculate the elapsed time of the active task as Date.now() - the last time the task was played.


Anyway, these are the two major pieces of this simple app, which means the app is functional. Except for the fact that it does not yet run on my phone. So that’s the next thing I’ll be working on. Android support in tauri appears to be available, but I don’t think it’s really in a working state, which I’m sure will make this an interesting experience.