mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-06-17 11:58:30 +00:00
Remove text versions of menu items
This commit is contained in:
@ -51,11 +51,6 @@
|
|||||||
-->
|
-->
|
||||||
<property id="confirm_timeout" type="number">3</property>
|
<property id="confirm_timeout" type="number">3</property>
|
||||||
|
|
||||||
<!--
|
|
||||||
Lean UI with icons vs second level of menu text.
|
|
||||||
-->
|
|
||||||
<property id="menu_theme" type="number">0</property>
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Left to right or right to left text. Language dependent.
|
Left to right or right to left text. Language dependent.
|
||||||
-->
|
-->
|
||||||
|
@ -65,17 +65,6 @@
|
|||||||
<settingConfig type="numeric" min="0" />
|
<settingConfig type="numeric" min="0" />
|
||||||
</setting>
|
</setting>
|
||||||
|
|
||||||
<setting
|
|
||||||
propertyKey="@Properties.menu_theme"
|
|
||||||
title="@Strings.SettingsMenuItemStyle"
|
|
||||||
prompt="@Strings.SettingsSelect"
|
|
||||||
>
|
|
||||||
<settingConfig type="list">
|
|
||||||
<listEntry value="0">@Strings.SettingsMenuItemStyleIcons</listEntry>
|
|
||||||
<listEntry value="1">@Strings.SettingsMenuItemStyleText</listEntry>
|
|
||||||
</settingConfig>
|
|
||||||
</setting>
|
|
||||||
|
|
||||||
<setting
|
<setting
|
||||||
propertyKey="@Properties.menu_alignment"
|
propertyKey="@Properties.menu_alignment"
|
||||||
title="@Strings.SettingsTextAlign"
|
title="@Strings.SettingsTextAlign"
|
||||||
|
@ -13,52 +13,52 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<strings>
|
<strings>
|
||||||
<string id="AppName" scope="glance">HomeAssistant</string>
|
<string id="AppName" scope="glance">HomeAssistant</string>
|
||||||
<string id="MenuItemOn">On</string>
|
<string id="Confirm">Sure?</string>
|
||||||
<string id="MenuItemOff">Off</string>
|
<string id="Executed" scope="glance">Confirmed</string>
|
||||||
<string id="MenuItemTap">Tap</string>
|
<string id="NoPhone" scope="glance">No Phone connection</string>
|
||||||
<string id="MenuItemMenu">Menu</string>
|
<string id="NoInternet">No Internet connection</string>
|
||||||
<string id="Confirm">Sure?</string>
|
<string id="NoResponse">No Response, check Internet connection</string>
|
||||||
<string id="Executed" scope="glance">Confirmed</string>
|
<string id="NoAPIKey" scope="glance">No API key in the application settings</string>
|
||||||
<string id="NoPhone" scope="glance">No Phone connection</string>
|
<string id="NoApiUrl" scope="glance">No API URL in the application settings</string>
|
||||||
<string id="NoInternet">No Internet connection</string>
|
<string id="NoConfigUrl" scope="glance">No configuration URL in the application settings</string>
|
||||||
<string id="NoResponse">No Response, check Internet connection</string>
|
<string id="ApiFlood">API calls too rapid. Please slow down your requests.</string>
|
||||||
<string id="NoAPIKey" scope="glance">No API key in the application settings</string>
|
<string id="ApiUrlNotFound">URL not found. Potential API URL error in settings.</string>
|
||||||
<string id="NoApiUrl" scope="glance">No API URL in the application settings</string>
|
<string id="ConfigUrlNotFound">URL not found. Potential Configuration URL error in settings.</string>
|
||||||
<string id="NoConfigUrl" scope="glance">No configuration URL in the application settings</string>
|
<string id="NoJson">No JSON returned from HTTP request.</string>
|
||||||
<string id="ApiFlood">API calls too rapid. Please slow down your requests.</string>
|
<string id="UnhandledHttpErr">HTTP request returned error code = </string>
|
||||||
<string id="ApiUrlNotFound">URL not found. Potential API URL error in settings.</string>
|
<string id="TrailingSlashErr">API URL must not have a trailing slash '/'</string>
|
||||||
<string id="ConfigUrlNotFound">URL not found. Potential Configuration URL error in settings.</string>
|
<string id="WebhookFailed">Failed to register Webhook</string>
|
||||||
<string id="NoJson">No JSON returned from HTTP request.</string>
|
<string id="TemplateError">Failed to render template</string>
|
||||||
<string id="UnhandledHttpErr">HTTP request returned error code = </string>
|
<string id="Available" scope="glance">Available</string>
|
||||||
<string id="TrailingSlashErr">API URL must not have a trailing slash '/'</string>
|
<string id="Checking" scope="glance">Checking...</string>
|
||||||
<string id="WebhookFailed">Failed to register Webhook</string>
|
<string id="Unavailable" scope="glance">Unavailable</string>
|
||||||
<string id="TemplateError">Failed to render template</string>
|
<string id="Unconfigured" scope="glance">Unconfigured</string>
|
||||||
<string id="Available" scope="glance">Available</string>
|
<string id="Cached" scope="glance">Cached</string>
|
||||||
<string id="Checking" scope="glance">Checking...</string>
|
<string id="GlanceMenu" scope="glance">Menu</string>
|
||||||
<string id="Unavailable" scope="glance">Unavailable</string>
|
|
||||||
<string id="Unconfigured" scope="glance">Unconfigured</string>
|
|
||||||
<string id="Cached" scope="glance">Cached</string>
|
|
||||||
<string id="GlanceMenu" scope="glance">Menu</string>
|
|
||||||
|
|
||||||
<!-- For the settings GUI -->
|
<!-- For the settings GUI -->
|
||||||
<string id="SettingsSelect">Select...</string>
|
<string id="SettingsSelect">Select...</string>
|
||||||
<string id="SettingsApiKey">API Key for HomeAssistant.</string>
|
<string id="SettingsApiKey">API Key for HomeAssistant.</string>
|
||||||
<string id="SettingsApiKeyPrompt">Long-Lived Access Token.</string>
|
<string id="SettingsApiKeyPrompt">Long-Lived Access Token.</string>
|
||||||
<string id="SettingsApiUrl">URL for HomeAssistant API.</string>
|
<string id="SettingsApiUrl">URL for HomeAssistant API.</string>
|
||||||
<string id="SettingsConfigUrl">URL for menu configuration (JSON).</string>
|
<string id="SettingsConfigUrl">URL for menu configuration (JSON).</string>
|
||||||
<string id="SettingsCacheConfig">Should the application cache the menu configuration?</string>
|
<string id="SettingsCacheConfig">Should the application cache the menu configuration?</string>
|
||||||
<string id="SettingsClearCache">Should the application clear the existing cache next time it is started?</string>
|
<string id="SettingsClearCache">Should the application clear the existing cache next time it is
|
||||||
<string id="SettingsAppTimeout">Timeout in seconds. Exit the application after this period of inactivity to save the device battery.</string>
|
started?</string>
|
||||||
<string id="SettingsConfirmTimeout">After this time (in seconds), a confirmation dialog for an action is automatically closed and the action is cancelled. Set to 0 to disable the timeout.</string>
|
<string id="SettingsAppTimeout">Timeout in seconds. Exit the application after this period of
|
||||||
<string id="SettingsMenuItemStyle">Menu item style.</string>
|
inactivity to save the device battery.</string>
|
||||||
<string id="SettingsMenuItemStyleIcons">Icons</string>
|
<string id="SettingsConfirmTimeout">After this time (in seconds), a confirmation dialog for an
|
||||||
<string id="SettingsMenuItemStyleText">Additional Text</string>
|
action is automatically closed and the action is cancelled. Set to 0 to disable the timeout.</string>
|
||||||
<string id="SettingsTextAlign">Left (off) or Right (on) Menu Alignment.</string>
|
<string id="SettingsTextAlign">Left (off) or Right (on) Menu Alignment.</string>
|
||||||
<string id="LeftToRight">Left to right</string>
|
<string id="LeftToRight">Left to right</string>
|
||||||
<string id="RightToLeft">Right to Left</string>
|
<string id="RightToLeft">Right to Left</string>
|
||||||
<string id="SettingsWidgetStart">(Widget only) Automatically start the application from the widget without waiting for a tap.</string>
|
<string id="SettingsWidgetStart">(Widget only) Automatically start the application from the widget
|
||||||
<string id="SettingsEnableBatteryLevel">Enable the background service to send the clock battery level to Home Assistant.</string>
|
without waiting for a tap.</string>
|
||||||
<string id="SettingsBatteryLevelRefreshRate">The refresh rate (in minutes) at which the background service should repeat sending the battery level.</string>
|
<string id="SettingsEnableBatteryLevel">Enable the background service to send the clock battery
|
||||||
<string id="WebhookId">(Read only) The Webhook ID created by the watch for battery level updates. You might require this for debugging.</string>
|
level to Home Assistant.</string>
|
||||||
|
<string id="SettingsBatteryLevelRefreshRate">The refresh rate (in minutes) at which the background
|
||||||
|
service should repeat sending the battery level.</string>
|
||||||
|
<string id="WebhookId">(Read only) The Webhook ID created by the watch for battery level updates.
|
||||||
|
You might require this for debugging.</string>
|
||||||
</strings>
|
</strings>
|
@ -1,72 +0,0 @@
|
|||||||
//-----------------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Distributed under MIT Licence
|
|
||||||
// See https://github.com/house-of-abbey/GarminHomeAssistant/blob/main/LICENSE.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// GarminHomeAssistant is a Garmin IQ application written in Monkey C and routinely
|
|
||||||
// tested on a Venu 2 device. The source code is provided at:
|
|
||||||
// https://github.com/house-of-abbey/GarminHomeAssistant.
|
|
||||||
//
|
|
||||||
// P A Abbey & J D Abbey & Someone0nEarth, 31 October 2023
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Description:
|
|
||||||
//
|
|
||||||
// Menu button that triggers a service.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
using Toybox.Lang;
|
|
||||||
using Toybox.WatchUi;
|
|
||||||
using Toybox.Graphics;
|
|
||||||
|
|
||||||
class HomeAssistantIconMenuItem extends WatchUi.IconMenuItem {
|
|
||||||
private var mHomeAssistantService as HomeAssistantService;
|
|
||||||
private var mService as Lang.String;
|
|
||||||
private var mConfirm as Lang.Boolean;
|
|
||||||
|
|
||||||
function initialize(
|
|
||||||
label as Lang.String or Lang.Symbol,
|
|
||||||
subLabel as Lang.String or Lang.Symbol or Null,
|
|
||||||
identifier as Lang.Object or Null,
|
|
||||||
service as Lang.String or Null,
|
|
||||||
confirm as Lang.Boolean,
|
|
||||||
icon as Graphics.BitmapType or WatchUi.Drawable,
|
|
||||||
options as {
|
|
||||||
:alignment as WatchUi.MenuItem.Alignment
|
|
||||||
} or Null,
|
|
||||||
haService as HomeAssistantService
|
|
||||||
) {
|
|
||||||
WatchUi.IconMenuItem.initialize(
|
|
||||||
label,
|
|
||||||
subLabel,
|
|
||||||
identifier,
|
|
||||||
icon,
|
|
||||||
options
|
|
||||||
);
|
|
||||||
|
|
||||||
mHomeAssistantService = haService;
|
|
||||||
mIdentifier = identifier;
|
|
||||||
mService = service;
|
|
||||||
mConfirm = confirm;
|
|
||||||
}
|
|
||||||
|
|
||||||
function callService() as Void {
|
|
||||||
if (mConfirm) {
|
|
||||||
WatchUi.pushView(
|
|
||||||
new HomeAssistantConfirmation(),
|
|
||||||
new HomeAssistantConfirmationDelegate(method(:onConfirm)),
|
|
||||||
WatchUi.SLIDE_IMMEDIATE
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
onConfirm();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onConfirm() as Void {
|
|
||||||
mHomeAssistantService.call(mIdentifier as Lang.String, mService);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -22,7 +22,7 @@ using Toybox.Lang;
|
|||||||
using Toybox.WatchUi;
|
using Toybox.WatchUi;
|
||||||
using Toybox.Graphics;
|
using Toybox.Graphics;
|
||||||
|
|
||||||
class HomeAssistantMenuItem extends WatchUi.MenuItem {
|
class HomeAssistantMenuItem extends WatchUi.IconMenuItem {
|
||||||
private var mHomeAssistantService as HomeAssistantService;
|
private var mHomeAssistantService as HomeAssistantService;
|
||||||
private var mService as Lang.String;
|
private var mService as Lang.String;
|
||||||
private var mConfirm as Lang.Boolean;
|
private var mConfirm as Lang.Boolean;
|
||||||
@ -33,20 +33,22 @@ class HomeAssistantMenuItem extends WatchUi.MenuItem {
|
|||||||
identifier as Lang.Object or Null,
|
identifier as Lang.Object or Null,
|
||||||
service as Lang.String or Null,
|
service as Lang.String or Null,
|
||||||
confirm as Lang.Boolean,
|
confirm as Lang.Boolean,
|
||||||
|
icon as Graphics.BitmapType or WatchUi.Drawable,
|
||||||
options as {
|
options as {
|
||||||
:alignment as WatchUi.MenuItem.Alignment,
|
:alignment as WatchUi.MenuItem.Alignment
|
||||||
:icon as Graphics.BitmapType or WatchUi.Drawable or Lang.Symbol
|
|
||||||
} or Null,
|
} or Null,
|
||||||
haService as HomeAssistantService
|
haService as HomeAssistantService
|
||||||
) {
|
) {
|
||||||
WatchUi.MenuItem.initialize(
|
WatchUi.IconMenuItem.initialize(
|
||||||
label,
|
label,
|
||||||
subLabel,
|
subLabel,
|
||||||
identifier,
|
identifier,
|
||||||
|
icon,
|
||||||
options
|
options
|
||||||
);
|
);
|
||||||
|
|
||||||
mHomeAssistantService = haService;
|
mHomeAssistantService = haService;
|
||||||
|
mIdentifier = identifier;
|
||||||
mService = service;
|
mService = service;
|
||||||
mConfirm = confirm;
|
mConfirm = confirm;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ class HomeAssistantMenuItemFactory {
|
|||||||
function toggle(label as Lang.String or Lang.Symbol, identifier as Lang.Object or Null) as WatchUi.MenuItem {
|
function toggle(label as Lang.String or Lang.Symbol, identifier as Lang.Object or Null) as WatchUi.MenuItem {
|
||||||
return new HomeAssistantToggleMenuItem(
|
return new HomeAssistantToggleMenuItem(
|
||||||
label,
|
label,
|
||||||
Settings.getMenuStyle() == Settings.MENU_STYLE_TEXT ? RezStrings.getLabelToggle() : null,
|
null,
|
||||||
identifier,
|
identifier,
|
||||||
false,
|
false,
|
||||||
mMenuItemOptions
|
mMenuItemOptions
|
||||||
@ -91,35 +91,19 @@ class HomeAssistantMenuItemFactory {
|
|||||||
service as Lang.String or Null,
|
service as Lang.String or Null,
|
||||||
confirm as Lang.Boolean
|
confirm as Lang.Boolean
|
||||||
) as WatchUi.MenuItem {
|
) as WatchUi.MenuItem {
|
||||||
if (Settings.getMenuStyle() == Settings.MENU_STYLE_TEXT) {
|
return new HomeAssistantMenuItem(
|
||||||
return new HomeAssistantMenuItem(
|
label,
|
||||||
label,
|
null,
|
||||||
RezStrings.getMenuItemTap(),
|
identifier,
|
||||||
identifier,
|
service,
|
||||||
service,
|
confirm,
|
||||||
confirm,
|
mTapTypeIcon,
|
||||||
mMenuItemOptions,
|
mMenuItemOptions,
|
||||||
mHomeAssistantService
|
mHomeAssistantService
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
return new HomeAssistantIconMenuItem(
|
|
||||||
label,
|
|
||||||
null,
|
|
||||||
identifier,
|
|
||||||
service,
|
|
||||||
confirm,
|
|
||||||
mTapTypeIcon,
|
|
||||||
mMenuItemOptions,
|
|
||||||
mHomeAssistantService
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function group(definition as Lang.Dictionary) as WatchUi.MenuItem {
|
function group(definition as Lang.Dictionary) as WatchUi.MenuItem {
|
||||||
if (Settings.getMenuStyle() == Settings.MENU_STYLE_TEXT) {
|
return new HomeAssistantViewMenuItem(definition, mGroupTypeIcon, mMenuItemOptions);
|
||||||
return new HomeAssistantViewMenuItem(definition);
|
|
||||||
} else {
|
|
||||||
return new HomeAssistantViewIconMenuItem(definition, mGroupTypeIcon, mMenuItemOptions);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ class HomeAssistantView extends WatchUi.Menu2 {
|
|||||||
var lmi = mListMenuItems as Lang.Array<WatchUi.MenuItem>;
|
var lmi = mListMenuItems as Lang.Array<WatchUi.MenuItem>;
|
||||||
for(var i = 0; i < mListMenuItems.size(); i++) {
|
for(var i = 0; i < mListMenuItems.size(); i++) {
|
||||||
var item = lmi[i];
|
var item = lmi[i];
|
||||||
if (item instanceof HomeAssistantViewMenuItem || item instanceof HomeAssistantViewIconMenuItem) {
|
if (item instanceof HomeAssistantViewMenuItem) {
|
||||||
fullList.addAll(item.getMenuView().getItemsToUpdate());
|
fullList.addAll(item.getMenuView().getItemsToUpdate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,12 +154,6 @@ class HomeAssistantViewDelegate extends WatchUi.Menu2InputDelegate {
|
|||||||
System.println(haItem.getLabel() + " " + haItem.getId());
|
System.println(haItem.getLabel() + " " + haItem.getId());
|
||||||
}
|
}
|
||||||
haItem.callService();
|
haItem.callService();
|
||||||
} else if (item instanceof HomeAssistantIconMenuItem) {
|
|
||||||
var haItem = item as HomeAssistantIconMenuItem;
|
|
||||||
if (Globals.scDebug) {
|
|
||||||
System.println(haItem.getLabel() + " " + haItem.getId());
|
|
||||||
}
|
|
||||||
haItem.callService();
|
|
||||||
} else if (item instanceof HomeAssistantTemplateMenuItem) {
|
} else if (item instanceof HomeAssistantTemplateMenuItem) {
|
||||||
var haItem = item as HomeAssistantTemplateMenuItem;
|
var haItem = item as HomeAssistantTemplateMenuItem;
|
||||||
if (Globals.scDebug) {
|
if (Globals.scDebug) {
|
||||||
@ -168,12 +162,6 @@ class HomeAssistantViewDelegate extends WatchUi.Menu2InputDelegate {
|
|||||||
haItem.callService();
|
haItem.callService();
|
||||||
} else if (item instanceof HomeAssistantViewMenuItem) {
|
} else if (item instanceof HomeAssistantViewMenuItem) {
|
||||||
var haMenuItem = item as HomeAssistantViewMenuItem;
|
var haMenuItem = item as HomeAssistantViewMenuItem;
|
||||||
if (Globals.scDebug) {
|
|
||||||
System.println("Menu: " + haMenuItem.getLabel() + " " + haMenuItem.getId());
|
|
||||||
}
|
|
||||||
WatchUi.pushView(haMenuItem.getMenuView(), new HomeAssistantViewDelegate(false), WatchUi.SLIDE_LEFT);
|
|
||||||
} else if (item instanceof 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());
|
||||||
}
|
}
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
//-----------------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Distributed under MIT Licence
|
|
||||||
// See https://github.com/house-of-abbey/GarminHomeAssistant/blob/main/LICENSE.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// GarminHomeAssistant is a Garmin IQ application written in Monkey C and routinely
|
|
||||||
// tested on a Venu 2 device. The source code is provided at:
|
|
||||||
// https://github.com/house-of-abbey/GarminHomeAssistant.
|
|
||||||
//
|
|
||||||
// P A Abbey & J D Abbey & Someone0nEarth, 16 November 2023
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Description:
|
|
||||||
//
|
|
||||||
// Menu button with an icon that opens a sub-menu.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
using Toybox.Lang;
|
|
||||||
using Toybox.WatchUi;
|
|
||||||
|
|
||||||
class HomeAssistantViewIconMenuItem extends WatchUi.IconMenuItem {
|
|
||||||
private var mMenu as HomeAssistantView;
|
|
||||||
|
|
||||||
function initialize(definition as Lang.Dictionary, icon as WatchUi.Drawable, options as {
|
|
||||||
:alignment as WatchUi.MenuItem.Alignment
|
|
||||||
} or Null) {
|
|
||||||
var label = definition.get("name") as Lang.String;
|
|
||||||
var identifier = definition.get("entity") as Lang.String;
|
|
||||||
|
|
||||||
WatchUi.IconMenuItem.initialize(
|
|
||||||
label,
|
|
||||||
null,
|
|
||||||
identifier,
|
|
||||||
icon,
|
|
||||||
options
|
|
||||||
);
|
|
||||||
|
|
||||||
mMenu = new HomeAssistantView(definition, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getMenuView() as HomeAssistantView {
|
|
||||||
return mMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -9,28 +9,33 @@
|
|||||||
// tested on a Venu 2 device. The source code is provided at:
|
// tested on a Venu 2 device. The source code is provided at:
|
||||||
// https://github.com/house-of-abbey/GarminHomeAssistant.
|
// https://github.com/house-of-abbey/GarminHomeAssistant.
|
||||||
//
|
//
|
||||||
// P A Abbey & J D Abbey & Someone0nEarth, 31 October 2023
|
// P A Abbey & J D Abbey & Someone0nEarth, 16 November 2023
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Description:
|
// Description:
|
||||||
//
|
//
|
||||||
// Menu button that opens a sub-menu.
|
// Menu button with an icon that opens a sub-menu.
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------
|
||||||
|
|
||||||
using Toybox.Lang;
|
using Toybox.Lang;
|
||||||
using Toybox.WatchUi;
|
using Toybox.WatchUi;
|
||||||
|
|
||||||
class HomeAssistantViewMenuItem extends WatchUi.MenuItem {
|
class HomeAssistantViewMenuItem extends WatchUi.IconMenuItem {
|
||||||
private var mMenu as HomeAssistantView;
|
private var mMenu as HomeAssistantView;
|
||||||
|
|
||||||
function initialize(definition as Lang.Dictionary) {
|
function initialize(definition as Lang.Dictionary, icon as WatchUi.Drawable, options as {
|
||||||
// definitions.get(...) are Strings here as they have been checked by HomeAssistantView first
|
:alignment as WatchUi.MenuItem.Alignment
|
||||||
WatchUi.MenuItem.initialize(
|
} or Null) {
|
||||||
definition.get("name") as Lang.String,
|
var label = definition.get("name") as Lang.String;
|
||||||
RezStrings.getMenuItemMenu(),
|
var identifier = definition.get("entity") as Lang.String;
|
||||||
definition.get("entity") as Lang.String,
|
|
||||||
null
|
WatchUi.IconMenuItem.initialize(
|
||||||
|
label,
|
||||||
|
null,
|
||||||
|
identifier,
|
||||||
|
icon,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
|
|
||||||
mMenu = new HomeAssistantView(definition, null);
|
mMenu = new HomeAssistantView(definition, null);
|
||||||
|
@ -27,8 +27,6 @@ class RezStrings {
|
|||||||
|
|
||||||
(:glance)
|
(:glance)
|
||||||
private static var strAppName as Lang.String or Null;
|
private static var strAppName as Lang.String or Null;
|
||||||
private static var strMenuItemTap as Lang.String or Null;
|
|
||||||
private static var strMenuItemMenu as Lang.String or Null;
|
|
||||||
private static var strConfirm as Lang.String or Null;
|
private static var strConfirm as Lang.String or Null;
|
||||||
private static var strExecuted as Lang.String or Null;
|
private static var strExecuted as Lang.String or Null;
|
||||||
(:glance)
|
(:glance)
|
||||||
@ -61,7 +59,6 @@ class RezStrings {
|
|||||||
private static var strCached as Lang.String or Null;
|
private static var strCached as Lang.String or Null;
|
||||||
(:glance)
|
(:glance)
|
||||||
private static var strGlanceMenu as Lang.String or Null;
|
private static var strGlanceMenu as Lang.String or Null;
|
||||||
private static var strLabelToggle as Lang.Dictionary or Null;
|
|
||||||
|
|
||||||
// Can't initialise a constant directly, have to be initialised via a function
|
// Can't initialise a constant directly, have to be initialised via a function
|
||||||
// for 'WatchUi.loadResource' to be available.
|
// for 'WatchUi.loadResource' to be available.
|
||||||
@ -84,8 +81,6 @@ class RezStrings {
|
|||||||
// for 'WatchUi.loadResource' to be available.
|
// for 'WatchUi.loadResource' to be available.
|
||||||
static function update() {
|
static function update() {
|
||||||
strAppName = WatchUi.loadResource($.Rez.Strings.AppName);
|
strAppName = WatchUi.loadResource($.Rez.Strings.AppName);
|
||||||
strMenuItemTap = WatchUi.loadResource($.Rez.Strings.MenuItemTap);
|
|
||||||
strMenuItemMenu = WatchUi.loadResource($.Rez.Strings.MenuItemMenu);
|
|
||||||
strConfirm = WatchUi.loadResource($.Rez.Strings.Confirm);
|
strConfirm = WatchUi.loadResource($.Rez.Strings.Confirm);
|
||||||
strExecuted = WatchUi.loadResource($.Rez.Strings.Executed);
|
strExecuted = WatchUi.loadResource($.Rez.Strings.Executed);
|
||||||
strNoPhone = WatchUi.loadResource($.Rez.Strings.NoPhone);
|
strNoPhone = WatchUi.loadResource($.Rez.Strings.NoPhone);
|
||||||
@ -108,24 +103,12 @@ class RezStrings {
|
|||||||
strUnconfigured = WatchUi.loadResource($.Rez.Strings.Unconfigured);
|
strUnconfigured = WatchUi.loadResource($.Rez.Strings.Unconfigured);
|
||||||
strCached = WatchUi.loadResource($.Rez.Strings.Cached);
|
strCached = WatchUi.loadResource($.Rez.Strings.Cached);
|
||||||
strGlanceMenu = WatchUi.loadResource($.Rez.Strings.GlanceMenu);
|
strGlanceMenu = WatchUi.loadResource($.Rez.Strings.GlanceMenu);
|
||||||
strLabelToggle = {
|
|
||||||
:enabled => WatchUi.loadResource($.Rez.Strings.MenuItemOn) as Lang.String,
|
|
||||||
:disabled => WatchUi.loadResource($.Rez.Strings.MenuItemOff) as Lang.String
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getAppName() as Lang.String {
|
static function getAppName() as Lang.String {
|
||||||
return strAppName;
|
return strAppName;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getMenuItemTap() as Lang.String {
|
|
||||||
return strMenuItemTap;
|
|
||||||
}
|
|
||||||
|
|
||||||
static function getMenuItemMenu() as Lang.String {
|
|
||||||
return strMenuItemMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
static function getConfirm() as Lang.String {
|
static function getConfirm() as Lang.String {
|
||||||
return strConfirm;
|
return strConfirm;
|
||||||
}
|
}
|
||||||
@ -214,8 +197,4 @@ class RezStrings {
|
|||||||
return strGlanceMenu;
|
return strGlanceMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getLabelToggle() as Lang.Dictionary {
|
|
||||||
return strLabelToggle;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,9 +28,6 @@ using Toybox.Time;
|
|||||||
|
|
||||||
(:glance, :background)
|
(:glance, :background)
|
||||||
class Settings {
|
class Settings {
|
||||||
public static const MENU_STYLE_ICONS = 0;
|
|
||||||
public static const MENU_STYLE_TEXT = 1;
|
|
||||||
|
|
||||||
private static var mApiKey as Lang.String = "";
|
private static var mApiKey as Lang.String = "";
|
||||||
private static var mWebhookId as Lang.String = "";
|
private static var mWebhookId as Lang.String = "";
|
||||||
private static var mApiUrl as Lang.String = "";
|
private static var mApiUrl as Lang.String = "";
|
||||||
@ -39,7 +36,6 @@ class Settings {
|
|||||||
private static var mClearCache as Lang.Boolean = false;
|
private static var mClearCache as Lang.Boolean = false;
|
||||||
private static var mAppTimeout as Lang.Number = 0; // seconds
|
private static var mAppTimeout as Lang.Number = 0; // seconds
|
||||||
private static var mConfirmTimeout as Lang.Number = 3; // seconds
|
private static var mConfirmTimeout as Lang.Number = 3; // seconds
|
||||||
private static var mMenuStyle as Lang.Number = MENU_STYLE_ICONS;
|
|
||||||
private static var mMenuAlignment as Lang.Number = WatchUi.MenuItem.MENU_ITEM_LABEL_ALIGN_LEFT;
|
private static var mMenuAlignment as Lang.Number = WatchUi.MenuItem.MENU_ITEM_LABEL_ALIGN_LEFT;
|
||||||
private static var mIsWidgetStartNoTap as Lang.Boolean = false;
|
private static var mIsWidgetStartNoTap as Lang.Boolean = false;
|
||||||
private static var mIsBatteryLevelEnabled as Lang.Boolean = false;
|
private static var mIsBatteryLevelEnabled as Lang.Boolean = false;
|
||||||
@ -60,7 +56,6 @@ class Settings {
|
|||||||
mClearCache = Properties.getValue("clear_cache");
|
mClearCache = Properties.getValue("clear_cache");
|
||||||
mAppTimeout = Properties.getValue("app_timeout");
|
mAppTimeout = Properties.getValue("app_timeout");
|
||||||
mConfirmTimeout = Properties.getValue("confirm_timeout");
|
mConfirmTimeout = Properties.getValue("confirm_timeout");
|
||||||
mMenuStyle = Properties.getValue("menu_theme");
|
|
||||||
mMenuAlignment = Properties.getValue("menu_alignment");
|
mMenuAlignment = Properties.getValue("menu_alignment");
|
||||||
mIsWidgetStartNoTap = Properties.getValue("widget_start_no_tap");
|
mIsWidgetStartNoTap = Properties.getValue("widget_start_no_tap");
|
||||||
mIsBatteryLevelEnabled = Properties.getValue("enable_battery_level");
|
mIsBatteryLevelEnabled = Properties.getValue("enable_battery_level");
|
||||||
@ -143,10 +138,6 @@ class Settings {
|
|||||||
return mConfirmTimeout * 1000; // Convert to milliseconds
|
return mConfirmTimeout * 1000; // Convert to milliseconds
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getMenuStyle() as Lang.Number {
|
|
||||||
return mMenuStyle; // Either MENU_STYLE_ICONS or MENU_STYLE_TEXT
|
|
||||||
}
|
|
||||||
|
|
||||||
static function getMenuAlignment() as Lang.Number {
|
static function getMenuAlignment() as Lang.Number {
|
||||||
return mMenuAlignment; // Either WatchUi.MenuItem.MENU_ITEM_LABEL_ALIGN_RIGHT or WatchUi.MenuItem.MENU_ITEM_LABEL_ALIGN_LEFT
|
return mMenuAlignment; // Either WatchUi.MenuItem.MENU_ITEM_LABEL_ALIGN_RIGHT or WatchUi.MenuItem.MENU_ITEM_LABEL_ALIGN_LEFT
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user