1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// Author: cirakg & claude ai
// Summary: Application entry point (Connect IQ AppBase): lifecycle, first view, glance, locking on exit.
//
// Connect IQ lifecycle: initialize -> onStart -> getInitialView (or
// getGlanceView in glance mode) -> views run -> onStop.
//
// The vault is opened in getInitialView, not onStart: onStart also runs in
// glance mode, which has too little memory for it.
//
// Security: onStop locks the vault (keys and decrypted codes are wiped). It
// runs when the user leaves the app, and also when Garmin's system passcode
// shuts running apps down.
//
// getGlanceView is (:glance), so the compiler checks this class against the
// glance scope too. The other methods never run in glance mode and use
// non-glance code, so they opt out with (:typecheck(disableGlanceCheck)).
import Toybox.Application;
import Toybox.Lang;
import Toybox.WatchUi;
class OtpWalletApp extends Application.AppBase {
// True once the full app (not the glance) has started.
private var _started as Boolean = false;
function initialize() {
AppBase.initialize();
// Start of the start-up timer reported by `make perf` (debug builds only).
Diag.markStart();
}
function onStart(state as Dictionary?) as Void {
}
(:typecheck(disableGlanceCheck))
// onStop also runs after the glance, where AppState was never loaded.
function onStop(state as Dictionary?) as Void {
if (_started) {
AppState.lock();
}
}
// The list, or a full-screen message when the data can't be used.
(:typecheck(disableGlanceCheck))
function getInitialView() as [Views] or [Views, InputDelegates] {
_started = true;
AppState.start();
var error = AppState.startError;
if (error != null) {
return [new InfoView("OTP Wallet", [error], "error"), new InfoDelegate()];
}
var list = new ListView();
return [list, new ListDelegate(list)];
}
(:glance)
function getGlanceView() as [WatchUi.GlanceView] or [WatchUi.GlanceView, WatchUi.GlanceViewDelegate] or Null {
return [new OtpGlanceView()];
}
}
|