einsatzprotokoll/source/ErrorView.mc
EiSiMo 025d3007db Phase 3: event creation flow (GPS + success / error)
GpsService runs a single-shot position request with a hard timeout
and early-exit when Config.GPS_TARGET_ACCURACY_M is reached.
LoadingView renders a circular progress bar around the edge plus the
"Standort wird bestimmt" prompt; on callback it persists a new Event
via EventStore.add and transitions to SuccessView (green checkmark,
short vibration, auto-close) or ErrorView (red alert, 3× vibration,
German message, longer hold). TextUtils extracts the shared
multi-line centered text rendering so MenuView, LoadingView and
ErrorView all render wrapped German text consistently. Positioning
permission added to manifest.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 20:36:22 +02:00

60 lines
1.9 KiB
MonkeyC
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Toybox.Attention;
import Toybox.Graphics;
import Toybox.Lang;
import Toybox.Timer;
import Toybox.WatchUi;
// Red warning flash when GPS acquisition fails. 3× vibration + German
// error message for Config.ERROR_DISPLAY_MS, then closes the app.
class ErrorView extends WatchUi.View {
private var _timer as Timer.Timer;
function initialize() {
View.initialize();
_timer = new Timer.Timer();
}
function onShow() as Void {
if (Attention has :vibrate) {
var profile = [
new Attention.VibeProfile(75, 250),
new Attention.VibeProfile(0, 150),
new Attention.VibeProfile(75, 250),
new Attention.VibeProfile(0, 150),
new Attention.VibeProfile(75, 250)
] as Array<Attention.VibeProfile>;
Attention.vibrate(profile);
}
_timer.start(method(:_dismiss), Config.ERROR_DISPLAY_MS, false);
}
function onHide() as Void {
_timer.stop();
}
function _dismiss() as Void {
System.exit();
}
function onUpdate(dc as Dc) as Void {
dc.setColor(Config.COLOR_FG, Config.COLOR_BG);
dc.clear();
var cx = LayoutMetrics.centerX(dc);
var cy = LayoutMetrics.centerY(dc);
var min = LayoutMetrics.minDim(dc);
var iconRadius = (min * 0.1).toNumber();
var iconCy = (min * 0.25).toNumber();
dc.setColor(Config.COLOR_ERROR, Config.COLOR_BG);
dc.fillCircle(cx, iconCy, iconRadius);
dc.setColor(Config.COLOR_BG, Config.COLOR_ERROR);
dc.drawText(cx, iconCy, Graphics.FONT_MEDIUM, "!",
Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER);
dc.setColor(Config.COLOR_FG, Config.COLOR_BG);
var textCy = cy + (min * 0.08).toNumber();
TextUtils.drawResourceCentered(dc, Rez.Strings.error_gps, cx, textCy, Graphics.FONT_TINY);
}
}