strooooke / quickfit

QuickFit is an Android app which lets you add preconfigured workouts to Google Fit with a single click.
Apache License 2.0
14 stars 4 forks source link

Cannot start service in background #60

Closed strooooke closed 5 years ago

strooooke commented 5 years ago

Concerns:

strooooke commented 5 years ago

Some thinking out loud about the alarm situation:

Current architecture:

ScheduleEntry.COL_SHOW_NOTIFICATION has the following usages:

Desired state:

Note: when enqueuing work from any BroadcastReceiver, use goAsync, and register completion upon completion of the enqueue operation.

strooooke commented 5 years ago

We could:

Alright, on boot we look at all the schedule entries. For each one, we need to decide whether:

But, problem is: say we show the notification, deferred work enqueues the next alarm (for "in a week") and switches state to ON_DISPLAY. Notification gets cancelled. State switches to ACKNOWLEDGED. Device shuts down. Device boots up again, 1.5 weeks later. Expected state: notification for the new event is shown (from last week, not the one two weeks ago). But isn't.

So, that's not sufficient, we do need to keep info about the next planned alarm time too, so that we can do catch-up on boot.

How about the current schema?

strooooke commented 5 years ago

Note: need to reschedule notifications on ACTION_LOCALE_CHANGED (for properly localized texts). Edit: no, we don't! (Well, we could refresh the already-displaying notifications, but that's more of a luxury problem). Can do all localization in the AlarmReceiver, that's fine on the main thread.