mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-06-18 12:28:41 +00:00
Bug fix for devices with API 3.1.0
1) Removed WatchUi.getCurrentView() API call in favour of a new method of ensuring only one ErrorView is pushed at a time. 2) Any error view will be cancelled when responses start working again, e.g. watch gets in Bluetooth range of the phone again. 3) Added error message decoding for misspelled entities. Co-Authored-By: Joseph Abbey <me@josephabbey.dev>
This commit is contained in:
@ -26,6 +26,7 @@ using Toybox.Timer;
|
||||
using Toybox.Application.Properties;
|
||||
|
||||
class HomeAssistantConfirmation extends WatchUi.Confirmation {
|
||||
|
||||
function initialize() {
|
||||
WatchUi.Confirmation.initialize(WatchUi.loadResource($.Rez.Strings.Confirm));
|
||||
}
|
||||
@ -33,32 +34,32 @@ class HomeAssistantConfirmation extends WatchUi.Confirmation {
|
||||
}
|
||||
|
||||
class HomeAssistantConfirmationDelegate extends WatchUi.ConfirmationDelegate {
|
||||
private var confirmMethod;
|
||||
private var timeout;
|
||||
private var mConfirmMethod;
|
||||
private var mTimer;
|
||||
|
||||
function initialize(callback as Method() as Void) {
|
||||
WatchUi.ConfirmationDelegate.initialize();
|
||||
confirmMethod = callback;
|
||||
mConfirmMethod = callback;
|
||||
var timeoutSeconds = Properties.getValue("confirm_timeout") as Lang.Number;
|
||||
if (timeoutSeconds > 0) {
|
||||
timeout = new Timer.Timer();
|
||||
timeout.start(method(:onTimeout), timeoutSeconds * 1000, true);
|
||||
mTimer = new Timer.Timer();
|
||||
mTimer.start(method(:onTimeout), timeoutSeconds * 1000, true);
|
||||
}
|
||||
}
|
||||
|
||||
function onResponse(response) as Lang.Boolean {
|
||||
getApp().getQuitTimer().reset();
|
||||
if (timeout) {
|
||||
timeout.stop();
|
||||
if (mTimer) {
|
||||
mTimer.stop();
|
||||
}
|
||||
if (response == WatchUi.CONFIRM_YES) {
|
||||
confirmMethod.invoke();
|
||||
mConfirmMethod.invoke();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function onTimeout() as Void {
|
||||
timeout.stop();
|
||||
mTimer.stop();
|
||||
WatchUi.popView(WatchUi.SLIDE_RIGHT);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user