mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-07-30 16:38:31 +00:00
fix setting toggleItem, periodic pulling
This commit is contained in:
@ -40,6 +40,7 @@ class HomeAssistantApp extends Application.AppBase {
|
|||||||
private var mIsApp as Lang.Boolean = false; // Or Widget
|
private var mIsApp as Lang.Boolean = false; // Or Widget
|
||||||
private var mUpdating as Lang.Boolean = false; // Don't start a second chain of updates
|
private var mUpdating as Lang.Boolean = false; // Don't start a second chain of updates
|
||||||
private var mTemplates as Lang.Dictionary = {};
|
private var mTemplates as Lang.Dictionary = {};
|
||||||
|
private var mNotifiedNoBle as Lang.Boolean = false;
|
||||||
|
|
||||||
//! Class Constructor
|
//! Class Constructor
|
||||||
//
|
//
|
||||||
@ -321,11 +322,11 @@ class HomeAssistantApp extends Application.AppBase {
|
|||||||
|
|
||||||
//! Start the periodic menu updates for as long as the application is running.
|
//! Start the periodic menu updates for as long as the application is running.
|
||||||
//
|
//
|
||||||
function startUpdates() {
|
function startUpdates() as Void {
|
||||||
if (mHaMenu != null and !mUpdating) {
|
if (mHaMenu != null and !mUpdating) {
|
||||||
// Start the continuous update process that continues for as long as the application is running.
|
// Start the continuous update process that continues for as long as the application is running.
|
||||||
updateMenuItems();
|
|
||||||
mUpdating = true;
|
mUpdating = true;
|
||||||
|
updateMenuItems();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,22 +436,35 @@ class HomeAssistantApp extends Application.AppBase {
|
|||||||
|
|
||||||
// In Wifi/LTE execution mode, we should not show an error page but use a toast instead.
|
// In Wifi/LTE execution mode, we should not show an error page but use a toast instead.
|
||||||
if (Settings.getWifiLteExecutionEnabled() && (! phoneConnected || ! connectionAvailable)) {
|
if (Settings.getWifiLteExecutionEnabled() && (! phoneConnected || ! connectionAvailable)) {
|
||||||
var toast = WatchUi.loadResource($.Rez.Strings.NoPhone);
|
// Notify only once per disconnection cycle
|
||||||
if (!connectionAvailable) {
|
if (!mNotifiedNoBle) {
|
||||||
toast = WatchUi.loadResource($.Rez.Strings.NoInternet);
|
var toast = WatchUi.loadResource($.Rez.Strings.NoPhone);
|
||||||
|
if (!connectionAvailable) {
|
||||||
|
toast = WatchUi.loadResource($.Rez.Strings.NoInternet);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mHasToast) {
|
||||||
|
WatchUi.showToast(toast, null);
|
||||||
|
} else {
|
||||||
|
new Alert({
|
||||||
|
:timeout => Globals.scAlertTimeout,
|
||||||
|
:font => Graphics.FONT_MEDIUM,
|
||||||
|
:text => toast,
|
||||||
|
:fgcolor => Graphics.COLOR_WHITE,
|
||||||
|
:bgcolor => Graphics.COLOR_BLACK
|
||||||
|
}).pushView(WatchUi.SLIDE_IMMEDIATE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mHasToast) {
|
mNotifiedNoBle = true;
|
||||||
WatchUi.showToast(toast, null);
|
setApiStatus(WatchUi.loadResource($.Rez.Strings.Unavailable) as Lang.String);
|
||||||
} else {
|
|
||||||
new Alert({
|
var delay = Settings.getPollDelay();
|
||||||
:timeout => Globals.scAlertTimeout,
|
if (delay > 0) {
|
||||||
:font => Graphics.FONT_MEDIUM,
|
mUpdateTimer.start(method(:startUpdates), delay, false);
|
||||||
:text => toast,
|
|
||||||
:fgcolor => Graphics.COLOR_WHITE,
|
|
||||||
:bgcolor => Graphics.COLOR_BLACK
|
|
||||||
}).pushView(WatchUi.SLIDE_IMMEDIATE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mUpdating = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -463,6 +477,8 @@ class HomeAssistantApp extends Application.AppBase {
|
|||||||
ErrorView.show(WatchUi.loadResource($.Rez.Strings.NoInternet) as Lang.String);
|
ErrorView.show(WatchUi.loadResource($.Rez.Strings.NoInternet) as Lang.String);
|
||||||
setApiStatus(WatchUi.loadResource($.Rez.Strings.Unavailable) as Lang.String);
|
setApiStatus(WatchUi.loadResource($.Rez.Strings.Unavailable) as Lang.String);
|
||||||
} else {
|
} else {
|
||||||
|
mNotifiedNoBle = false;
|
||||||
|
|
||||||
if (mItemsToUpdate == null or mTemplates == null) {
|
if (mItemsToUpdate == null or mTemplates == null) {
|
||||||
mItemsToUpdate = mHaMenu.getItemsToUpdate();
|
mItemsToUpdate = mHaMenu.getItemsToUpdate();
|
||||||
mTemplates = {};
|
mTemplates = {};
|
||||||
|
@ -255,6 +255,8 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem {
|
|||||||
var url = getUrl(id, s);
|
var url = getUrl(id, s);
|
||||||
|
|
||||||
if ((! phoneConnected || ! internetAvailable) && Settings.getWifiLteExecutionEnabled()) {
|
if ((! phoneConnected || ! internetAvailable) && Settings.getWifiLteExecutionEnabled()) {
|
||||||
|
// Undo the toggle
|
||||||
|
setEnabled(!isEnabled());
|
||||||
wifiPrompt(s);
|
wifiPrompt(s);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user