mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-06-17 20:08:33 +00:00
Directly quit w/o showing RootView (if possible)
This commit is contained in:
@ -177,7 +177,7 @@ class HomeAssistantApp extends Application.AppBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function pushHomeAssistantMenuView() as Void{
|
function pushHomeAssistantMenuView() as Void{
|
||||||
WatchUi.pushView(mHaMenu, new HomeAssistantViewDelegate(), WatchUi.SLIDE_IMMEDIATE);
|
WatchUi.pushView(mHaMenu, new HomeAssistantViewDelegate(true), WatchUi.SLIDE_IMMEDIATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to spread out the API calls so as not to overload the results queue and cause Communications.BLE_QUEUE_FULL (-101) error.
|
// We need to spread out the API calls so as not to overload the results queue and cause Communications.BLE_QUEUE_FULL (-101) error.
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
using Toybox.Application;
|
using Toybox.Application;
|
||||||
using Toybox.Lang;
|
using Toybox.Lang;
|
||||||
using Toybox.Graphics;
|
using Toybox.Graphics;
|
||||||
|
using Toybox.System;
|
||||||
using Toybox.WatchUi;
|
using Toybox.WatchUi;
|
||||||
|
|
||||||
class HomeAssistantView extends WatchUi.Menu2 {
|
class HomeAssistantView extends WatchUi.Menu2 {
|
||||||
@ -103,12 +104,23 @@ class HomeAssistantView extends WatchUi.Menu2 {
|
|||||||
//
|
//
|
||||||
class HomeAssistantViewDelegate extends WatchUi.Menu2InputDelegate {
|
class HomeAssistantViewDelegate extends WatchUi.Menu2InputDelegate {
|
||||||
|
|
||||||
function initialize() {
|
private var mIsRootMenuView = false;
|
||||||
|
|
||||||
|
function initialize(isRootMenuView as Lang.Boolean) {
|
||||||
Menu2InputDelegate.initialize();
|
Menu2InputDelegate.initialize();
|
||||||
|
mIsRootMenuView = isRootMenuView;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onBack() {
|
function onBack() {
|
||||||
getApp().getQuitTimer().reset();
|
getApp().getQuitTimer().reset();
|
||||||
|
|
||||||
|
if (mIsRootMenuView){
|
||||||
|
// If its started from glance or as an activity, directly exit the widget/app
|
||||||
|
// (on widgets without glance, this exit() won`t do anything,
|
||||||
|
// so the base view will be shown instead, through the popView below this "if body")
|
||||||
|
System.exit();
|
||||||
|
}
|
||||||
|
|
||||||
WatchUi.popView(WatchUi.SLIDE_RIGHT);
|
WatchUi.popView(WatchUi.SLIDE_RIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,15 +159,13 @@ class HomeAssistantViewDelegate extends WatchUi.Menu2InputDelegate {
|
|||||||
if (Globals.scDebug) {
|
if (Globals.scDebug) {
|
||||||
System.println("Menu: " + haMenuItem.getLabel() + " " + haMenuItem.getId());
|
System.println("Menu: " + haMenuItem.getLabel() + " " + haMenuItem.getId());
|
||||||
}
|
}
|
||||||
// No delegate state to be amended, so re-use 'self'.
|
WatchUi.pushView(haMenuItem.getMenuView(), new HomeAssistantViewDelegate(false), WatchUi.SLIDE_LEFT);
|
||||||
WatchUi.pushView(haMenuItem.getMenuView(), self, WatchUi.SLIDE_LEFT);
|
|
||||||
} else if (item instanceof HomeAssistantViewIconMenuItem) {
|
} else if (item instanceof HomeAssistantViewIconMenuItem) {
|
||||||
var haMenuItem = item as HomeAssistantViewIconMenuItem;
|
var haMenuItem = item as HomeAssistantViewIconMenuItem;
|
||||||
if (Globals.scDebug) {
|
if (Globals.scDebug) {
|
||||||
System.println("IconMenu: " + haMenuItem.getLabel() + " " + haMenuItem.getId());
|
System.println("IconMenu: " + haMenuItem.getLabel() + " " + haMenuItem.getId());
|
||||||
}
|
}
|
||||||
// No delegate state to be amended, so re-use 'self'.
|
WatchUi.pushView(haMenuItem.getMenuView(), new HomeAssistantViewDelegate(false), WatchUi.SLIDE_LEFT);
|
||||||
WatchUi.pushView(haMenuItem.getMenuView(), self, WatchUi.SLIDE_LEFT);
|
|
||||||
} else {
|
} else {
|
||||||
if (Globals.scDebug) {
|
if (Globals.scDebug) {
|
||||||
System.println(item.getLabel() + " " + item.getId());
|
System.println(item.getLabel() + " " + item.getId());
|
||||||
|
Reference in New Issue
Block a user