mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2026-08-12 16:11:23 +00:00
Bug fix for PIN enabled items on non-touchscreen devices (#367)
Hopefully a simple change, but care is needed to check the logic. I have tested on the simulator, but then I did also last time and the logic was wrong.
This commit is contained in:
@@ -60,3 +60,4 @@
|
||||
| 3.12 | Amended GPS accuracy values used by the background service. |
|
||||
| 3.13 | Added support for new devices: `d2mach2pro`, `fr170`, `fr170m`, `fr70`. |
|
||||
| 3.14 | Numeric items now support `tap_action.data` fields so service call options like `transition` are catered for. See the documentation on [Additional Action Data](https://github.com/house-of-abbey/GarminHomeAssistant/blob/main/examples/Numeric.md#additional-action-data). This features has been provided by [@StumblingGamer](https://github.com/StumblingGamer). Now prevent PIN enabled menu items from being enabled on non-touch screen devices. The PIN must be removed for the menu item to function. Fix for initialising numeric pickers with no user defined template. |
|
||||
| 3.15 | The prevention of PIN enabled menu items on non-touch screen devices was improperly implemented, this version provides a bug fix. |
|
||||
|
||||
@@ -76,49 +76,32 @@ class HomeAssistantView extends WatchUi.Menu2 {
|
||||
}
|
||||
}
|
||||
if (type != null && name != null && enabled) {
|
||||
if (type.equals("toggle") && entity != null) {
|
||||
addItem(HomeAssistantMenuItemFactory.create().toggle(
|
||||
name,
|
||||
entity,
|
||||
content,
|
||||
{
|
||||
:exit => exit,
|
||||
:confirm => confirm,
|
||||
:pin => pin
|
||||
}
|
||||
));
|
||||
} else if (type.equals("tap") && action != null) {
|
||||
if (pin && !System.getDeviceSettings().isTouchScreen) {
|
||||
addItem(HomeAssistantMenuItemFactory.create().tap(
|
||||
name,
|
||||
entity,
|
||||
content,
|
||||
action,
|
||||
"PIN requires Touchscreen",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
data,
|
||||
{
|
||||
:exit => exit,
|
||||
:confirm => confirm,
|
||||
:pin => pin
|
||||
:exit => false,
|
||||
:confirm => false,
|
||||
:pin => false
|
||||
}
|
||||
));
|
||||
} else if (type.equals("template") && content != null) {
|
||||
// NB. "template" is deprecated in the schema and remains only for backward compatibility. All menu items can now use templates, so the replacement is "info".
|
||||
// The exit option is dependent on the type of template.
|
||||
if (tap_action == null) {
|
||||
// No exit from an information only item
|
||||
addItem(HomeAssistantMenuItemFactory.create().tap(
|
||||
} else {
|
||||
if (type.equals("toggle") && entity != null) {
|
||||
addItem(HomeAssistantMenuItemFactory.create().toggle(
|
||||
name,
|
||||
entity,
|
||||
content,
|
||||
action,
|
||||
data,
|
||||
{
|
||||
:exit => false,
|
||||
:exit => exit,
|
||||
:confirm => confirm,
|
||||
:pin => pin
|
||||
}
|
||||
));
|
||||
} else {
|
||||
// You may exit from template item with a 'tap_action'.
|
||||
} else if (type.equals("tap") && action != null) {
|
||||
addItem(HomeAssistantMenuItemFactory.create().tap(
|
||||
name,
|
||||
entity,
|
||||
@@ -131,9 +114,39 @@ class HomeAssistantView extends WatchUi.Menu2 {
|
||||
:pin => pin
|
||||
}
|
||||
));
|
||||
}
|
||||
} else if (type.equals("numeric") && action != null) {
|
||||
if (System.getDeviceSettings().isTouchScreen) {
|
||||
} else if (type.equals("template") && content != null) {
|
||||
// NB. "template" is deprecated in the schema and remains only for backward compatibility. All menu items can now use templates, so the replacement is "info".
|
||||
// The exit option is dependent on the type of template.
|
||||
if (tap_action == null) {
|
||||
// No exit from an information only item
|
||||
addItem(HomeAssistantMenuItemFactory.create().tap(
|
||||
name,
|
||||
entity,
|
||||
content,
|
||||
action,
|
||||
data,
|
||||
{
|
||||
:exit => false,
|
||||
:confirm => confirm,
|
||||
:pin => pin
|
||||
}
|
||||
));
|
||||
} else {
|
||||
// You may exit from template item with a 'tap_action'.
|
||||
addItem(HomeAssistantMenuItemFactory.create().tap(
|
||||
name,
|
||||
entity,
|
||||
content,
|
||||
action,
|
||||
data,
|
||||
{
|
||||
:exit => exit,
|
||||
:confirm => confirm,
|
||||
:pin => pin
|
||||
}
|
||||
));
|
||||
}
|
||||
} else if (type.equals("numeric") && action != null) {
|
||||
// Numeric items are only actionable on touch screen devices.
|
||||
if (tap_action != null) {
|
||||
var picker = tap_action.get("picker") as Lang.Dictionary?;
|
||||
@@ -153,36 +166,23 @@ class HomeAssistantView extends WatchUi.Menu2 {
|
||||
));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if (type.equals("info") && content != null) {
|
||||
// Cannot exit from a non-actionable information only menu item.
|
||||
addItem(HomeAssistantMenuItemFactory.create().tap(
|
||||
"PIN requires Touchscreen",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
name,
|
||||
entity,
|
||||
content,
|
||||
action,
|
||||
data,
|
||||
{
|
||||
:exit => false,
|
||||
:confirm => false,
|
||||
:pin => false
|
||||
:confirm => confirm,
|
||||
:pin => pin
|
||||
}
|
||||
));
|
||||
} else if (type.equals("group")) {
|
||||
addItem(HomeAssistantMenuItemFactory.create().group(items[i], content));
|
||||
}
|
||||
} else if (type.equals("info") && content != null) {
|
||||
// Cannot exit from a non-actionable information only menu item.
|
||||
addItem(HomeAssistantMenuItemFactory.create().tap(
|
||||
name,
|
||||
entity,
|
||||
content,
|
||||
action,
|
||||
data,
|
||||
{
|
||||
:exit => false,
|
||||
:confirm => confirm,
|
||||
:pin => pin
|
||||
}
|
||||
));
|
||||
} else if (type.equals("group")) {
|
||||
addItem(HomeAssistantMenuItemFactory.create().group(items[i], content));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user