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:
Joseph Abbey
2026-07-28 19:53:39 +01:00
committed by GitHub
2 changed files with 58 additions and 57 deletions

View File

@@ -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. |

View File

@@ -76,6 +76,20 @@ class HomeAssistantView extends WatchUi.Menu2 {
}
}
if (type != null && name != null && enabled) {
if (pin && !System.getDeviceSettings().isTouchScreen) {
addItem(HomeAssistantMenuItemFactory.create().tap(
"PIN requires Touchscreen",
null,
null,
null,
data,
{
:exit => false,
:confirm => false,
:pin => false
}
));
} else {
if (type.equals("toggle") && entity != null) {
addItem(HomeAssistantMenuItemFactory.create().toggle(
name,
@@ -133,7 +147,6 @@ class HomeAssistantView extends WatchUi.Menu2 {
));
}
} else if (type.equals("numeric") && action != null) {
if (System.getDeviceSettings().isTouchScreen) {
// Numeric items are only actionable on touch screen devices.
if (tap_action != null) {
var picker = tap_action.get("picker") as Lang.Dictionary?;
@@ -153,20 +166,6 @@ class HomeAssistantView extends WatchUi.Menu2 {
));
}
}
} else {
addItem(HomeAssistantMenuItemFactory.create().tap(
"PIN requires Touchscreen",
null,
null,
null,
data,
{
:exit => false,
:confirm => false,
:pin => false
}
));
}
} else if (type.equals("info") && content != null) {
// Cannot exit from a non-actionable information only menu item.
addItem(HomeAssistantMenuItemFactory.create().tap(
@@ -188,6 +187,7 @@ class HomeAssistantView extends WatchUi.Menu2 {
}
}
}
}
//! Return a list of items that need to be updated within this menu structure.
//!