Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e207478e79 | ||
|
|
3f6fe5abf1 | ||
|
|
7f1b246679 | ||
|
|
3a7eb8c612 |
@@ -70,7 +70,10 @@ everything works except installation and the service worker.
|
||||
stray thumb can't wipe a live match. It's absent on a fresh match, where there
|
||||
is nothing yet to wipe.
|
||||
- **Pause** freezes mid-turn and resumes exactly where it stopped, delay
|
||||
included. Opening either sheet pauses automatically. The settings sheet leaves
|
||||
included. Both halves read **Paused** underneath the delay bar while it is, in
|
||||
the same ink as the clock above it, and the play button lights up — so a
|
||||
stopped clock can't be mistaken for a running one from either side of the
|
||||
board. Opening either sheet pauses automatically. The settings sheet leaves
|
||||
it paused — everything in there resets the clocks anyway — while the score
|
||||
sheet picks the turn back up when you close it, so glancing at the score
|
||||
doesn't cost you a tap on play. It's absent whenever there's no clock running
|
||||
|
||||
@@ -61,6 +61,14 @@ make some moves, force-quit from the task switcher and reopen — everything
|
||||
should come back, paused. That is the check that proves the app's storage is
|
||||
working, and it fails silently rather than loudly.
|
||||
|
||||
**Let the turn run at least 40 seconds before you quit.** This is the whole
|
||||
check, and doing it any faster proves nothing: for the first 12 seconds of a
|
||||
turn the delay absorbs everything and the reserve clock is *supposed* to sit
|
||||
still, so a clock that has lost its place looks exactly like one that hasn't.
|
||||
Quit well past the delay and the time must come back lower than it was at the
|
||||
turn switch — and the delay counter must not be sitting at a full 12. That is
|
||||
how a broken save hid from this check from 1.0 to 1.3.
|
||||
|
||||
## 5. Commit, tag, push
|
||||
|
||||
```bash
|
||||
|
||||
@@ -12,8 +12,8 @@ android {
|
||||
applicationId = "nl.hansdezwart.bgclock"
|
||||
minSdk = 26
|
||||
targetSdk = 36
|
||||
versionCode = 4
|
||||
versionName = "1.3"
|
||||
versionCode = 6
|
||||
versionName = "1.5"
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
|
||||
@@ -121,8 +121,15 @@ public class MainActivity extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
// forwarded so the page's visibilitychange fires — that is what calls
|
||||
// saveGame() and nudges the audio context back after backgrounding
|
||||
// Forwarded so the WebView stops its timers, animations and audio while the
|
||||
// app is in the background, and picks them up again on return.
|
||||
//
|
||||
// This does NOT drive the page's visibilitychange — an earlier comment here
|
||||
// claimed it did, and the saved match quietly depended on that being true.
|
||||
// Document visibility follows the WebView's view and window visibility, not
|
||||
// this call, so the page can be killed without ever hearing about it. The
|
||||
// page no longer relies on being told: it writes the match to localStorage
|
||||
// once a second while a clock is running.
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
Fixes a match not coming back correctly after the app is force-quit. The clock
|
||||
returned to where it stood at the last turn change, losing the time spent on
|
||||
the turn that was interrupted. The match is now written down once a second
|
||||
while a clock is running, so at most a second can be lost.
|
||||
@@ -0,0 +1 @@
|
||||
Added a 'Paused' indicator when the clock is paused.
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 117 KiB After Width: | Height: | Size: 123 KiB |
+76
-2
@@ -182,6 +182,49 @@
|
||||
text-align:right;
|
||||
}
|
||||
|
||||
/* ---------- paused ----------
|
||||
A stopped clock used to look exactly like a running one: the panel keeps its
|
||||
accent, and the delay bar simply freezes mid-drain. The only tell was the
|
||||
play glyph in the bar — small, grey, and upside down for one of the two
|
||||
players. So both halves say it in words.
|
||||
|
||||
Hung off the delay row rather than added to .stack, so the big clock does
|
||||
not move a pixel when the clock stops — the same promise .btn--vacant makes
|
||||
in the bar, and the reason .delay fades rather than hides. It also cannot
|
||||
live *inside* .delay: that is opacity:0 whenever no delay is running, and a
|
||||
child can never be more opaque than its parent, which would lose the word on
|
||||
the waiting half, on a spent delay, and at a delay of 0. */
|
||||
.foot{position:relative}
|
||||
.paused{
|
||||
position:absolute;
|
||||
top:100%;
|
||||
left:50%;
|
||||
/* the bar and its number sit dead centre of the panel (see .dnum), so
|
||||
centring on that row centres on the panel, whatever the count reads */
|
||||
transform:translateX(-50%);
|
||||
/* a clear step below the bar rather than .stack's gap: near enough to belong
|
||||
to the delay row, far enough not to crowd it */
|
||||
margin-top:clamp(21px,5.8vw,41px);
|
||||
white-space:nowrap;
|
||||
line-height:1;
|
||||
/* Wider than the delay bar, narrower than the clock — the band is tighter
|
||||
than it sounds, since "3:00" is only about 2.2x the bar. The crossovers
|
||||
are .track's own (20vw between 360 and 700px wide), so the word holds its
|
||||
proportion to the bar at every size instead of drifting at the ends.
|
||||
Part of the width comes from the tracking rather than the glyph size:
|
||||
spaced letters carry "held" without shouting over the clock. */
|
||||
font-size:clamp(34px,9.4vw,66px);
|
||||
font-weight:700;
|
||||
letter-spacing:.08em;
|
||||
/* no colour of its own: it inherits the panel's, which is what the clock and
|
||||
the delay count are already wearing. Each theme picks its own --accent-ink
|
||||
(white on most of them), so the word follows the palette without a rule
|
||||
per theme, and the paused half never has two different inks on it. */
|
||||
opacity:0;
|
||||
transition:opacity .16s ease;
|
||||
}
|
||||
.paused.on{opacity:1}
|
||||
|
||||
/* ---------- control bar ---------- */
|
||||
.bar{
|
||||
background:var(--bar);
|
||||
@@ -199,6 +242,9 @@
|
||||
cursor:pointer;
|
||||
}
|
||||
.btn:active{color:var(--icon-hot)}
|
||||
/* the way back from a paused clock, lit like a held Reset: the bar is the only
|
||||
thing either player can act on while the clocks are stopped */
|
||||
#playpause.lit{color:var(--icon-hot)}
|
||||
.btn[aria-pressed="false"]{color:#5E5954}
|
||||
.btn svg{width:clamp(23px,6.4vw,32px);height:auto;display:block}
|
||||
.btn svg[hidden]{display:none}
|
||||
@@ -432,10 +478,13 @@
|
||||
<div class="stack">
|
||||
<div class="time" data-time>3:00</div>
|
||||
<div class="out" data-out hidden>Out of<br>time</div>
|
||||
<div class="foot">
|
||||
<div class="delay" data-delay>
|
||||
<span class="track"><i class="fill" data-fill></i></span>
|
||||
<span class="dnum" data-dnum>15</span>
|
||||
</div>
|
||||
<div class="paused" data-paused>Paused</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -498,10 +547,13 @@
|
||||
<div class="stack">
|
||||
<div class="time" data-time>3:00</div>
|
||||
<div class="out" data-out hidden>Out of<br>time</div>
|
||||
<div class="foot">
|
||||
<div class="delay" data-delay>
|
||||
<span class="track"><i class="fill" data-fill></i></span>
|
||||
<span class="dnum" data-dnum>15</span>
|
||||
</div>
|
||||
<div class="paused" data-paused>Paused</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -709,7 +761,8 @@
|
||||
scoreLines: [].slice.call(p.querySelectorAll(".line:not(.line--moves)")),
|
||||
delay: p.querySelector("[data-delay]"),
|
||||
fill: p.querySelector("[data-fill]"),
|
||||
dnum: p.querySelector("[data-dnum]")
|
||||
dnum: p.querySelector("[data-dnum]"),
|
||||
paused: p.querySelector("[data-paused]")
|
||||
};
|
||||
});
|
||||
var btnPlay = document.getElementById("playpause");
|
||||
@@ -886,6 +939,11 @@
|
||||
setText(el[i].dnum, Math.ceil(dLeft / 1000));
|
||||
}
|
||||
|
||||
// both halves, not just the one whose turn it is: the waiting player's
|
||||
// clock is stopped too, and they are the one who can't read the bar's
|
||||
// play glyph the right way up
|
||||
el[i].paused.classList.toggle("on", st.phase === PAUSE);
|
||||
|
||||
setAttr(el[i].root, "data-state",
|
||||
(st.phase === FLAG && i === st.active) ? "flagged"
|
||||
: (i === st.active && st.phase !== IDLE) ? "active" : "idle");
|
||||
@@ -901,6 +959,7 @@
|
||||
// nothing running to pause: before a game's first tap, and after a flag,
|
||||
// where togglePause is inert anyway — the game is over, Reset is the way out
|
||||
btnPlay.classList.toggle("btn--vacant", st.phase === IDLE || st.phase === FLAG);
|
||||
btnPlay.classList.toggle("lit", st.phase === PAUSE);
|
||||
}
|
||||
|
||||
function loop(){ render(); requestAnimationFrame(loop); }
|
||||
@@ -1051,11 +1110,26 @@
|
||||
if(st.phase === PAUSE && st.active < 0) st.phase = IDLE; // can't be mid-turn with no turn
|
||||
}
|
||||
|
||||
// the only hooks iOS reliably fires before killing an app
|
||||
// The hooks iOS fires before killing an app. Android's WebView is the problem
|
||||
// child: neither of these is guaranteed there, whatever MainActivity's
|
||||
// onPause() forwarding suggests, and when they don't fire the newest save is
|
||||
// the one tap() wrote — which carries held ≈ 0, because tap() sets turnAt and
|
||||
// saves in the same breath. Reopening then hands back the entire turn, and
|
||||
// the bug hides in plain sight: quit inside the delay window and a clock that
|
||||
// correctly hasn't moved looks exactly like a clock that lost its place.
|
||||
document.addEventListener("visibilitychange", function(){
|
||||
if(document.visibilityState === "hidden") saveGame();
|
||||
});
|
||||
window.addEventListener("pagehide", saveGame);
|
||||
// a different signal from visibilitychange, and it does fire when Android's
|
||||
// task switcher opens. saveGame() is idempotent, so an extra call is free
|
||||
window.addEventListener("blur", saveGame);
|
||||
|
||||
// and the one that doesn't depend on being told anything: a second is the
|
||||
// most a force-quit can now cost, which is well inside the delay nobody is
|
||||
// charged for. A timer rather than a hook in loop(), because rAF stops when
|
||||
// the page is hidden — exactly when this matters most.
|
||||
setInterval(function(){ if(st.phase === RUN) saveGame(); }, 1000);
|
||||
|
||||
/* Reset is a hold, not a tap. It used to be two taps inside 2s, and a test
|
||||
user found the button, tapped it once and gave up — which is exactly what
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/* Cache-first: once installed the clock never touches the network again. */
|
||||
const CACHE = "bgclock-v19";
|
||||
const CACHE = "bgclock-v21";
|
||||
const FILES = [
|
||||
"./",
|
||||
"./index.html",
|
||||
|
||||
Reference in New Issue
Block a user