LibreShift / red-moon

Android screen filter app for night time phone use.
GNU General Public License v3.0
642 stars 80 forks source link

After a time zone change, Red Moon enables the filter according to the old time zone #235

Closed axelsimon closed 5 years ago

axelsimon commented 5 years ago

Hi! When going from one time zone to another one further west (ie, going one hour "back in time") I discovered my Red Moon filter kicked in at 23:15 (new time) which corresponds to 00:15 in my original time zone.

Red Moon is set to enable the filter at 00:15.

I expected the filter to be activated at 00:15 when the phone's clock read 00:15, not 23:15 :)

Red Moon version: 3.3.3 (F-Droid) Android version; 5.1 (cm 12) Xperia z3

Hope this helps!

smichel17 commented 5 years ago

I'll check to see if Android has a way to get notified of time zone changes when they happen. Otherwise, this is probably not worth the time to fix, since it's a rare occurrence and with the current implementation it should automatically correct itself for tomorrow, anyway.

smichel17 commented 5 years ago

Looks like it is possible to do this by adding a broadcast receiver that listens for ACTION_TIMEZONE_CHANGED.

seond commented 5 years ago

What we need to do when receiving ACTION_TIMEZONE_CHANGED is mostly same as what we're doing on receiving ACTION_BOOT_COMPLETED except there might be a pair of schedules to cancel. So I'm thinking of taking out filterIsOnPrediction to some common module to use for different events/lifecycles. Any thoughts or recommendations? Thanks.

smichel17 commented 5 years ago

Brainstorm: I can think of a couple options (ordered from pretty to quick and dirty) —

I'd probably accept any of those, though the last is pretty hacky. If I were doing it myself I'd probably do the middle one, and refactor to the first if it turns out there's other places we want to use filterIsOnPrediction.

seond commented 5 years ago

I liked the middle one two. Just created a PR. Thanks!