TiddlyTools/Time/CountDown uses a once-per-second interrupt-driven “ticker” to repeatedly subtract “1” from the remaining countdown time, until it reaches 0 and invokes the desired action(s). As you’ve noted, on Android devices, this interrupt-driven ticker is only triggered when the phone and the browser app are active. Thus, the countdown is effectively “paused” when the phone is in standby mode. Unfortunately, changing this behavior would require an extensive re-write of the CountDown logic.
Fortunately, there may be an alternative, by using TiddlyTools/Time/Alarms instead of TiddlyTools/Time/Countdown. Unlike the CountDown code, the Alarms code works by comparing a defined alarm date and time with the current date and time, so it doesn’t need to “tick” once-per-second in order to detect when the desired action(s) should be invoked.
Give this a try:
First, import the following tiddlers from It's About Time! — TiddlyTools: "Small Tools for Big Ideas!" (tm)
- TiddlyTools/Time/Ticker
- TiddlyTools/Time/action-timeout.js
- TiddlyTools/Time/ParseDate
- TiddlyTools/Time/Alarms
(Note: you can delete the TiddlyTools/Time/CountDown and the AutoHideSaverButton tiddler you had previously created, as they will no longer be used.)
Next, create a tiddler (e.g., AutoHideSaverStartup), tagged with $:/tags/StartupAction/Browser containing:
<$action-setfield
$tiddler="AutoHideSaver"
$timestamp="no"
alarms={{{ [<now "YYYY-0MM-0DD;0hh:0mm:0ss">parsedate[number]add[600000]parsedate:number[YYYY-0MM-0DD;0hh:0mm:0ss]addprefix[once;]addsuffix[;AutoHideSaver]] }}}/>
Then, create a tiddler (e.g., AutoHideSaver), containing:
<$action-setfield
$tiddler="$:/config/PageControlButtons/Visibility/$:/core/ui/Buttons/save-wiki"
text="hide"/>
<$action-setfield $tiddler="AutoHideSaver" $timestamp="no" $field=alarms/>
{{||TiddlyTools/Time/Alarms}}
Notes:
- The
AutoHideSaverStartup tiddler is invoked at startup, and sets the alarms field of the AutoHideSaver tiddler.
- The desired alarm date and time is automatically computed by getting the current formatted date and time, converting it to a “unix time” decimal number, adding 10 minutes (600000 milliseconds), and then converting it back to a formatted date and time. A prefix of “
once;” and a suffix of “;AutoHideSaver” are then added to produce an alarm definition usng the format required by the TiddlyTools/Time/Alarms macro code: once;YYYY-MM-DD;hh:mm:ss;ActionTiddlerTitle
- The
AutoHideSaver tiddler contains two actions that will be invoked when the alarm is triggered:
- The first action hides the “save-wiki” button
- The second action deletes the alarm definition that was set at startup (and is “expired” when the alarm is triggered). Note the use of
$timestamp="no", which prevents the AutoHideSaver tiddler’s “modified” timestamp from being updated. This is optional, and just keeps the AutoHideSaver tiddler from moving to the top of the “Recent Changes” sidebar list.
- Transcluding
{{||TiddlyTools/Time/Alarms}} in the AutoHideSaver tiddler is also optional, and provides an interactive form that can be used to manually edit, suspend, or delete the current alarm.
-e