summaryrefslogtreecommitdiff
path: root/source/ui/CodeView.mc
diff options
context:
space:
mode:
Diffstat (limited to 'source/ui/CodeView.mc')
-rw-r--r--source/ui/CodeView.mc19
1 files changed, 16 insertions, 3 deletions
diff --git a/source/ui/CodeView.mc b/source/ui/CodeView.mc
index efa23d2..03f1fa7 100644
--- a/source/ui/CodeView.mc
+++ b/source/ui/CodeView.mc
@@ -27,6 +27,9 @@
// ticker timer does the renewing (and redraws the progress while
// encoding), so a code screen never needs more timers.
// * Too big: a message with the size needed.
+// * A locked code closes back to the list when auto-lock fires while it
+// is open (README 7.5), like a locked OTP entry: the ticker keeps
+// running for it and checks the session.
// The payload is decrypted when the screen opens and wiped once encoded.
import Toybox.Attention;
@@ -70,6 +73,9 @@ class CodeView extends WatchUi.View {
_shownLogged = false;
encode();
boostBrightness();
+ if (header.locked) {
+ startTicker();
+ }
}
function onHide() as Void {
@@ -143,8 +149,13 @@ class CodeView extends WatchUi.View {
}
// Progress redraws while a job runs; brightness renewals during the
- // minute. The ticker stops when neither is needed.
+ // minute; auto-lock for a locked code. The ticker stops when none of
+ // them is needed.
function onTick() as Void {
+ if (header.locked && AppState.checkAutoLock()) {
+ WatchUi.popView(WatchUi.SLIDE_RIGHT);
+ return;
+ }
if (_job != null) {
WatchUi.requestUpdate();
}
@@ -157,7 +168,7 @@ class CodeView extends WatchUi.View {
light();
}
}
- if (_job == null && _boostStart < 0) {
+ if (_job == null && _boostStart < 0 && !header.locked) {
stopTicker();
}
}
@@ -266,8 +277,10 @@ class CodeView extends WatchUi.View {
} else if (code instanceof RunsPainter) {
drawMatrix(dc, code, smallFont, smallH);
} else if (job != null) {
+ var percent = job.percent();
dc.drawText(w / 2, h / 2 - smallH / 2, smallFont, (job instanceof RunsPainter ? "Drawing… " : "Encoding… ")
- + job.percent() + "%", Graphics.TEXT_JUSTIFY_CENTER);
+ + percent + "%", Graphics.TEXT_JUSTIFY_CENTER);
+ Diag.data("code_progress", "percent=" + percent); // for UI scripts
} else {
drawMessage(dc, code instanceof Codes.CodeError ? code.message : "…", smallFont, smallH);
}